|  | 
|  | 1 | +# REQUIRES: lld | 
|  | 2 | + | 
|  | 3 | +# Test that functions have the correct types. | 
|  | 4 | +# This uses the same input as SymbolFile/PDB/func-symbols.test. However, DIA  | 
|  | 5 | +# creates one named `Type` per function and uses identical UIDs for `Type` and | 
|  | 6 | +# `Function`, whereas native creates one unnamed type per signature and has different UIDs. | 
|  | 7 | + | 
|  | 8 | +# RUN: split-file %s %t | 
|  | 9 | +# RUN: %build --compiler=clang-cl --arch=32 --nodefaultlib -o %t.exe %t/main.cpp %t/second.cpp | 
|  | 10 | +# RUN: lldb-test symbols %t.exe | FileCheck --check-prefix=CHECK-ONE %s | 
|  | 11 | +# RUN: lldb-test symbols %t.exe | FileCheck --check-prefix=CHECK-TWO %s | 
|  | 12 | + | 
|  | 13 | +#--- main.cpp | 
|  | 14 | + | 
|  | 15 | +// Global functions | 
|  | 16 | +int Func_arg_array(int array[]) { return 1; } | 
|  | 17 | +void Func_arg_void(void) { return; } | 
|  | 18 | +void Func_arg_none(void) { return; } | 
|  | 19 | +void Func_varargs(...) { return; } | 
|  | 20 | + | 
|  | 21 | +// Class | 
|  | 22 | +namespace MemberTest { | 
|  | 23 | +  class A { | 
|  | 24 | +  public: | 
|  | 25 | +    int Func(int a, ...) { return 1; } | 
|  | 26 | +  }; | 
|  | 27 | +} | 
|  | 28 | + | 
|  | 29 | +// Template | 
|  | 30 | +template <int N=1, class ...T> | 
|  | 31 | +void TemplateFunc(T ...Arg) { | 
|  | 32 | +  return; | 
|  | 33 | +} | 
|  | 34 | + | 
|  | 35 | +// namespace | 
|  | 36 | +namespace { | 
|  | 37 | +  void Func(int a, const long b, volatile bool c, ...) { return; } | 
|  | 38 | +} | 
|  | 39 | + | 
|  | 40 | +namespace NS { | 
|  | 41 | +  void Func(char a, int b) { | 
|  | 42 | +    return; | 
|  | 43 | +  } | 
|  | 44 | +} | 
|  | 45 | + | 
|  | 46 | +// Static function | 
|  | 47 | +static long StaticFunction(int a) | 
|  | 48 | +{ | 
|  | 49 | +  return 2; | 
|  | 50 | +} | 
|  | 51 | + | 
|  | 52 | +// Inlined function | 
|  | 53 | +inline void InlinedFunction(long a) { return; } | 
|  | 54 | + | 
|  | 55 | +extern void FunctionCall(); | 
|  | 56 | + | 
|  | 57 | +int main() { | 
|  | 58 | +  MemberTest::A v1; | 
|  | 59 | +  v1.Func('a',10); | 
|  | 60 | + | 
|  | 61 | +  Func(1, 5, true, 10, 8); | 
|  | 62 | +  NS::Func('c', 2); | 
|  | 63 | + | 
|  | 64 | +  TemplateFunc(10); | 
|  | 65 | +  TemplateFunc(10,11,88); | 
|  | 66 | + | 
|  | 67 | +  StaticFunction(2); | 
|  | 68 | +  InlinedFunction(1); | 
|  | 69 | + | 
|  | 70 | +  FunctionCall(); | 
|  | 71 | +  return 0; | 
|  | 72 | +} | 
|  | 73 | + | 
|  | 74 | +#--- main-checks | 
|  | 75 | + | 
|  | 76 | +# CHECK-ONE: Module [[MD:.*]] | 
|  | 77 | +# CHECK-ONE-DAG: SymbolFile native-pdb ([[MD]]) | 
|  | 78 | +# CHECK-ONE-DAG: [[TY0:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} int (int *) | 
|  | 79 | +# CHECK-ONE-DAG: [[TY1:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (void) | 
|  | 80 | +# CHECK-ONE-DAG: [[TY2:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (...) | 
|  | 81 | +# CHECK-ONE-DAG: [[TY3:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (char, int) | 
|  | 82 | +# CHECK-ONE-DAG: [[TY4:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} int (void) | 
|  | 83 | +# CHECK-ONE-DAG: [[TY5:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (int, const long, volatile _Bool, ...) | 
|  | 84 | +# CHECK-ONE-DAG: [[TY6:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} long (int) | 
|  | 85 | +# CHECK-ONE-DAG: [[TY7:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} int (int, ...) | 
|  | 86 | +# CHECK-ONE-DAG: [[TY8:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (int) | 
|  | 87 | +# CHECK-ONE-DAG: [[TY9:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (int, int, int) | 
|  | 88 | +# CHECK-ONE-DAG: [[TY10:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (long) | 
|  | 89 | + | 
|  | 90 | +# CHECK-ONE: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}main.cpp' | 
|  | 91 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func_arg_array@@YAHQAH@Z, type = [[TY0]] | 
|  | 92 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func_arg_void@@YAXXZ, type = [[TY1]] | 
|  | 93 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func_arg_none@@YAXXZ, type = [[TY1]] | 
|  | 94 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func_varargs@@YAXZZ, type = [[TY2]] | 
|  | 95 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func@NS@@YAXDH@Z, type = [[TY3]] | 
|  | 96 | +# CHECK-ONE-DAG: Function{{.*}}, demangled = main, type = [[TY4]] | 
|  | 97 | +# CHECK-ONE-DAG: Function{{.*}}, demangled = {{.*}}`anonymous namespace'::Func{{.*}}, type = [[TY5]] | 
|  | 98 | +# CHECK-ONE-DAG: Function{{.*}}, demangled = {{.*}}StaticFunction{{.*}}, type = [[TY6]] | 
|  | 99 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?Func@A@MemberTest@@QAAHHZZ, type = [[TY7]] | 
|  | 100 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ??$TemplateFunc@$00H@@YAXH@Z, type = [[TY8]] | 
|  | 101 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ??$TemplateFunc@$00HHH@@YAXHHH@Z, type = [[TY9]] | 
|  | 102 | +# CHECK-ONE-DAG: Function{{.*}}, mangled = ?InlinedFunction@@YAXJ@Z, type = [[TY10]] | 
|  | 103 | + | 
|  | 104 | +#--- second.cpp | 
|  | 105 | + | 
|  | 106 | +// Static function | 
|  | 107 | +namespace { | 
|  | 108 | +static long StaticFunction(int a) | 
|  | 109 | +{ | 
|  | 110 | +  return 2; | 
|  | 111 | +} | 
|  | 112 | +} | 
|  | 113 | + | 
|  | 114 | +// Inlined function | 
|  | 115 | +static inline int InlinedFunction(long a) { return 10; } | 
|  | 116 | + | 
|  | 117 | +void FunctionCall() | 
|  | 118 | +{ | 
|  | 119 | +  StaticFunction(1); | 
|  | 120 | +  InlinedFunction(1); | 
|  | 121 | +} | 
|  | 122 | + | 
|  | 123 | +#--- second-checks | 
|  | 124 | + | 
|  | 125 | +# We expect new types observed in another compile unit | 
|  | 126 | +# CHECK-TWO-DAG: [[TY1:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} void (void) | 
|  | 127 | +# CHECK-TWO-DAG: [[TY2:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} long (int) | 
|  | 128 | +# CHECK-TWO-DAG: [[TY3:.*]]:   Type{{.*}} , size = 0, compiler_type = {{.*}} int (long) | 
|  | 129 | + | 
|  | 130 | +# CHECK-TWO: {{.*}}:   CompileUnit{{.*}}, language = "c++", file = '{{.*}}second.cpp' | 
|  | 131 | +# CHECK-TWO-DAG: Function{{.*}}, mangled = ?FunctionCall@@YAXXZ, type = [[TY1]] | 
|  | 132 | +# CHECK-TWO-DAG: Function{{.*}}, demangled = {{.*}}`anonymous namespace'::StaticFunction{{.*}}, type = [[TY2]] | 
|  | 133 | +# CHECK-TWO-DAG: Function{{.*}}, demangled = {{.*}}InlinedFunction{{.*}}, type = [[TY3]] | 
0 commit comments