summaryrefslogtreecommitdiffstats
path: root/clang/test/Analysis/cast-value-notes.cpp
diff options
context:
space:
mode:
authorCsaba Dabis <dabis.csaba98@gmail.com>2019-08-22 02:57:59 +0000
committerCsaba Dabis <dabis.csaba98@gmail.com>2019-08-22 02:57:59 +0000
commit4d71600c113243b0f3eb04c2308f0eda60bfccaa (patch)
treea7020f89d567be6a998011f6200088b2d70865e9 /clang/test/Analysis/cast-value-notes.cpp
parent12002fbd211d3197a2ccba63632937ee1e9212f4 (diff)
downloadbcm5719-llvm-4d71600c113243b0f3eb04c2308f0eda60bfccaa.tar.gz
bcm5719-llvm-4d71600c113243b0f3eb04c2308f0eda60bfccaa.zip
[analyzer] CastValueChecker: Model isa(), isa_and_nonnull()
Summary: - Reviewed By: NoQ Differential Revision: https://reviews.llvm.org/D66423 llvm-svn: 369615
Diffstat (limited to 'clang/test/Analysis/cast-value-notes.cpp')
-rw-r--r--clang/test/Analysis/cast-value-notes.cpp25
1 files changed, 18 insertions, 7 deletions
diff --git a/clang/test/Analysis/cast-value-notes.cpp b/clang/test/Analysis/cast-value-notes.cpp
index 77801d69935..6e7f6b01af7 100644
--- a/clang/test/Analysis/cast-value-notes.cpp
+++ b/clang/test/Analysis/cast-value-notes.cpp
@@ -1,5 +1,5 @@
// RUN: %clang_analyze_cc1 \
-// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue \
+// RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
// RUN: -analyzer-output=text -verify %s
#include "Inputs/llvm.h"
@@ -43,16 +43,21 @@ void evalNonNullParamNonNullReturnReference(const Shape &S) {
return;
}
- if (dyn_cast_or_null<Triangle>(C)) {
+ if (isa<Triangle>(C)) {
// expected-note@-1 {{'C' is not a 'Triangle'}}
// expected-note@-2 {{Taking false branch}}
return;
}
- (void)(1 / !C);
- // expected-note@-1 {{'C' is non-null}}
- // expected-note@-2 {{Division by zero}}
- // expected-warning@-3 {{Division by zero}}
+ if (isa<Circle>(C)) {
+ // expected-note@-1 {{'C' is a 'Circle'}}
+ // expected-note@-2 {{Taking true branch}}
+
+ (void)(1 / !C);
+ // expected-note@-1 {{'C' is non-null}}
+ // expected-note@-2 {{Division by zero}}
+ // expected-warning@-3 {{Division by zero}}
+ }
}
void evalNonNullParamNonNullReturn(const Shape *S) {
@@ -60,7 +65,13 @@ void evalNonNullParamNonNullReturn(const Shape *S) {
// expected-note@-1 {{'S' is a 'Circle'}}
// expected-note@-2 {{'C' initialized here}}
- if (!cast<Triangle>(C)) {
+ if (!isa<Triangle>(C)) {
+ // expected-note@-1 {{Assuming 'C' is a 'Triangle'}}
+ // expected-note@-2 {{Taking false branch}}
+ return;
+ }
+
+ if (!isa<Triangle>(C)) {
// expected-note@-1 {{'C' is a 'Triangle'}}
// expected-note@-2 {{Taking false branch}}
return;
OpenPOWER on IntegriCloud