diff --git a/clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.cpp b/clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.cpp index ac788a3aee5c..a5f8fa7e7334 100644 --- a/clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.cpp +++ b/clang-tools-extra/clang-tidy/cert/VariadicFunctionDefCheck.cpp @@ -20,9 +20,12 @@ void VariadicFunctionDefCheck::registerMatchers(MatchFinder *Finder) { if (!getLangOpts().CPlusPlus) return; - // We only care about function *definitions* that are variadic. - Finder->addMatcher(functionDecl(isDefinition(), isVariadic()).bind("func"), - this); + // We only care about function *definitions* that are variadic, and do not + // have extern "C" language linkage. + Finder->addMatcher( + functionDecl(isDefinition(), isVariadic(), unless(isExternC())) + .bind("func"), + this); } void VariadicFunctionDefCheck::check(const MatchFinder::MatchResult &Result) { diff --git a/clang-tools-extra/test/clang-tidy/cert-variadic-function-def.cpp b/clang-tools-extra/test/clang-tidy/cert-variadic-function-def.cpp index 6bb6b1371b86..2c1420b9e362 100644 --- a/clang-tools-extra/test/clang-tidy/cert-variadic-function-def.cpp +++ b/clang-tools-extra/test/clang-tidy/cert-variadic-function-def.cpp @@ -16,3 +16,9 @@ struct S { void f1(int, ...) {} // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: do not define a C-style variadic function; consider using a function parameter pack or currying instead }; + +// Function definitions that are extern "C" are good. +extern "C" void f4(int, ...) {} // ok +extern "C" { + void f5(int, ...) {} // ok +}