diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2016-11-30 18:26:43 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2016-11-30 18:26:43 +0000 |
| commit | 7b75e3266c868ea6f9fa0783944e0f43d5ced2a3 (patch) | |
| tree | 6b176f106f0e6c63c30cdb140727deeec7847fbc /clang/test | |
| parent | 4ae38347924cd685a1e0c5259ee7476d61484326 (diff) | |
| download | bcm5719-llvm-7b75e3266c868ea6f9fa0783944e0f43d5ced2a3.tar.gz bcm5719-llvm-7b75e3266c868ea6f9fa0783944e0f43d5ced2a3.zip | |
[analyzer] SValExplainer: Support ObjC ivars and __block variables.
Additionally, explain the difference between normal and heap-based
symbolic regions.
llvm-svn: 288260
Diffstat (limited to 'clang/test')
| -rw-r--r-- | clang/test/Analysis/explain-svals.cpp | 2 | ||||
| -rw-r--r-- | clang/test/Analysis/explain-svals.m | 27 |
2 files changed, 28 insertions, 1 deletions
diff --git a/clang/test/Analysis/explain-svals.cpp b/clang/test/Analysis/explain-svals.cpp index c0ed74914ed..ef2ebc244a6 100644 --- a/clang/test/Analysis/explain-svals.cpp +++ b/clang/test/Analysis/explain-svals.cpp @@ -47,7 +47,7 @@ void test_2(char *ptr, int ext) { clang_analyzer_explain(glob_ptr); // expected-warning-re{{{{^value derived from \(symbol of type 'int' conjured at statement 'conjure\(\)'\) for global variable 'glob_ptr'$}}}} clang_analyzer_explain(clang_analyzer_getExtent(ptr)); // expected-warning-re{{{{^extent of pointee of argument 'ptr'$}}}} int *x = new int[ext]; - clang_analyzer_explain(x); // expected-warning-re{{{{^pointer to element of type 'int' with index 0 of pointee of symbol of type 'int \*' conjured at statement 'new int \[ext\]'$}}}} + clang_analyzer_explain(x); // expected-warning-re{{{{^pointer to element of type 'int' with index 0 of heap segment that starts at symbol of type 'int \*' conjured at statement 'new int \[ext\]'$}}}} // Sic! What gets computed is the extent of the element-region. clang_analyzer_explain(clang_analyzer_getExtent(x)); // expected-warning-re{{{{^signed 32-bit integer '4'$}}}} delete[] x; diff --git a/clang/test/Analysis/explain-svals.m b/clang/test/Analysis/explain-svals.m new file mode 100644 index 00000000000..34cdacfa282 --- /dev/null +++ b/clang/test/Analysis/explain-svals.m @@ -0,0 +1,27 @@ +// RUN: %clang_cc1 -w -triple i386-apple-darwin10 -fblocks -analyze -analyzer-checker=core.builtin,debug.ExprInspection -verify %s + +#include "Inputs/system-header-simulator-objc.h" + +void clang_analyzer_explain(void *); + +@interface Object : NSObject { +@public + Object *x; +} +@end + +void test_1(Object *p) { + clang_analyzer_explain(p); // expected-warning-re{{{{^argument 'p'$}}}} + clang_analyzer_explain(p->x); // expected-warning-re{{{{^initial value of instance variable 'x' of object at argument 'p'$}}}} + Object *q = [[Object alloc] init]; + clang_analyzer_explain(q); // expected-warning-re{{{{^symbol of type 'Object \*' conjured at statement '\[\[Object alloc\] init\]'$}}}} + clang_analyzer_explain(q->x); // expected-warning-re{{{{^initial value of instance variable 'x' of object at symbol of type 'Object \*' conjured at statement '\[\[Object alloc\] init\]'$}}}} +} + +void test_2() { + __block int x; + ^{ + clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}} + }; + clang_analyzer_explain(&x); // expected-warning-re{{{{^pointer to block variable 'x'$}}}} +} |

