Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.

llvm-svn: 249555
This commit is contained in:
Aaron Ballman 2015-10-07 15:14:10 +00:00
parent fcc7f6622f
commit fd3a3b3f29
2 changed files with 12 additions and 3 deletions

View File

@ -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) {

View File

@ -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
}