mangle.cpp revision cf85b933fef4ce827df83ef2d22c322ab2078aa5
1// RUN: clang-cc -emit-llvm %s -o %t -triple=x86_64-apple-darwin9 && 2 3// FIXME: This test is intentionally trivial, because we can't yet 4// CodeGen anything real in C++. 5struct X { }; 6struct Y { }; 7 8// RUN: grep _ZplRK1YRA100_P1X %t | count 1 && 9bool operator+(const Y&, X* (&xs)[100]) { return false; } 10 11// RUN: grep _Z1f1s %t | count 1 && 12typedef struct { int a; } s; 13void f(s) { } 14 15// RUN: grep _Z1f1e %t| count 1 && 16typedef enum { foo } e; 17void f(e) { } 18 19// RUN: grep _Z1f1u %t | count 1 && 20typedef union { int a; } u; 21void f(u) { } 22 23// RUN: grep _Z1f1x %t | count 1 && 24typedef struct { int a; } x,y; 25void f(y) { } 26 27// RUN: grep _Z1fv %t | count 1 && 28void f() { } 29 30// RUN: grep _ZN1N1fEv %t | count 1 && 31namespace N { void f() { } } 32 33// RUN: grep _ZN1N1N1fEv %t | count 1 && 34namespace N { namespace N { void f() { } } } 35 36// RUN: grep unmangled_function %t | count 1 && 37extern "C" { namespace N { void unmangled_function() { } } } 38 39// RUN: grep unmangled_variable %t | count 1 && 40extern "C" { namespace N { int unmangled_variable = 10; } } 41 42// RUN: grep _ZN1N1iE %t | count 1 && 43namespace N { int i; } 44 45// RUN: grep _ZZN1N1fEiiE1b %t | count 2 && 46namespace N { int f(int, int) { static int b; return b; } } 47 48// RUN: grep "_ZZN1N1gEvE1a =" %t | count 1 && 49// RUN: grep "_ZGVZN1N1gEvE1a =" %t | count 1 && 50namespace N { int h(); void g() { static int a = h(); } } 51 52// RUN: grep "_Z1fno" %t | count 1 && 53void f(__int128_t, __uint128_t) { } 54 55template <typename T> struct S1 {}; 56 57// RUN: grep "_Z1f2S1IiE" %t | count 1 && 58void f(S1<int>) {} 59 60// RUN: grep "_Z1f2S1IdE" %t | count 1 && 61void f(S1<double>) {} 62 63template <int N> struct S2 {}; 64// RUN: grep "_Z1f2S2ILi100EE" %t | count 1 && 65void f(S2<100>) {} 66 67// RUN: grep "_Z1f2S2ILin100EE" %t | count 1 && 68void f(S2<-100>) {} 69 70template <bool B> struct S3 {}; 71 72// RUN: grep "_Z1f2S3ILb1EE" %t | count 1 && 73void f(S3<true>) {} 74 75// RUN: grep "_Z1f2S3ILb0EE" %t | count 1 && 76void f(S3<false>) {} 77 78// RUN: grep "_Z2f22S3ILb1EE" %t | count 1 && 79void f2(S3<100>) {} 80 81struct S; 82 83// RUN: grep "_Z1fM1SKFvvE" %t | count 1 && 84void f(void (S::*)() const) {} 85 86// RUN: grep "_Z1fM1SFvvE" %t | count 1 && 87void f(void (S::*)()) {} 88 89// RUN: grep "_Z1fi" %t | count 1 && 90void f(const int) { } 91 92// RUN: true 93