forked from OSchip/llvm-project
[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 llvm-svn: 343632
This commit is contained in:
parent
d807f9065b
commit
e602dfbc62
|
@ -220,11 +220,15 @@ def NullableReturnedFromNonnullChecker : Checker<"NullableReturnedFromNonnull">,
|
|||
|
||||
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 {
|
||||
|
|
|
@ -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(FILE *stream);
|
|||
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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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.
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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.
|
||||
|
|
Loading…
Reference in New Issue