r343632 - [analyzer] Promote StdCLibraryFunctionsChecker to the apiModeling category.
Artem Dergachev via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 2 13:50:41 PDT 2018
Author: dergachev
Date: Tue Oct 2 13:50:40 2018
New Revision: 343632
URL: http://llvm.org/viewvc/llvm-project?rev=343632&view=rev
Log:
[analyzer] Promote StdCLibraryFunctionsChecker to the apiModeling category.
Because all our languages are C-based, there's no reason to
enable this checker only on UNIX targets.
Patch by DonĂ¡t Nagy!
Differential Revision: https://reviews.llvm.org/D52722
Modified:
cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
cfe/trunk/test/Analysis/conversion.c
cfe/trunk/test/Analysis/std-c-library-functions-inlined.c
cfe/trunk/test/Analysis/std-c-library-functions.c
cfe/trunk/test/Analysis/std-c-library-functions.cpp
Modified: cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td?rev=343632&r1=343631&r2=343632&view=diff
==============================================================================
--- cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td (original)
+++ cfe/trunk/include/clang/StaticAnalyzer/Checkers/Checkers.td Tue Oct 2 13:50:40 2018
@@ -220,11 +220,15 @@ def NullableReturnedFromNonnullChecker :
let ParentPackage = APIModeling in {
+def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
+ HelpText<"Improve modeling of the C standard library functions">,
+ DescFile<"StdLibraryFunctionsChecker.cpp">;
+
def TrustNonnullChecker : Checker<"TrustNonnull">,
HelpText<"Trust that returns from framework methods annotated with _Nonnull are not null">,
DescFile<"TrustNonnullChecker.cpp">;
-}
+} // end "apiModeling"
//===----------------------------------------------------------------------===//
// Evaluate "builtin" functions.
@@ -494,10 +498,6 @@ def VforkChecker : Checker<"Vfork">,
HelpText<"Check for proper usage of vfork">,
DescFile<"VforkChecker.cpp">;
-def StdCLibraryFunctionsChecker : Checker<"StdCLibraryFunctions">,
- HelpText<"Improve modeling of the C standard library functions">,
- DescFile<"StdLibraryFunctionsChecker.cpp">;
-
} // end "unix"
let ParentPackage = UnixAlpha in {
Modified: cfe/trunk/test/Analysis/conversion.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/conversion.c?rev=343632&r1=343631&r2=343632&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/conversion.c (original)
+++ cfe/trunk/test/Analysis/conversion.c Tue Oct 2 13:50:40 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare -analyzer-checker=core,alpha.core.Conversion -verify %s
+// RUN: %clang_analyze_cc1 -Wno-conversion -Wno-tautological-constant-compare -analyzer-checker=core,apiModeling,alpha.core.Conversion -verify %s
unsigned char U8;
signed char S8;
@@ -138,15 +138,14 @@ void dontwarn5() {
}
-// false positives..
+// C library functions, handled via apiModeling.StdCLibraryFunctions
int isascii(int c);
-void falsePositive1() {
+void libraryFunction1() {
char kb2[5];
int X = 1000;
if (isascii(X)) {
- // FIXME: should not warn here:
- kb2[0] = X; // expected-warning {{Loss of precision}}
+ kb2[0] = X; // no-warning
}
}
@@ -156,7 +155,7 @@ typedef struct FILE {} FILE; int getc(FI
char reply_string[8192];
FILE *cin;
extern int dostuff (void);
-int falsePositive2() {
+int libraryFunction2() {
int c, n;
int dig;
char *cp = reply_string;
@@ -175,8 +174,7 @@ int falsePositive2() {
if (c == EOF)
return(4);
if (cp < &reply_string[sizeof(reply_string) - 1])
- // FIXME: should not warn here:
- *cp++ = c; // expected-warning {{Loss of precision}}
+ *cp++ = c; // no-warning
}
}
}
Modified: cfe/trunk/test/Analysis/std-c-library-functions-inlined.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions-inlined.c?rev=343632&r1=343631&r2=343632&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/std-c-library-functions-inlined.c (original)
+++ cfe/trunk/test/Analysis/std-c-library-functions-inlined.c Tue Oct 2 13:50:40 2018
@@ -1,8 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=unix.StdCLibraryFunctions -verify %s
-// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s
-// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s
-// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=apiModeling.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions -verify %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions -verify %s
// This test tests crashes that occur when standard functions are available
// for inlining.
Modified: cfe/trunk/test/Analysis/std-c-library-functions.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions.c?rev=343632&r1=343631&r2=343632&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/std-c-library-functions.c (original)
+++ cfe/trunk/test/Analysis/std-c-library-functions.c Tue Oct 2 13:50:40 2018
@@ -1,8 +1,8 @@
-// RUN: %clang_analyze_cc1 -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
-// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple i686-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple armv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
+// RUN: %clang_analyze_cc1 -triple thumbv7-a15-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify -analyzer-config eagerly-assume=false %s
void clang_analyzer_eval(int);
Modified: cfe/trunk/test/Analysis/std-c-library-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/std-c-library-functions.cpp?rev=343632&r1=343631&r2=343632&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/std-c-library-functions.cpp (original)
+++ cfe/trunk/test/Analysis/std-c-library-functions.cpp Tue Oct 2 13:50:40 2018
@@ -1,4 +1,4 @@
-// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=unix.StdCLibraryFunctions,debug.ExprInspection -verify %s
+// RUN: %clang_analyze_cc1 -triple x86_64-unknown-linux -analyzer-checker=apiModeling.StdCLibraryFunctions,debug.ExprInspection -verify %s
// Test that we don't model functions with broken prototypes.
// Because they probably work differently as well.
More information about the cfe-commits
mailing list