[clang-tools-extra] r249555 - Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.
Aaron Ballman via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 7 08:14:11 PDT 2015
Author: aaronballman
Date: Wed Oct 7 10:14:10 2015
New Revision: 249555
URL: http://llvm.org/viewvc/llvm-project?rev=249555&view=rev
Log:
Loosening the restriction on variadic function definitions so that extern "C" function definitions are permissible.
Modified:
clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp
Modified: clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp?rev=249555&r1=249554&r2=249555&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/cert/VariadicFunctionDefCheck.cpp Wed Oct 7 10:14:10 2015
@@ -20,9 +20,12 @@ void VariadicFunctionDefCheck::registerM
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) {
Modified: clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp?rev=249555&r1=249554&r2=249555&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/cert-variadic-function-def.cpp Wed Oct 7 10:14:10 2015
@@ -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
+}
More information about the cfe-commits
mailing list