mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 12:12:47 +01:00
[Demangle][Rust] Parse function signatures
Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D102581
This commit is contained in:
parent
c8ca4bcf8b
commit
f7d35d6801
@ -88,6 +88,7 @@ private:
|
|||||||
void demangleImplPath(InType InType);
|
void demangleImplPath(InType InType);
|
||||||
void demangleGenericArg();
|
void demangleGenericArg();
|
||||||
void demangleType();
|
void demangleType();
|
||||||
|
void demangleFnSig();
|
||||||
void demangleConst();
|
void demangleConst();
|
||||||
void demangleConstInt();
|
void demangleConstInt();
|
||||||
void demangleConstBool();
|
void demangleConstBool();
|
||||||
|
@ -472,6 +472,9 @@ void Demangler::demangleType() {
|
|||||||
print("*mut ");
|
print("*mut ");
|
||||||
demangleType();
|
demangleType();
|
||||||
break;
|
break;
|
||||||
|
case 'F':
|
||||||
|
demangleFnSig();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
Position = Start;
|
Position = Start;
|
||||||
demanglePath(rust_demangle::InType::Yes);
|
demanglePath(rust_demangle::InType::Yes);
|
||||||
@ -479,6 +482,47 @@ void Demangler::demangleType() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// <fn-sig> := [<binder>] ["U"] ["K" <abi>] {<type>} "E" <type>
|
||||||
|
// <abi> = "C"
|
||||||
|
// | <undisambiguated-identifier>
|
||||||
|
void Demangler::demangleFnSig() {
|
||||||
|
// FIXME demangle binder.
|
||||||
|
|
||||||
|
if (consumeIf('U'))
|
||||||
|
print("unsafe ");
|
||||||
|
|
||||||
|
if (consumeIf('K')) {
|
||||||
|
print("extern \"");
|
||||||
|
if (consumeIf('C')) {
|
||||||
|
print("C");
|
||||||
|
} else {
|
||||||
|
Identifier Ident = parseIdentifier();
|
||||||
|
for (char C : Ident.Name) {
|
||||||
|
// When mangling ABI string, the "-" is replaced with "_".
|
||||||
|
if (C == '_')
|
||||||
|
C = '-';
|
||||||
|
print(C);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
print("\" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
print("fn(");
|
||||||
|
for (size_t I = 0; !Error && !consumeIf('E'); ++I) {
|
||||||
|
if (I > 0)
|
||||||
|
print(", ");
|
||||||
|
demangleType();
|
||||||
|
}
|
||||||
|
print(")");
|
||||||
|
|
||||||
|
if (consumeIf('u')) {
|
||||||
|
// Skip the unit type from the output.
|
||||||
|
} else {
|
||||||
|
print(" -> ");
|
||||||
|
demangleType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// <const> = <basic-type> <const-data>
|
// <const> = <basic-type> <const-data>
|
||||||
// | "p" // placeholder
|
// | "p" // placeholder
|
||||||
// | <backref>
|
// | <backref>
|
||||||
|
@ -187,6 +187,35 @@ CHECK: types::<*const _>
|
|||||||
CHECK: types::<*mut _>
|
CHECK: types::<*mut _>
|
||||||
_RIC5typesOpE
|
_RIC5typesOpE
|
||||||
|
|
||||||
|
; Function signatures
|
||||||
|
|
||||||
|
CHECK: function::<fn()>
|
||||||
|
_RIC8functionFEuE
|
||||||
|
|
||||||
|
CHECK: function::<fn() -> _>
|
||||||
|
_RIC8functionFEpE
|
||||||
|
|
||||||
|
CHECK: function::<fn(_)>
|
||||||
|
_RIC8functionFpEuE
|
||||||
|
|
||||||
|
CHECK: function::<fn(_, _)>
|
||||||
|
_RIC8functionFppEuE
|
||||||
|
|
||||||
|
CHECK: function::<fn(_, _, _)>
|
||||||
|
_RIC8functionFpppEuE
|
||||||
|
|
||||||
|
CHECK: function::<unsafe fn()>
|
||||||
|
_RIC8functionFUEuE
|
||||||
|
|
||||||
|
CHECK: function::<extern "C" fn()>
|
||||||
|
_RIC8functionFKCEuE
|
||||||
|
|
||||||
|
CHECK: function::<extern "cdecl" fn()>
|
||||||
|
_RIC8functionFK5cdeclEuE
|
||||||
|
|
||||||
|
CHECK: function::<unsafe extern "C-cmse-nonsecure-call" fn()>
|
||||||
|
_RIC8functionFUK21C_cmse_nonsecure_callEuE
|
||||||
|
|
||||||
; Integer constants. Test value demangling.
|
; Integer constants. Test value demangling.
|
||||||
|
|
||||||
CHECK: integer::<0>
|
CHECK: integer::<0>
|
||||||
|
Loading…
Reference in New Issue
Block a user