diff --git a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp --- a/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp +++ b/clang-tools-extra/clang-tidy/cppcoreguidelines/ProTypeVarargCheck.cpp @@ -18,11 +18,20 @@ const internal::VariadicDynCastAllOfMatcher vAArgExpr; +// FIXME: Add any more builtin variadics that shouldn't trigger this +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) { diff --git a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp b/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp --- a/clang-tools-extra/test/clang-tidy/checkers/cppcoreguidelines-pro-type-vararg.cpp +++ b/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); +}