summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra
diff options
context:
space:
mode:
authorAlexander Kornienko <alexfh@google.com>2016-12-30 15:15:14 +0000
committerAlexander Kornienko <alexfh@google.com>2016-12-30 15:15:14 +0000
commit2042f833fdb8bea4a347e4291c1e76df1ef5a43f (patch)
tree7ab6412e37a9f81cc3c36caa2360c3b740b95384 /clang-tools-extra
parent75e39f9790f4049df1cda33c1472a62cd06f9bfe (diff)
downloadbcm5719-llvm-2042f833fdb8bea4a347e4291c1e76df1ef5a43f.tar.gz
bcm5719-llvm-2042f833fdb8bea4a347e4291c1e76df1ef5a43f.zip
[clang-tidy] google-explicit-constructor: ignore macros
llvm-svn: 290756
Diffstat (limited to 'clang-tools-extra')
-rw-r--r--clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp4
-rw-r--r--clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp8
2 files changed, 11 insertions, 1 deletions
diff --git a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
index 1605626d142..220d31c360e 100644
--- a/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
+++ b/clang-tools-extra/clang-tidy/google/ExplicitConstructorCheck.cpp
@@ -89,6 +89,10 @@ void ExplicitConstructorCheck::check(const MatchFinder::MatchResult &Result) {
if (const auto *Conversion =
Result.Nodes.getNodeAs<CXXConversionDecl>("conversion")) {
SourceLocation Loc = Conversion->getLocation();
+ // Ignore all macros until we learn to ignore specific ones (e.g. used in
+ // gmock to define matchers).
+ if (Loc.isMacroID())
+ return;
diag(Loc, WarningMessage)
<< Conversion << FixItHint::CreateInsertion(Loc, "explicit ");
return;
diff --git a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp
index aac6ab62bd2..4143e937c71 100644
--- a/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp
+++ b/clang-tools-extra/test/clang-tidy/google-explicit-constructor.cpp
@@ -168,5 +168,11 @@ void f2() {
if (b) {}
(void)(F<double>*)b;
(void)(F<double*>*)b;
-
}
+
+#define DEFINE_STRUCT_WITH_OPERATOR_BOOL(name) \
+ struct name { \
+ operator bool() const; \
+ }
+
+DEFINE_STRUCT_WITH_OPERATOR_BOOL(H);
OpenPOWER on IntegriCloud