[PATCH] D88833: [clang-tidy] Do not warn on pointer decays in system macros

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 6 00:26:25 PDT 2020


njames93 added a comment.

Can you please upload this diff with full context `-U999999`



================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:50
+
+AST_MATCHER(ImplicitCastExpr, isArrayToPointerDecay) {
+  return Node.getCastKind() == CK_ArrayToPointerDecay;
----------------
Is this matcher necessary, there is already a matcher `hasCastKind` that'll do this functionality


================
Comment at: clang-tools-extra/clang-tidy/cppcoreguidelines/ProBoundsArrayToPointerDecayCheck.cpp:56
+  auto &SM = Finder->getASTContext().getSourceManager();
+  if (!SM.isInSystemMacro(Node.getBeginLoc())) {
+    return false;
----------------
Elide braces on single line if branches


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:13
 };
-}
+} // namespace gsl
 
----------------
Unrelated formatting changes


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:36
+  int j = a[(1 + 2)]; // OK
+  pointerfun(&a[0]);  // OK
 
----------------
Unrelated formatting change


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:46
 const char *g2() {
-    return ("clang"); // OK, ParenExpr hides the literal-pointer decay
+  return ("clang"); // OK, ParenExpr hides the literal-pointer decay
 }
----------------
Unrelated formatting change


================
Comment at: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-bounds-array-to-pointer-decay.cpp:52
   void *a[2];
-  f2(static_cast<void *const*>(a)); // OK, explicit cast
+  f2(static_cast<void *const *>(a)); // OK, explicit cast
+}
----------------
Unrelated formatting change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D88833/new/

https://reviews.llvm.org/D88833



More information about the cfe-commits mailing list