f4a2713ac8
Change-Id: Ia40e9ffdf29b5dab2f122f673ff6802a58bc690f
39 lines
1.2 KiB
Text
39 lines
1.2 KiB
Text
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -verify %s
|
|
|
|
void clang_analyzer_eval(bool);
|
|
@class NSString;
|
|
|
|
void sanity() {
|
|
clang_analyzer_eval(@""); // expected-warning{{TRUE}}
|
|
clang_analyzer_eval(@"abc"); // expected-warning{{TRUE}}
|
|
}
|
|
|
|
namespace rdar13773117 {
|
|
NSString *const kConstantGlobalString = @"foo";
|
|
NSString *globalString = @"bar";
|
|
|
|
extern void invalidateGlobals();
|
|
|
|
void testGlobals() {
|
|
clang_analyzer_eval(kConstantGlobalString); // expected-warning{{TRUE}}
|
|
clang_analyzer_eval(globalString); // expected-warning{{UNKNOWN}}
|
|
|
|
globalString = @"baz";
|
|
clang_analyzer_eval(globalString); // expected-warning{{TRUE}}
|
|
|
|
invalidateGlobals();
|
|
|
|
clang_analyzer_eval(kConstantGlobalString); // expected-warning{{TRUE}}
|
|
clang_analyzer_eval(globalString); // expected-warning{{UNKNOWN}}
|
|
}
|
|
|
|
NSString *returnString(NSString *input = @"garply") {
|
|
return input;
|
|
}
|
|
|
|
void testDefaultArg() {
|
|
clang_analyzer_eval(returnString(@"")); // expected-warning{{TRUE}}
|
|
clang_analyzer_eval(returnString(0)); // expected-warning{{FALSE}}
|
|
clang_analyzer_eval(returnString()); // expected-warning{{TRUE}}
|
|
}
|
|
}
|