reference, declarationdefinition
definition → references, declarations, derived classes, virtual overrides
reference to multiple definitions → definitions
unreferenced
    1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69
   70
   71
   72
   73
   74
   75
   76
   77
   78
   79
   80
   81
   82
   83
   84
   85
   86
   87
   88
   89
   90
   91
   92
   93
   94
   95
   96
   97
   98
   99
  100
  101
  102
  103
  104
  105
  106
  107
  108
  109
  110
  111
  112
  113
  114
  115
  116
  117
  118
  119
  120
  121
  122
  123
  124
  125
  126
  127
  128
  129
  130
  131
  132
  133
  134
  135
  136
  137
  138
  139
  140
  141
  142
  143
  144
  145
  146
  147
  148
  149
  150
  151
  152
  153
// clang-format off
// REQUIRES: lld

// Test various interesting cases for AST reconstruction.
// RUN: %build --compiler=clang-cl --nodefaultlib -o %t.exe -- %s 
// RUN: env LLDB_USE_NATIVE_PDB_READER=1 %lldb -f %t.exe -s \
// RUN:     %p/Inputs/nested-types.lldbinit 2>&1 | FileCheck %s

struct S {
  struct NestedStruct {
    int A = 0;
    int B = 1;
  };

  enum class NestedEnum {
    EnumValue1 = 0,
    EnumValue2 = 1,
  };
  int C = 2;
  int D = 3;
  using VoidPtrT = void *;
  VoidPtrT DD = nullptr;
};
struct T {
  using NestedTypedef = int;
  using NestedTypedef2 = S;

  struct NestedStruct {
    int E = 4;
    int F = 5;
  };

  using NestedStructAlias = NestedStruct;
  using NST = S::NestedStruct;

  NestedTypedef NT = 4;

  using U = struct {
    int G = 6;
    int H = 7;
  };
};

template<typename Param>
class U {
public:
  // See llvm.org/pr39607.  clang-cl currently doesn't emit an important debug
  // info record for nested template instantiations, so we can't reconstruct
  // a proper DeclContext hierarchy for these.  As such, U<X>::V<Y> will show up
  // in the global namespace.
  template<typename Param>
  struct V {
    Param I = 8;
    Param J = 9;

    using W = T::NestedTypedef;
    using X = U<int>;
  };

  struct W {
    Param M = 12;
    Param N = 13;
  };
  Param K = 10;
  Param L = 11;
  using Y = V<int>;
  using Z = V<T>;
};

constexpr S GlobalA;
constexpr S::NestedStruct GlobalB;
constexpr T GlobalC;
constexpr T::NestedStruct GlobalD;
constexpr T::U GlobalE;
constexpr U<int> GlobalF;
constexpr U<int>::V<int> GlobalG;
constexpr U<int>::W GlobalH;
constexpr S::NestedEnum GlobalEnum = S::NestedEnum::EnumValue1;


int main(int argc, char **argv) {
  return 0;
}



// CHECK: (lldb) target variable -T GlobalA
// CHECK: (const S) GlobalA = {
// CHECK:   (int) C = 2
// CHECK:   (int) D = 3
// CHECK:   (void *) DD = 0x00000000
// CHECK: }
// CHECK: (lldb) target variable -T GlobalB
// CHECK: (const S::NestedStruct) GlobalB = {
// CHECK:   (int) A = 0
// CHECK:   (int) B = 1
// CHECK: }
// CHECK: (lldb) target variable -T GlobalC
// CHECK: (const T) GlobalC = {
// CHECK:   (int) NT = 4
// CHECK: }
// CHECK: (lldb) target variable -T GlobalD
// CHECK: (const T::NestedStruct) GlobalD = {
// CHECK:   (int) E = 4
// CHECK:   (int) F = 5
// CHECK: }
// CHECK: (lldb) target variable -T GlobalE
// CHECK: (const T::U) GlobalE = {
// CHECK:   (int) G = 6
// CHECK:   (int) H = 7
// CHECK: }
// CHECK: (lldb) target variable -T GlobalF
// CHECK: (const U<int>) GlobalF = {
// CHECK:   (int) K = 10
// CHECK:   (int) L = 11
// CHECK: }
// CHECK: (lldb) target variable -T GlobalG
// CHECK: (const U<int>::V<int>) GlobalG = {
// CHECK:   (int) I = 8
// CHECK:   (int) J = 9
// CHECK: }
// CHECK: (lldb) target variable -T GlobalEnum
// CHECK: (const S::NestedEnum) GlobalEnum = EnumValue1
// CHECK: (lldb) target modules dump ast
// CHECK: Dumping clang ast for 1 modules.
// CHECK: TranslationUnitDecl {{.*}}
// CHECK: |-CXXRecordDecl {{.*}} struct S definition
// CHECK: | |-FieldDecl {{.*}} C 'int'
// CHECK: | |-FieldDecl {{.*}} D 'int'
// CHECK: | |-FieldDecl {{.*}} DD 'void *'
// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition
// CHECK: | | |-FieldDecl {{.*}} A 'int'
// CHECK: | | `-FieldDecl {{.*}} B 'int'
// CHECK: | `-EnumDecl {{.*}} NestedEnum
// CHECK: |   |-EnumConstantDecl {{.*}} EnumValue1 'S::NestedEnum'
// CHECK: |   `-EnumConstantDecl {{.*}} EnumValue2 'S::NestedEnum'
// CHECK: |-CXXRecordDecl {{.*}} struct T definition
// CHECK: | |-FieldDecl {{.*}} NT 'int'
// CHECK: | |-CXXRecordDecl {{.*}} struct NestedStruct definition
// CHECK: | | |-FieldDecl {{.*}} E 'int'
// CHECK: | | `-FieldDecl {{.*}} F 'int'
// CHECK: | `-CXXRecordDecl {{.*}} struct U definition
// CHECK: |   |-FieldDecl {{.*}} G 'int'
// CHECK: |   `-FieldDecl {{.*}} H 'int'
// CHECK: |-CXXRecordDecl {{.*}} class U<int> definition
// CHECK: | |-FieldDecl {{.*}} K 'int'
// CHECK: | |-FieldDecl {{.*}} L 'int'
// CHECK: | `-CXXRecordDecl {{.*}} struct W definition
// CHECK: |   |-FieldDecl {{.*}} M 'int'
// CHECK: |   `-FieldDecl {{.*}} N 'int'
// CHECK: |-CXXRecordDecl {{.*}} struct U<int>::V<int> definition
// CHECK: | |-FieldDecl {{.*}} I 'int'
// CHECK: | `-FieldDecl {{.*}} J 'int'