[clang] Handle __declspec() attributes in using
[llvm-project.git] / clang / test / Analysis / cast-value-state-dump.cpp
blob07fd7abd848ab79a05d1fd23eb04944dbf32bf2a
1 // RUN: %clang_analyze_cc1 -std=c++14 \
2 // RUN: -analyzer-checker=core,apiModeling.llvm.CastValue,debug.ExprInspection\
3 // RUN: -analyzer-output=text -verify %s 2>&1 | FileCheck %s
5 #include "Inputs/llvm.h"
7 void clang_analyzer_printState();
9 namespace clang {
10 struct Shape {};
11 class Triangle : public Shape {};
12 class Circle : public Shape {};
13 class Square : public Shape {};
14 } // namespace clang
16 using namespace llvm;
17 using namespace clang;
19 void evalNonNullParamNonNullReturn(const Shape *S) {
20 const auto *C = dyn_cast_or_null<Circle>(S);
21 // expected-note@-1 {{Assuming 'S' is a 'const class clang::Circle *'}}
22 // expected-note@-2 {{'C' initialized here}}
24 // FIXME: We assumed that 'S' is a 'Circle' therefore it is not a 'Square'.
25 if (dyn_cast_or_null<Square>(S)) {
26 // expected-note@-1 {{Assuming 'S' is not a 'const class clang::Square *'}}
27 // expected-note@-2 {{Taking false branch}}
28 return;
31 clang_analyzer_printState();
33 // CHECK: "dynamic_types": [
34 // CHECK-NEXT: { "region": "SymRegion{reg_$0<const Shape * S>}", "dyn_type": "const class clang::Circle", "sub_classable": true }
35 // CHECK-NEXT: ],
36 // CHECK-NEXT: "dynamic_casts": [
37 // CHECK: { "region": "SymRegion{reg_$0<const Shape * S>}", "casts": [
38 // CHECK-NEXT: { "from": "struct clang::Shape", "to": "class clang::Circle", "kind": "success" },
39 // CHECK-NEXT: { "from": "struct clang::Shape", "to": "class clang::Square", "kind": "fail" }
40 // CHECK-NEXT: ] }
42 (void)(1 / !C);
43 // expected-note@-1 {{'C' is non-null}}
44 // expected-note@-2 {{Division by zero}}
45 // expected-warning@-3 {{Division by zero}}