1 // RUN: %clang_analyze_cc1 -std=c++17 -analyzer-checker=core,debug.ExprInspection -verify %s
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
7 void clang_analyzer_dump(const T
*);
8 void clang_analyzer_warnIfReached();
10 template <typename T
, auto Value
, typename U
>
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}}}
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}}}
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}}}
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}}}
50 func
<struct Class
, 42ull>('b'); // instantiate template
55 clang_analyzer_dump(__func__
); // expected-warning {{&Element{"A",0 S64b,char}}}
57 clang_analyzer_dump(__FUNCTION__
); // expected-warning {{&Element{"A::A",0 S64b,char}}}
59 clang_analyzer_dump(__FUNCTION__
); // expected-warning {{&Element{"A",0 S64b,char}}}
61 clang_analyzer_dump(__PRETTY_FUNCTION__
); // expected-warning {{&Element{"A::A()",0 S64b,char}}}
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}}}
75 clang_analyzer_dump(__func__
); // expected-warning {{&Element{"~A",0 S64b,char}}}
77 clang_analyzer_dump(__FUNCTION__
); // expected-warning {{&Element{"A::~A",0 S64b,char}}}
79 clang_analyzer_dump(__FUNCTION__
); // expected-warning {{&Element{"~A",0 S64b,char}}}
81 clang_analyzer_dump(__PRETTY_FUNCTION__
); // expected-warning {{&Element{"A::~A()",0 S64b,char}}}
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}}}
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