summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp
diff options
context:
space:
mode:
authorMiklos Vajna <vmiklos@vmiklos.hu>2018-10-21 19:16:25 +0000
committerMiklos Vajna <vmiklos@vmiklos.hu>2018-10-21 19:16:25 +0000
commite967a12733565fff0beb16865bd21e381b75b250 (patch)
tree07156e641bab1e93ceda8f59e80c709dd42f2931 /clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp
parentca8a05ac34b69559911a014c64fdbaa998c1da99 (diff)
downloadbcm5719-llvm-e967a12733565fff0beb16865bd21e381b75b250.tar.gz
bcm5719-llvm-e967a12733565fff0beb16865bd21e381b75b250.zip
[clang-tidy] add IgnoreMacros option to readability-redundant-smartptr-get
And also enable it by default to be consistent with e.g. modernize-use-using. This helps e.g. when running this check on client code where the macro is provided by the system, so there is no easy way to modify it. Reviewed By: JonasToth Differential Revision: https://reviews.llvm.org/D53454 llvm-svn: 344871
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp')
-rw-r--r--clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp24
1 files changed, 24 insertions, 0 deletions
diff --git a/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp b/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp
new file mode 100644
index 00000000000..79e4d9224bc
--- /dev/null
+++ b/clang-tools-extra/test/clang-tidy/readability-redundant-smartptr-get-macros.cpp
@@ -0,0 +1,24 @@
+// RUN: %check_clang_tidy %s readability-redundant-smartptr-get %t -- \
+// RUN: -config="{CheckOptions: [{key: readability-redundant-smartptr-get.IgnoreMacros, value: 0}]}" \
+// RUN: -- -std=c++11
+
+namespace std {
+
+template <typename T>
+struct shared_ptr {
+ T &operator*() const;
+ T *operator->() const;
+ T *get() const;
+ explicit operator bool() const noexcept;
+};
+
+} // namespace std
+
+#define MACRO(p) p.get()
+
+void Positive() {
+ std::shared_ptr<int> x;
+ if (MACRO(x) == nullptr)
+ ;
+ // CHECK-MESSAGES: :[[@LINE-2]]:13: warning: redundant get() call on smart pointer
+};
OpenPOWER on IntegriCloud