[RISCV][FMV] Support target_clones (#85786)
[llvm-project.git] / clang / test / Analysis / eval-predefined-exprs.cpp
blobb26091869cd03f664b08d9dbb2c818db47d24700
1 // RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify %s
2 //
3 // RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify \
4 // RUN: -triple i386-pc-win32 -fms-compatibility -fms-extensions -DANALYZER_MS %s
6 template <typename T>
7 void clang_analyzer_dump(const T *);
8 void clang_analyzer_warnIfReached();
10 template <typename T, auto Value, typename U>
11 void func(U param) {
12 clang_analyzer_dump(__func__);
13 clang_analyzer_dump(__FUNCTION__);
14 clang_analyzer_dump(__PRETTY_FUNCTION__);
15 // expected-warning@-3 {{&Element{"func",0 S64b,char}}}
16 // expected-warning@-3 {{&Element{"func",0 S64b,char}}}
17 // expected-warning@-3 {{&Element{"void func(U) [T = Class, Value = 42ULL, U = char]",0 S64b,char}}}
19 #ifdef ANALYZER_MS
20 clang_analyzer_dump(__FUNCDNAME__);
21 clang_analyzer_dump(L__FUNCTION__);
22 clang_analyzer_dump(__FUNCSIG__);
23 clang_analyzer_dump(L__FUNCSIG__);
24 // expected-warning@-4 {{&Element{"??$func@UClass@?1??foo@@YAXXZ@$0CK@D@@YAXD@Z",0 S64b,char}}}
25 // expected-warning@-4 {{&Element{L"func",0 S64b,wchar_t}}}
26 // expected-warning@-4 {{&Element{"void __cdecl func(U) [T = Class, Value = 42ULL, U = char]",0 S64b,char}}}
27 // expected-warning@-4 {{&Element{L"void __cdecl func(U) [T = Class, Value = 42ULL, U = char]",0 S64b,wchar_t}}}
28 #endif
31 void foo() {
32 clang_analyzer_dump(__func__);
33 clang_analyzer_dump(__FUNCTION__);
34 clang_analyzer_dump(__PRETTY_FUNCTION__);
35 // expected-warning@-3 {{&Element{"foo",0 S64b,char}}}
36 // expected-warning@-3 {{&Element{"foo",0 S64b,char}}}
37 // expected-warning@-3 {{&Element{"void foo()",0 S64b,char}}}
39 #ifdef ANALYZER_MS
40 clang_analyzer_dump(__FUNCDNAME__);
41 clang_analyzer_dump(L__FUNCTION__);
42 clang_analyzer_dump(__FUNCSIG__);
43 clang_analyzer_dump(L__FUNCSIG__);
44 // expected-warning@-4 {{&Element{"?foo@@YAXXZ",0 S64b,char}}}
45 // expected-warning@-4 {{&Element{L"foo",0 S64b,wchar_t}}}
46 // expected-warning@-4 {{&Element{"void __cdecl foo(void)",0 S64b,char}}}
47 // expected-warning@-4 {{&Element{L"void __cdecl foo(void)",0 S64b,wchar_t}}}
48 #endif
50 func<struct Class, 42ull>('b'); // instantiate template
53 struct A {
54 A() {
55 clang_analyzer_dump(__func__); // expected-warning {{&Element{"A",0 S64b,char}}}
56 #ifdef ANALYZER_MS
57 clang_analyzer_dump(__FUNCTION__); // expected-warning {{&Element{"A::A",0 S64b,char}}}
58 #else
59 clang_analyzer_dump(__FUNCTION__); // expected-warning {{&Element{"A",0 S64b,char}}}
60 #endif
61 clang_analyzer_dump(__PRETTY_FUNCTION__); // expected-warning {{&Element{"A::A()",0 S64b,char}}}
63 #ifdef ANALYZER_MS
64 clang_analyzer_dump(__FUNCDNAME__);
65 clang_analyzer_dump(L__FUNCTION__);
66 clang_analyzer_dump(__FUNCSIG__);
67 clang_analyzer_dump(L__FUNCSIG__);
68 // expected-warning@-4 {{&Element{"??0A@@QAE@XZ",0 S64b,char}}}
69 // expected-warning@-4 {{&Element{L"A",0 S64b,wchar_t}}}
70 // expected-warning@-4 {{&Element{"__thiscall A::A(void)",0 S64b,char}}}
71 // expected-warning@-4 {{&Element{L"__thiscall A::A(void)",0 S64b,wchar_t}}}
72 #endif
74 ~A() {
75 clang_analyzer_dump(__func__); // expected-warning {{&Element{"~A",0 S64b,char}}}
76 #ifdef ANALYZER_MS
77 clang_analyzer_dump(__FUNCTION__); // expected-warning {{&Element{"A::~A",0 S64b,char}}}
78 #else
79 clang_analyzer_dump(__FUNCTION__); // expected-warning {{&Element{"~A",0 S64b,char}}}
80 #endif
81 clang_analyzer_dump(__PRETTY_FUNCTION__); // expected-warning {{&Element{"A::~A()",0 S64b,char}}}
83 #ifdef ANALYZER_MS
84 clang_analyzer_dump(__FUNCDNAME__);
85 clang_analyzer_dump(L__FUNCTION__);
86 clang_analyzer_dump(__FUNCSIG__);
87 clang_analyzer_dump(L__FUNCSIG__);
88 // expected-warning@-4 {{&Element{"??1A@@QAE@XZ",0 S64b,char}}}
89 // expected-warning@-4 {{&Element{L"~A",0 S64b,wchar_t}}}
90 // expected-warning@-4 {{&Element{"__thiscall A::~A(void)",0 S64b,char}}}
91 // expected-warning@-4 {{&Element{L"__thiscall A::~A(void)",0 S64b,wchar_t}}}
92 #endif
95 template <typename> int dependent() {
96 // We should not analyze dependent functions.
97 // Such functions have no function name of predefined expressions such as: '__func__' etc.
98 clang_analyzer_warnIfReached(); // no-warning