mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2025-02-09 10:55:03 +00:00
Itanium Mangling: In 'enable_if', omit X/E around <expr-primary>.
The Clang enable_if extension is mangled as an <extended-qualifier>, which is supposed to contain <template-args>. However, we were unconditionally emitting X/E around its arguments, neglecting the fact that <expr-primary> should be emitted directly without the surrounding X/E. Differential Revision: https://reviews.llvm.org/D95488
This commit is contained in:
parent
8ca33605ff
commit
a7246ba02a
@ -727,9 +727,17 @@ void CXXNameMangler::mangleFunctionEncodingBareType(const FunctionDecl *FD) {
|
||||
EnableIfAttr *EIA = dyn_cast<EnableIfAttr>(*I);
|
||||
if (!EIA)
|
||||
continue;
|
||||
Out << 'X';
|
||||
mangleExpression(EIA->getCond());
|
||||
Out << 'E';
|
||||
if (Context.getASTContext().getLangOpts().getClangABICompat() >
|
||||
LangOptions::ClangABI::Ver11) {
|
||||
mangleTemplateArgExpr(EIA->getCond());
|
||||
} else {
|
||||
// Prior to Clang 12, we hardcoded the X/E around enable-if's argument,
|
||||
// even though <template-arg> should not include an X/E around
|
||||
// <expr-primary>.
|
||||
Out << 'X';
|
||||
mangleExpression(EIA->getCond());
|
||||
Out << 'E';
|
||||
}
|
||||
}
|
||||
Out << 'E';
|
||||
FunctionTypeDepth.pop(Saved);
|
||||
|
@ -31,22 +31,22 @@ void bar(int m) __attribute__((overloadable, enable_if(m > 0, "")));
|
||||
void bar(int m) __attribute__((overloadable, enable_if(1, "")));
|
||||
// CHECK-LABEL: define{{.*}} void @test2
|
||||
void test2() {
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
|
||||
void (*p)(int) = bar;
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
|
||||
void (*p2)(int) = &bar;
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
|
||||
p = bar;
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3barUa9enable_ifILi1EEi
|
||||
p = &bar;
|
||||
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
|
||||
void *vp1 = (void*)&bar;
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
|
||||
void *vp2 = (void*)bar;
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
|
||||
vp1 = (void*)&bar;
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifIXLi1EEEi to i8*)
|
||||
// CHECK: store i8* bitcast (void (i32)* @_Z3barUa9enable_ifILi1EEi to i8*)
|
||||
vp1 = (void*)bar;
|
||||
}
|
||||
|
||||
@ -54,13 +54,13 @@ void baz(int m) __attribute__((overloadable, enable_if(1, "")));
|
||||
void baz(int m) __attribute__((overloadable));
|
||||
// CHECK-LABEL: define{{.*}} void @test3
|
||||
void test3() {
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
|
||||
void (*p)(int) = baz;
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
|
||||
void (*p2)(int) = &baz;
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
|
||||
p = baz;
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifIXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3bazUa9enable_ifILi1EEi
|
||||
p = &baz;
|
||||
}
|
||||
|
||||
@ -71,13 +71,13 @@ void qux(int m) __attribute__((overloadable, enable_if(1, ""),
|
||||
void qux(int m) __attribute__((overloadable, enable_if(1, "")));
|
||||
// CHECK-LABEL: define{{.*}} void @test4
|
||||
void test4() {
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
|
||||
void (*p)(int) = qux;
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
|
||||
void (*p2)(int) = &qux;
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
|
||||
p = qux;
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifIXLi1EEXLi1EEEi
|
||||
// CHECK: store void (i32)* @_Z3quxUa9enable_ifILi1ELi1EEi
|
||||
p = &qux;
|
||||
}
|
||||
|
||||
@ -90,6 +90,6 @@ void test5() {
|
||||
int foo(char *i __attribute__((pass_object_size(0))))
|
||||
__attribute__((enable_if(1, ""), overloadable));
|
||||
|
||||
// CHECK: call i32 @_Z3fooUa9enable_ifIXLi1EEEPcU17pass_object_size0
|
||||
// CHECK: call i32 @_Z3fooUa9enable_ifILi1EEPcU17pass_object_size0
|
||||
foo((void*)0);
|
||||
}
|
||||
|
@ -130,4 +130,9 @@ template void test7<A>(A::Int<1>);
|
||||
template<int N> using matrix1xN = int __attribute__((matrix_type(1, N)));
|
||||
template<int N> void test8(matrix1xN<N> a) {}
|
||||
template void test8<2>(matrix1xN<2> a);
|
||||
|
||||
// PRE12: @_ZN12expr_primary5test9EUa9enable_ifIXLi1EEEv
|
||||
// V12: @_ZN12expr_primary5test9EUa9enable_ifILi1EEv
|
||||
void test9(void) __attribute__((enable_if(1, ""))) {}
|
||||
|
||||
}
|
||||
|
@ -5,7 +5,7 @@ int test5(int);
|
||||
template <typename T>
|
||||
T test5(T) __attribute__((enable_if(1, "better than non-template")));
|
||||
|
||||
// CHECK: @_Z5test5IiEUa9enable_ifIXLi1EEET_S0_
|
||||
// CHECK: @_Z5test5IiEUa9enable_ifILi1EET_S0_
|
||||
int (*Ptr)(int) = &test5;
|
||||
|
||||
// Test itanium mangling for attribute enable_if
|
||||
|
Loading…
x
Reference in New Issue
Block a user