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) {
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) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits