[analyzer] Add a test for copy-constructor inlining.
llvm-svn: 161274
This commit is contained in:
parent
24bc514c0c
commit
86bedb0de0
|
@ -1,4 +1,6 @@
|
|||
// RUN: %clang_cc1 -analyze -analyzer-checker=core -fobjc-arc -cfg-add-implicit-dtors -Wno-null-dereference -verify %s
|
||||
// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -fobjc-arc -cfg-add-implicit-dtors -Wno-null-dereference -verify %s
|
||||
|
||||
void clang_analyzer_eval(bool);
|
||||
|
||||
struct Wrapper {
|
||||
__strong id obj;
|
||||
|
@ -9,3 +11,31 @@ void test() {
|
|||
// force a diagnostic
|
||||
*(char *)0 = 1; // expected-warning{{Dereference of null pointer}}
|
||||
}
|
||||
|
||||
|
||||
struct IntWrapper {
|
||||
int x;
|
||||
};
|
||||
|
||||
void testCopyConstructor() {
|
||||
IntWrapper a;
|
||||
a.x = 42;
|
||||
|
||||
IntWrapper b(a);
|
||||
clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}}
|
||||
}
|
||||
|
||||
struct NonPODIntWrapper {
|
||||
int x;
|
||||
|
||||
virtual int get();
|
||||
};
|
||||
|
||||
void testNonPODCopyConstructor() {
|
||||
NonPODIntWrapper a;
|
||||
a.x = 42;
|
||||
|
||||
NonPODIntWrapper b(a);
|
||||
clang_analyzer_eval(b.x == 42); // expected-warning{{TRUE}}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue