Home | History | Annotate | Download | only in CodeGenCXX
      1 // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=i386-pc-win32 | FileCheck %s
      2 // RUN: %clang_cc1 -fblocks -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 | FileCheck -check-prefix X64 %s
      3 
      4 // CHECK: @"\01?a@@3HA"
      5 // CHECK: @"\01?b@N@@3HA"
      6 // CHECK: @"\01?anonymous@?A@N@@3HA"
      7 // CHECK: @c
      8 // CHECK: @"\01?d@foo@@0FB"
      9 // CHECK: @"\01?e@foo@@1JC"
     10 // CHECK: @"\01?f@foo@@2DD"
     11 // CHECK: @"\01?g@bar@@2HA"
     12 // CHECK: @"\01?h1@@3QAHA"
     13 // CHECK: @"\01?h2@@3QBHB"
     14 // CHECK: @"\01?i@@3PAY0BE@HA"
     15 // CHECK: @"\01?j@@3P6GHCE@ZA"
     16 // CHECK: @"\01?k@@3PTfoo@@DQ1@"
     17 // CHECK: @"\01?l@@3P8foo@@AEHH@ZQ1@"
     18 // CHECK: @"\01?color1@@3PANA"
     19 // CHECK: @"\01?color2@@3QBNB"
     20 // CHECK: @"\01?color3@@3QAY02$$CBNA"
     21 // CHECK: @"\01?color4@@3QAY02$$CBNA"
     22 
     23 int a;
     24 
     25 namespace N {
     26   int b;
     27 
     28   namespace {
     29     int anonymous;
     30   }
     31 }
     32 
     33 static int c;
     34 int _c(void) {return N::anonymous + c;}
     35 // CHECK: @"\01?_c@@YAHXZ"
     36 // X64: @"\01?_c@@YAHXZ"
     37 
     38 class foo {
     39   static const short d;
     40 protected:
     41   static volatile long e;
     42 public:
     43   static const volatile char f;
     44   int operator+(int a);
     45   foo(){}
     46 //CHECK: @"\01??0foo@@QAE@XZ"
     47 //X64: @"\01??0foo@@QEAA@XZ"
     48 
     49   ~foo(){}
     50 //CHECK: @"\01??1foo@@QAE@XZ"
     51 //X64: @"\01??1foo@@QEAA@XZ
     52 
     53   foo(int i){}
     54 //CHECK: @"\01??0foo@@QAE@H@Z"
     55 //X64: @"\01??0foo@@QEAA@H@Z"
     56 
     57   foo(char *q){}
     58 //CHECK: @"\01??0foo@@QAE@PAD@Z"
     59 //X64: @"\01??0foo@@QEAA@PEAD@Z"
     60 
     61   static foo* static_method() { return 0; }
     62 
     63 }f,s1(1),s2((char*)0);
     64 
     65 typedef foo (foo2);
     66 
     67 struct bar {
     68   static int g;
     69 };
     70 
     71 union baz {
     72   int a;
     73   char b;
     74   double c;
     75 };
     76 
     77 enum quux {
     78   qone,
     79   qtwo,
     80   qthree
     81 };
     82 
     83 foo bar() { return foo(); }
     84 //CHECK: @"\01?bar@@YA?AVfoo@@XZ"
     85 //X64: @"\01?bar@@YA?AVfoo@@XZ"
     86 
     87 int foo::operator+(int a) {
     88 //CHECK: @"\01??Hfoo@@QAEHH@Z"
     89 //X64: @"\01??Hfoo@@QEAAHH@Z"
     90 
     91   foo::static_method();
     92 //CHECK: @"\01?static_method@foo@@SAPAV1@XZ"
     93 //X64: @"\01?static_method@foo@@SAPEAV1@XZ"
     94   bar();
     95   return a;
     96 }
     97 
     98 const short foo::d = 0;
     99 volatile long foo::e;
    100 const volatile char foo::f = 'C';
    101 
    102 int bar::g;
    103 
    104 extern int * const h1 = &a;
    105 extern const int * const h2 = &a;
    106 
    107 int i[10][20];
    108 
    109 int (__stdcall *j)(signed char, unsigned char);
    110 
    111 const volatile char foo2::*k;
    112 
    113 int (foo2::*l)(int);
    114 
    115 // Static functions are mangled, too.
    116 // Also make sure calling conventions, arglists, and throw specs work.
    117 static void __stdcall alpha(float a, double b) throw() {}
    118 bool __fastcall beta(long long a, wchar_t b) throw(signed char, unsigned char) {
    119 // CHECK: @"\01?beta@@YI_N_J_W@Z"
    120 // X64: @"\01?beta@@YA_N_J_W@Z"
    121   alpha(0.f, 0.0);
    122   return false;
    123 }
    124 
    125 // CHECK: @"\01?alpha@@YGXMN@Z"
    126 // X64: @"\01?alpha@@YAXMN@Z"
    127 
    128 // Make sure tag-type mangling works.
    129 void gamma(class foo, struct bar, union baz, enum quux) {}
    130 // CHECK: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
    131 // X64: @"\01?gamma@@YAXVfoo@@Ubar@@Tbaz@@W4quux@@@Z"
    132 
    133 // Make sure pointer/reference-type mangling works.
    134 void delta(int * const a, const long &) {}
    135 // CHECK: @"\01?delta@@YAXQAHABJ@Z"
    136 // X64: @"\01?delta@@YAXQEAHAEBJ@Z"
    137 
    138 // Array mangling.
    139 void epsilon(int a[][10][20]) {}
    140 // CHECK: @"\01?epsilon@@YAXQAY19BE@H@Z"
    141 // X64: @"\01?epsilon@@YAXQEAY19BE@H@Z"
    142 
    143 void zeta(int (*)(int, int)) {}
    144 // CHECK: @"\01?zeta@@YAXP6AHHH@Z@Z"
    145 // X64: @"\01?zeta@@YAXP6AHHH@Z@Z"
    146 
    147 // Blocks mangling (Clang extension). A block should be mangled slightly
    148 // differently from a similar function pointer.
    149 void eta(int (^)(int, int)) {}
    150 // CHECK: @"\01?eta@@YAXP_EAHHH@Z@Z"
    151 
    152 typedef int theta_arg(int,int);
    153 void theta(theta_arg^ block) {}
    154 // CHECK: @"\01?theta@@YAXP_EAHHH@Z@Z"
    155 
    156 void operator_new_delete() {
    157   char *ptr = new char;
    158 // CHECK: @"\01??2@YAPAXI@Z"
    159 
    160   delete ptr;
    161 // CHECK: @"\01??3@YAXPAX@Z"
    162 
    163   char *array = new char[42];
    164 // CHECK: @"\01??_U@YAPAXI@Z"
    165 
    166   delete [] array;
    167 // CHECK: @"\01??_V@YAXPAX@Z"
    168 }
    169 
    170 // PR13022
    171 void (redundant_parens)();
    172 void redundant_parens_use() { redundant_parens(); }
    173 // CHECK: @"\01?redundant_parens@@YAXXZ"
    174 // X64: @"\01?redundant_parens@@YAXXZ"
    175 
    176 // PR13047
    177 typedef double RGB[3];
    178 RGB color1;
    179 extern const RGB color2 = {};
    180 extern RGB const color3[5] = {};
    181 extern RGB const ((color4)[5]) = {};
    182 
    183 // PR12603
    184 enum E {};
    185 // CHECK: "\01?fooE@@YA?AW4E@@XZ"
    186 // X64: "\01?fooE@@YA?AW4E@@XZ"
    187 E fooE() { return E(); }
    188 
    189 class X {};
    190 // CHECK: "\01?fooX@@YA?AVX@@XZ"
    191 // X64: "\01?fooX@@YA?AVX@@XZ"
    192 X fooX() { return X(); }
    193 
    194 namespace PR13182 {
    195   extern char s0[];
    196   // CHECK: @"\01?s0@PR13182@@3PADA"
    197   extern char s1[42];
    198   // CHECK: @"\01?s1@PR13182@@3PADA"
    199   extern const char s2[];
    200   // CHECK: @"\01?s2@PR13182@@3QBDB"
    201   extern const char s3[42];
    202   // CHECK: @"\01?s3@PR13182@@3QBDB"
    203   extern volatile char s4[];
    204   // CHECK: @"\01?s4@PR13182@@3RCDC"
    205   extern const volatile char s5[];
    206   // CHECK: @"\01?s5@PR13182@@3SDDD"
    207   extern const char* const* s6;
    208   // CHECK: @"\01?s6@PR13182@@3PBQBDB"
    209 
    210   char foo() {
    211     return s0[0] + s1[0] + s2[0] + s3[0] + s4[0] + s5[0] + s6[0][0];
    212   }
    213 }
    214