summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorJordan Rose <jordan_rose@apple.com>2012-07-09 16:54:49 +0000
committerJordan Rose <jordan_rose@apple.com>2012-07-09 16:54:49 +0000
commitee158bc29bc12ce544996f7cdfde14aba63acf4d (patch)
treea0f52607ceb2dcbee9a4bac68815f3894ee7d99b /test
parent6deae7cc8de2fb7578ed244d064cd34af744aac5 (diff)
downloadclang-ee158bc29bc12ce544996f7cdfde14aba63acf4d.tar.gz
[analyzer] When inlining, make sure we use the definition decl.
This was a regression introduced during the CallEvent changes; a call to FunctionDecl::hasBody was also being used to replace the decl found by lookup with the actual definition. To keep from making this mistake again (particularly if/when we start inlining Objective-C methods), this commit adds a "getDefinition()" method to CallEvent, which should do the right thing under any circumstances. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@159940 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Analysis/inline.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/test/Analysis/inline.c b/test/Analysis/inline.c
index 0827d93461..73d629a04a 100644
--- a/test/Analysis/inline.c
+++ b/test/Analysis/inline.c
@@ -1,4 +1,6 @@
-// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-store region -verify %s
+// RUN: %clang_cc1 -analyze -analyzer-checker=core,debug.ExprInspection -analyzer-ipa=inlining -analyzer-store region -verify %s
+
+void clang_analyzer_eval(int);
int test1_f1() {
int y = 1;
@@ -90,3 +92,14 @@ int test_rdar10977037() {
}
+// Test inlining a forward-declared function.
+// This regressed when CallEvent was first introduced.
+int plus1(int x);
+void test() {
+ clang_analyzer_eval(plus1(2) == 3); // expected-warning{{TRUE}}
+}
+
+int plus1(int x) {
+ return x + 1;
+}
+