diff options
| author | Yury Gribov <y.gribov@samsung.com> | 2016-01-11 09:38:48 +0000 |
|---|---|---|
| committer | Yury Gribov <y.gribov@samsung.com> | 2016-01-11 09:38:48 +0000 |
| commit | 054873b0be85583b0499d12fad58566ae5398e4e (patch) | |
| tree | 2ac1948344659d0dd4cf10cc645f1c6d8535cac3 | |
| parent | 7ceec0b82f11f8b785ca7a34a05c5e2a4e42ccb7 (diff) | |
| download | bcm5719-llvm-054873b0be85583b0499d12fad58566ae5398e4e.tar.gz bcm5719-llvm-054873b0be85583b0499d12fad58566ae5398e4e.zip | |
AnalysisConsumer: use canonical decl for both lookup and store of
visited decls.
Due to redeclarations, the function may have different declarations used
in CallExpr and in the definition. However, we need to use a unique
declaration for both store and lookup in VisitedCallees. This patch
fixes issues with analysis in topological order. A simple test is
included.
Patch by Alex Sidorin!
Differential Revision: http://reviews.llvm.org/D15410
llvm-svn: 257318
| -rw-r--r-- | clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp | 9 | ||||
| -rw-r--r-- | clang/test/Analysis/inlining/analysis-order.c | 15 |
2 files changed, 20 insertions, 4 deletions
diff --git a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp index bf85c4ca0c6..d1446855e01 100644 --- a/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp +++ b/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp @@ -496,10 +496,11 @@ void AnalysisConsumer::HandleDeclsCallGraph(const unsigned LocalTUDeclsSize) { (Mgr->options.InliningMode == All ? nullptr : &VisitedCallees)); // Add the visited callees to the global visited set. - for (SetOfConstDecls::iterator I = VisitedCallees.begin(), - E = VisitedCallees.end(); I != E; ++I) { - Visited.insert(*I); - } + for (const Decl *Callee : VisitedCallees) + // Decls from CallGraph are already canonical. But Decls coming from + // CallExprs may be not. We should canonicalize them manually. + Visited.insert(isa<ObjCMethodDecl>(Callee) ? Callee + : Callee->getCanonicalDecl()); VisitedAsTopLevel.insert(D); } } diff --git a/clang/test/Analysis/inlining/analysis-order.c b/clang/test/Analysis/inlining/analysis-order.c new file mode 100644 index 00000000000..5149818c74f --- /dev/null +++ b/clang/test/Analysis/inlining/analysis-order.c @@ -0,0 +1,15 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core.builtin.NoReturnFunctions -analyzer-display-progress %s 2>&1 | FileCheck %s + +// Do not analyze test1() again because it was inlined +void test1(); + +void test2() { + test1(); +} + +void test1() { +} + +// CHECK: analysis-order.c test2 +// CHECK-NEXT: analysis-order.c test1 +// CHECK-NEXT: analysis-order.c test2 |

