Sockke created this revision. Sockke added a reviewer: aaron.ballman. Herald added subscribers: carlosgalvezp, shchenz, kbarton, xazax.hun, nemanjai. Herald added a reviewer: njames93. Herald added a project: All. Sockke requested review of this revision. Herald added a project: clang-tools-extra. Herald added a subscriber: cfe-commits.
https://godbolt.org/z/n4cK4fo3o The checker missed a check for invalid vardecl and this could cause a false positive. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D138655 Files: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -60,6 +60,8 @@ const ASTContext &Context = *Result.Context; const SourceManager &Source = Context.getSourceManager(); + if (MatchedDecl->isInvalidDecl()) + return; // We want to warn about cases where the type name // comes from a macro like this: //
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp =================================================================== --- clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp +++ clang-tools-extra/clang-tidy/cppcoreguidelines/InitVariablesCheck.cpp @@ -60,6 +60,8 @@ const ASTContext &Context = *Result.Context; const SourceManager &Source = Context.getSourceManager(); + if (MatchedDecl->isInvalidDecl()) + return; // We want to warn about cases where the type name // comes from a macro like this: //
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits