[cfe-commits] r161274 - /cfe/trunk/test/Analysis/ctor-inlining.mm

Jordan Rose jordan_rose at apple.com
Fri Aug 3 16:08:36 PDT 2012


Author: jrose
Date: Fri Aug  3 18:08:36 2012
New Revision: 161274

URL: http://llvm.org/viewvc/llvm-project?rev=161274&view=rev
Log:
[analyzer] Add a test for copy-constructor inlining.

Modified:
    cfe/trunk/test/Analysis/ctor-inlining.mm

Modified: cfe/trunk/test/Analysis/ctor-inlining.mm
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Analysis/ctor-inlining.mm?rev=161274&r1=161273&r2=161274&view=diff
==============================================================================
--- cfe/trunk/test/Analysis/ctor-inlining.mm (original)
+++ cfe/trunk/test/Analysis/ctor-inlining.mm Fri Aug  3 18:08:36 2012
@@ -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 @@
   // 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}}
+}
+





More information about the cfe-commits mailing list