diff options
| author | Artem Dergachev <artem.dergachev@gmail.com> | 2019-08-23 03:23:58 +0000 |
|---|---|---|
| committer | Artem Dergachev <artem.dergachev@gmail.com> | 2019-08-23 03:23:58 +0000 |
| commit | af992e6d0137d798e6b2cd27737b7a73300676a1 (patch) | |
| tree | 95c2fd0aacf444511dd93b265f87acafc1340f19 /clang/test/Analysis/cast-value-notes.cpp | |
| parent | 0900b77db27fdbc7cd16e6c778643a4db348d912 (diff) | |
| download | bcm5719-llvm-af992e6d0137d798e6b2cd27737b7a73300676a1.tar.gz bcm5719-llvm-af992e6d0137d798e6b2cd27737b7a73300676a1.zip | |
[analyzer] CastValueChecker: Avoid modeling casts between objects.
Our method only works correctly when casting a pointer to a pointer
or a reference to a reference.
Fixes a crash.
llvm-svn: 369727
Diffstat (limited to 'clang/test/Analysis/cast-value-notes.cpp')
| -rw-r--r-- | clang/test/Analysis/cast-value-notes.cpp | 11 |
1 files changed, 6 insertions, 5 deletions
diff --git a/clang/test/Analysis/cast-value-notes.cpp b/clang/test/Analysis/cast-value-notes.cpp index 6e7f6b01af7..f92ba90336a 100644 --- a/clang/test/Analysis/cast-value-notes.cpp +++ b/clang/test/Analysis/cast-value-notes.cpp @@ -27,9 +27,9 @@ void evalReferences(const Shape &S) { } void evalNonNullParamNonNullReturnReference(const Shape &S) { + // Unmodeled cast from reference to pointer. const auto *C = dyn_cast_or_null<Circle>(S); - // expected-note@-1 {{Assuming 'S' is a 'Circle'}} - // expected-note@-2 {{'C' initialized here}} + // expected-note@-1 {{'C' initialized here}} if (!dyn_cast_or_null<Circle>(C)) { // expected-note@-1 {{'C' is a 'Circle'}} @@ -132,10 +132,11 @@ void evalZeroParamNonNullReturn(const Shape &S) { // expected-warning@-3 {{Division by zero}} } -void evalZeroParamNullReturn(const Shape &S) { - const auto *C = S.getAs<Circle>(); +void evalZeroParamNullReturn(const Shape *S) { + const auto &C = S->getAs<Circle>(); // expected-note@-1 {{Assuming 'S' is not a 'Circle'}} - // expected-note@-2 {{'C' initialized to a null pointer value}} + // expected-note@-2 {{Storing null pointer value}} + // expected-note@-3 {{'C' initialized here}} if (!dyn_cast_or_null<Triangle>(S)) { // expected-note@-1 {{Assuming 'S' is a 'Triangle'}} |

