brintos

brintos / llvm-project-archived public Read only

0
0
Text · 3.4 KiB · 58f31ac Raw
101 lines · cpp
1// RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-filter Test %s | FileCheck -check-prefix DECLS %s2// RUN: %clang_cc1 -std=c++11 -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix LOOKUPS %s3// RUN: %clang_cc1 -std=c++11 -ast-dump -ast-dump-lookups -ast-dump-filter Test %s | FileCheck -check-prefix DECLS-LOOKUPS %s4// RUN: %clang_cc1 -std=c++11 -DPRAGMA -fsyntax-only -verify %s 2>&1 | FileCheck -check-prefix PRAGMA %s5 6namespace Test {7  typedef int T;8  extern int a;9  int a = 0;10}11 12#ifdef PRAGMA13#pragma clang __debug dump Test14// PRAGMA: lookup results for Test:15// PRAGMA-NEXT: NamespaceDecl {{.*}} Test16// PRAGMA-NEXT: |-TypedefDecl {{.*}} T 'int'17// PRAGMA-NEXT: | `-BuiltinType {{.*}} 'int'18// PRAGMA-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern19// PRAGMA-NEXT: `-VarDecl {{.*}} prev [[EXTERN_A]] {{.*}} a 'int' cinit20// PRAGMA-NEXT:   `-IntegerLiteral {{.*}} 'int' 021#endif22 23namespace Test { }24 25// DECLS: Dumping Test:26// DECLS-NEXT: NamespaceDecl {{.*}} Test27// DECLS-NEXT: |-TypedefDecl {{.*}} T 'int'28// DECLS-NEXT: | `-BuiltinType {{.*}} 'int'29// DECLS-NEXT: |-VarDecl [[EXTERN_A:0x[^ ]*]] {{.*}} a 'int' extern30// DECLS-NEXT: `-VarDecl {{.*}} prev [[EXTERN_A]] {{.*}} a 'int' cinit31// DECLS-NEXT:   `-IntegerLiteral {{.*}} 'int' 032//33// DECLS: Dumping Test:34// DECLS-NEXT: NamespaceDecl {{.*}} Test35 36// LOOKUPS: Dumping Test:37// LOOKUPS-NEXT: StoredDeclsMap Namespace {{.*}} 'Test'38// LOOKUPS:      DeclarationName 'a'39// LOOKUPS-NEXT: `-Var {{.*}} 'a' 'int'40//41// LOOKUPS: Dumping Test:42// LOOKUPS-NEXT: Lookup map is in primary DeclContext43 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' extern49// DECLS-LOOKUPS-NEXT:     `-VarDecl [[A]] prev [[EXTERN_A]] {{.*}} a 'int' cinit50// DECLS-LOOKUPS-NEXT:       `-IntegerLiteral {{.*}} 'int' 051//52// DECLS-LOOKUPS: Dumping Test:53// DECLS-LOOKUPS-NEXT: Lookup map is in primary DeclContext54 55#ifdef PRAGMA56namespace Test {57  struct S {58    const S& operator+(const S&) { return *this; }59  };60  void foo(S) {}61}62 63#pragma clang __debug dump foo(Test::S{})64// PRAGMA: CallExpr {{.*}} adl65// PRAGMA-NEXT: |-ImplicitCastExpr {{.*}}66// PRAGMA-NEXT: | `-DeclRefExpr {{.*}} 'void (S)' lvalue Function {{.*}} 'foo' 'void (S)'67 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 &)'72 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 &)'76 77template<typename T, int I>78void bar() {79#pragma clang __debug dump T{} // expected-warning {{type-dependent expression}}80#pragma clang __debug dump +I  // expected-warning {{value-dependent expression}}81}82 83template <typename T>84struct S {85  static constexpr const T *str = "string";86};87 88template <>89struct S<wchar_t> {90  static constexpr const wchar_t *str = L"wide string";91};92 93void func() {94  #pragma clang __debug dump S<wchar_t>::str;95  // PRAGMA: DeclRefExpr {{.*}} 'const wchar_t *const' lvalue Var {{.*}} 'str' 'const wchar_t *const'96}97 98#pragma clang __debug dump this is nonsense // expected-error {{invalid use of 'this'}}99 100#endif101