# HG changeset patch # User Andi-Bogdan Postelnicu # Date 1538398359 0 # Mon Oct 01 12:52:39 2018 +0000 # Node ID 4f99cc71fbde7304efa7fcb73fd01f9593a62299 # Parent 0d7a61d5930803d0b64a2a9ac0ab9009b4ce3c7d Bug 1494951 - [Static-Analysis][Clang-Tidy] Publish checker 'readability-redundant-smartptr-get'. r=janx Differential Revision: https://phabricator.services.mozilla.com/D7169 diff --git a/tools/clang-tidy/config.yaml b/tools/clang-tidy/config.yaml --- a/tools/clang-tidy/config.yaml +++ b/tools/clang-tidy/config.yaml @@ -113,17 +113,16 @@ clang_checkers: - name: readability-container-size-empty - name: readability-delete-null-pointer - name: readability-else-after-return - name: readability-inconsistent-declaration-parameter-name - name: readability-misleading-indentation - name: readability-non-const-parameter - name: readability-redundant-control-flow - name: readability-redundant-smartptr-get - publish: !!bool no - name: readability-redundant-string-cstr - name: readability-redundant-string-init - name: readability-static-accessed-through-instance - name: readability-simplify-boolean-expr - name: readability-uniqueptr-delete-release # We don't publish the google checkers since we are interested in only having # a general idea how our code complies with the rules added by these checkers. - name: google-build-explicit-make-pair diff --git a/tools/clang-tidy/test/readability-redundant-smartptr-get.cpp b/tools/clang-tidy/test/readability-redundant-smartptr-get.cpp --- a/tools/clang-tidy/test/readability-redundant-smartptr-get.cpp +++ b/tools/clang-tidy/test/readability-redundant-smartptr-get.cpp @@ -1,11 +1,20 @@ -#include +#define NULL __null + +namespace std { + +template +struct unique_ptr { + T& operator*() const; + T* operator->() const; + T* get() const; + explicit operator bool() const noexcept; +}; +} struct A { - void f() {} }; void foo() { - std::unique_ptr ptr = std::make_unique(); - ptr.get()->f(); + A& b2 = *std::unique_ptr().get(); } diff --git a/tools/clang-tidy/test/readability-redundant-smartptr-get.json b/tools/clang-tidy/test/readability-redundant-smartptr-get.json --- a/tools/clang-tidy/test/readability-redundant-smartptr-get.json +++ b/tools/clang-tidy/test/readability-redundant-smartptr-get.json @@ -1,1 +1,1 @@ -"[[\"warning\", \"redundant get() call on smart pointer\", \"readability-redundant-smartptr-get\"]]" \ No newline at end of file +[["warning", "redundant get() call on smart pointer", "readability-redundant-smartptr-get"]] \ No newline at end of file