[PATCH] D80887: [clang-tidy] ignore builtin varargs from pro-type-vararg-check

Nathan James via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun May 31 07:58:20 PDT 2020


njames93 updated this revision to Diff 267497.
njames93 added a comment.

Remove unnecessary fixme.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D80887

Files:
  clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
  clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp


Index: clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
===================================================================
--- clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
+++ clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp
@@ -49,3 +49,11 @@
 }
 
 int my_vprintf(const char* format, va_list arg ); // OK to declare function taking va_list
+
+void ignoredBuiltinsTest() {
+  (void)__builtin_assume_aligned(0, 8);
+  (void)__builtin_constant_p(0);
+  (void)__builtin_fpclassify(0, 0, 0, 0, 0, 0.f);
+  (void)__builtin_isinf_sign(0.f);
+  (void)__builtin_prefetch(nullptr);
+}
Index: clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
===================================================================
--- clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
+++ clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp
@@ -18,11 +18,19 @@
 
 const internal::VariadicDynCastAllOfMatcher<Stmt, VAArgExpr> vAArgExpr;
 
+static constexpr StringRef AllowedVariadics[] = {
+    "__builtin_constant_p", "__builtin_isinf_sign", "__builtin_assume_aligned",
+    "__builtin_prefetch",   "__builtin_fpclassify",
+};
+
 void ProTypeVarargCheck::registerMatchers(MatchFinder *Finder) {
   Finder->addMatcher(vAArgExpr().bind("va_use"), this);
 
   Finder->addMatcher(
-      callExpr(callee(functionDecl(isVariadic()))).bind("callvararg"), this);
+      callExpr(callee(functionDecl(isVariadic(),
+                                   unless(hasAnyName(AllowedVariadics)))))
+          .bind("callvararg"),
+      this);
 }
 
 static bool hasSingleVariadicArgumentWithValue(const CallExpr *C, uint64_t I) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D80887.267497.patch
Type: text/x-patch
Size: 1743 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200531/d4c3e612/attachment.bin>


More information about the cfe-commits mailing list