]> granicus.if.org Git - clang/commitdiff
[analyzer] Add a test for copy-constructor inlining.
authorJordan Rose <jordan_rose@apple.com>
Fri, 3 Aug 2012 23:08:36 +0000 (23:08 +0000)
committerJordan Rose <jordan_rose@apple.com>
Fri, 3 Aug 2012 23:08:36 +0000 (23:08 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@161274 91177308-0d34-0410-b5e6-96231b3b80d8

test/Analysis/ctor-inlining.mm

index 586c09d3048772cc13dd63401f0686b7a17fd38c..54d51b46dc5eea3f59aeec453160af8df72a924a 100644 (file)
@@ -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}}
+}
+