diff options
author | Anna Zaks <ganna@apple.com> | 2012-04-12 22:36:48 +0000 |
---|---|---|
committer | Anna Zaks <ganna@apple.com> | 2012-04-12 22:36:48 +0000 |
commit | 6a86082f3a06a2dcceaaf63f78a0e52d64bcbaa3 (patch) | |
tree | cf41e29ac97fff116c78975aeecda1a68594e741 /test/Analysis | |
parent | 273ed9870aa064992fb3c25a1f4d8973b10ad36e (diff) |
[analyzer] PCH deserialization optimization.
We should not deserialize unused declarations from the PCH file. Achieve
this by storing the top level declarations during parsing
(HandleTopLevelDecl ASTConsumer callback) and analyzing/building a call
graph only for those.
Tested the patch on a sample ObjC file that uses PCH. With the patch,
the analyzes is 17.5% faster and clang consumes 40% less memory.
Got about 10% overall build/analyzes time decrease on a large Objective
C project.
A bit of CallGraph refactoring/cleanup as well..
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154625 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Analysis')
-rw-r--r-- | test/Analysis/check-deserialization.cpp | 20 | ||||
-rw-r--r-- | test/Analysis/objc-method-coverage.m | 17 |
2 files changed, 37 insertions, 0 deletions
diff --git a/test/Analysis/check-deserialization.cpp b/test/Analysis/check-deserialization.cpp new file mode 100644 index 0000000000..2b0bce2b9a --- /dev/null +++ b/test/Analysis/check-deserialization.cpp @@ -0,0 +1,20 @@ +// RUN: %clang_cc1 -emit-pch -o %t %s +// RUN: %clang_cc1 -error-on-deserialized-decl S1_method -include-pch %t -analyze -analyzer-checker=core %s +// RUN: %clang_cc1 -include-pch %t -analyze -analyzer-checker=core -verify %s + +#ifndef HEADER +#define HEADER +// Header. + +void S1_method(); // This should not be deserialized. + + +#else +// Using the header. + +int test() { + int x = 0; + return 5/x; //expected-warning {{Division by zero}} +} + +#endif diff --git a/test/Analysis/objc-method-coverage.m b/test/Analysis/objc-method-coverage.m new file mode 100644 index 0000000000..056aafe518 --- /dev/null +++ b/test/Analysis/objc-method-coverage.m @@ -0,0 +1,17 @@ +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=inlining -analyzer-stats -fblocks %s 2>&1 | FileCheck %s +// RUN: %clang_cc1 -analyze -analyzer-checker=core -analyzer-ipa=none -analyzer-stats -fblocks %s 2>&1 | FileCheck %s + +@interface I +int f() { + return 0; +} +@end + +@implementation I ++ (void *)ff{ + return (void*)0; +} +@end + +// CHECK: ... Statistics Collected ... +// CHECK: 2 AnalysisConsumer - The # of functions analysed (as top level).
\ No newline at end of file |