summaryrefslogtreecommitdiff
path: root/test/Analysis/unified-sources
diff options
context:
space:
mode:
Diffstat (limited to 'test/Analysis/unified-sources')
-rw-r--r--test/Analysis/unified-sources/UnifiedSource-1.cpp5
-rw-r--r--test/Analysis/unified-sources/container.h10
-rw-r--r--test/Analysis/unified-sources/source1.cpp15
-rw-r--r--test/Analysis/unified-sources/source2.cpp25
4 files changed, 55 insertions, 0 deletions
diff --git a/test/Analysis/unified-sources/UnifiedSource-1.cpp b/test/Analysis/unified-sources/UnifiedSource-1.cpp
new file mode 100644
index 0000000000000..02569f247ee08
--- /dev/null
+++ b/test/Analysis/unified-sources/UnifiedSource-1.cpp
@@ -0,0 +1,5 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// There should still be diagnostics within included files.
+#include "source1.cpp"
+#include "source2.cpp"
diff --git a/test/Analysis/unified-sources/container.h b/test/Analysis/unified-sources/container.h
new file mode 100644
index 0000000000000..d0bcd778899a5
--- /dev/null
+++ b/test/Analysis/unified-sources/container.h
@@ -0,0 +1,10 @@
+class ContainerInHeaderFile {
+ class Iterator {
+ };
+
+public:
+ Iterator begin() const;
+ Iterator end() const;
+
+ int method() { return 0; }
+};
diff --git a/test/Analysis/unified-sources/source1.cpp b/test/Analysis/unified-sources/source1.cpp
new file mode 100644
index 0000000000000..886afed8d4178
--- /dev/null
+++ b/test/Analysis/unified-sources/source1.cpp
@@ -0,0 +1,15 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line in this file is there
+// only to suppress LIT warning for the complete lack of run-line.
+int foo(int x) {
+ if (x) {}
+ return 1 / x; // expected-warning{{}}
+}
+
+// Let's see if the container inlining heuristic still works.
+#include "container.h"
+int testContainerMethodInHeaderFile(ContainerInHeaderFile Cont) {
+ return 1 / Cont.method(); // no-warning
+}
diff --git a/test/Analysis/unified-sources/source2.cpp b/test/Analysis/unified-sources/source2.cpp
new file mode 100644
index 0000000000000..cd85e3522343f
--- /dev/null
+++ b/test/Analysis/unified-sources/source2.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_analyze_cc1 -analyzer-checker=core -verify %s
+
+// This test tests that the warning is here when it is included from
+// the unified sources file. The run-line in this file is there
+// only to suppress LIT warning for the complete lack of run-line.
+int testNullDereference() {
+ int *x = 0;
+ return *x; // expected-warning{{}}
+}
+
+// Let's see if the container inlining heuristic still works.
+class ContainerInCodeFile {
+ class Iterator {
+ };
+
+public:
+ Iterator begin() const;
+ Iterator end() const;
+
+ int method() { return 0; }
+};
+
+int testContainerMethodInCodeFile(ContainerInCodeFile Cont) {
+ return 1 / Cont.method(); // expected-warning{{}}
+}