[clang-tidy] google-explicit-constructor: ignore macros

llvm-svn: 290756
This commit is contained in:
Alexander Kornienko 2016-12-30 15:15:14 +00:00
parent 75e39f9790
commit 2042f833fd
2 changed files with 11 additions and 1 deletions

View File

@ -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;

View File

@ -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);