[flang][cuda] Adapt ExternalNameConversion to work in gpu module (#117039)
[llvm-project.git] / clang / test / AST / ast-dump-lookups.cpp
blob58f31ac4a3a6dfa7837d9c97e6d7fe01b303c41d
1 // RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix DECLS %s
2 // RUN: %clang_cc1 -std=c++11 -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix LOOKUPS %s
3 // RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix DECLS-LOOKUPS %s
4 // RUN: %clang_cc1 -std=c++11 -DPRAGMA -fsyntax-only -verify %s 2>&1 | FileCheck -check-prefix PRAGMA %s
6 namespace Test {
7 typedef int T;
8 extern int a;
9 int a = 0;
12 #ifdef PRAGMA
13 #pragma clang __debug dump Test
14 // PRAGMA: lookup results for Test:
15 // PRAGMA-NEXT: NamespaceDecl {{.*}} Test
16 // PRAGMA-NEXT: |-TypedefDecl {{.*}} T 'int'
17 // PRAGMA-NEXT: | `-BuiltinType {{.*}} 'int'
18 // PRAGMA-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern
19 // PRAGMA-NEXT: `-VarDecl {{.*}} prev [[EXTERN_A]] {{.*}} a 'int' cinit
20 // PRAGMA-NEXT: `-IntegerLiteral {{.*}} 'int' 0
21 #endif
23 namespace Test { }
25 // DECLS: Dumping Test:
26 // DECLS-NEXT: NamespaceDecl {{.*}} Test
27 // DECLS-NEXT: |-TypedefDecl {{.*}} T 'int'
28 // DECLS-NEXT: | `-BuiltinType {{.*}} 'int'
29 // DECLS-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern
30 // DECLS-NEXT: `-VarDecl {{.*}} prev [[EXTERN_A]] {{.*}} a 'int' cinit
31 // DECLS-NEXT: `-IntegerLiteral {{.*}} 'int' 0
33 // DECLS: Dumping Test:
34 // DECLS-NEXT: NamespaceDecl {{.*}} Test
36 // LOOKUPS: Dumping Test:
37 // LOOKUPS-NEXT: StoredDeclsMap Namespace {{.*}} 'Test'
38 // LOOKUPS: DeclarationName 'a'
39 // LOOKUPS-NEXT: `-Var {{.*}} 'a' 'int'
41 // LOOKUPS: Dumping Test:
42 // LOOKUPS-NEXT: Lookup map is in primary DeclContext
44 // DECLS-LOOKUPS: Dumping Test:
45 // DECLS-LOOKUPS-NEXT: StoredDeclsMap Namespace {{.*}} 'Test'
46 // DECLS-LOOKUPS: -DeclarationName 'a'
47 // DECLS-LOOKUPS-NEXT: `-Var [[A:[^ ]*]] 'a' 'int'
48 // DECLS-LOOKUPS-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern
49 // DECLS-LOOKUPS-NEXT: `-VarDecl [[A]] prev [[EXTERN_A]] {{.*}} a 'int' cinit
50 // DECLS-LOOKUPS-NEXT: `-IntegerLiteral {{.*}} 'int' 0
52 // DECLS-LOOKUPS: Dumping Test:
53 // DECLS-LOOKUPS-NEXT: Lookup map is in primary DeclContext
55 #ifdef PRAGMA
56 namespace Test {
57 struct S {
58 const S& operator+(const S&) { return *this; }
60 void foo(S) {}
63 #pragma clang __debug dump foo(Test::S{})
64 // PRAGMA: CallExpr {{.*}} adl
65 // PRAGMA-NEXT: |-ImplicitCastExpr {{.*}}
66 // PRAGMA-NEXT: | `-DeclRefExpr {{.*}} 'void (S)' lvalue Function {{.*}} 'foo' 'void (S)'
68 #pragma clang __debug dump Test::S{} + Test::S{}
69 // PRAGMA: CXXOperatorCallExpr {{.*}}
70 // PRAGMA-NEXT: |-ImplicitCastExpr {{.*}}
71 // PRAGMA-NEXT: | `-DeclRefExpr {{.*}} 'const S &(const S &)' lvalue CXXMethod {{.*}} 'operator+' 'const S &(const S &)'
73 #pragma clang __debug dump &Test::S::operator+
74 // PRAGMA: UnaryOperator {{.*}}
75 // PRAGMA-NEXT: `-DeclRefExpr {{.*}} 'const S &(const S &)' CXXMethod {{.*}} 'operator+' 'const S &(const S &)'
77 template<typename T, int I>
78 void bar() {
79 #pragma clang __debug dump T{} // expected-warning {{type-dependent expression}}
80 #pragma clang __debug dump +I // expected-warning {{value-dependent expression}}
83 template <typename T>
84 struct S {
85 static constexpr const T *str = "string";
88 template <>
89 struct S<wchar_t> {
90 static constexpr const wchar_t *str = L"wide string";
93 void func() {
94 #pragma clang __debug dump S<wchar_t>::str;
95 // PRAGMA: DeclRefExpr {{.*}} 'const wchar_t *const' lvalue Var {{.*}} 'str' 'const wchar_t *const'
98 #pragma clang __debug dump this is nonsense // expected-error {{invalid use of 'this'}}
100 #endif