[PATCH] D31130: B32239 clang-tidy should not warn about array to pointer decay on system macros
Aaron Ballman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Mar 20 15:15:49 PDT 2017
aaron.ballman added inline comments.
================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:50
+AST_MATCHER(Stmt, isArrayToPointerDecay) {
+ const auto *MatchedCast = cast<ImplicitCastExpr>(&Node);
----------------
Why not match on `ImplicitCastExpr` rather than `Stmt`? Then you can remove the explicit cast below.
================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:55
+
+AST_MATCHER(Stmt, sysSymbolDecayInSysHeader) {
+ const auto *E = cast<ImplicitCastExpr>(&Node);
----------------
Likewise here.
================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:59-60
+ if (SM.isInSystemMacro(E->getLocStart())) {
+ const auto *PredefSymbol = dyn_cast<PredefinedExpr>(E->getSubExpr());
+ if (PredefSymbol)
+ return true;
----------------
I think this is better-expressed with an isa check: `if (isa<PredefinedExpr>(E->getSubExpr())) return true;`
================
Comment at: clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:63-64
+
+ const auto *SymbolDeclRef = dyn_cast<DeclRefExpr>(E->getSubExpr());
+ if (SymbolDeclRef) {
+ const ValueDecl *SymbolDecl = SymbolDeclRef->getDecl();
----------------
You can combine these into `if (const auto *SDR = dyn_cast<>())`
https://reviews.llvm.org/D31130
More information about the cfe-commits
mailing list