mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-07 20:04:03 +00:00
llvm-undname: Several behavior-preserving changes to increase coverage
- Replace `Error = true` in a few branches that are truly unreachable with DEMANGLE_UNREACHABLE - Remove early return early in startsWithLocalScopePattern() because it's redundant with the next two early returns - Remove unreachable `case '0'` (it's handled in the branch below) - Remove an unused bool return - Add test coverage for several early error returns, mostly in array type parsing llvm-svn: 362506
This commit is contained in:
parent
1efce480d9
commit
dfcff893bb
@ -58,8 +58,9 @@ static bool isMemberPointer(StringView MangledName, bool &Error) {
|
||||
// what.
|
||||
break;
|
||||
default:
|
||||
Error = true;
|
||||
return false;
|
||||
// isMemberPointer() is called only if isPointerType() returns true,
|
||||
// and it rejects other prefixes.
|
||||
DEMANGLE_UNREACHABLE;
|
||||
}
|
||||
|
||||
// If it starts with a number, then 6 indicates a non-member function
|
||||
@ -141,8 +142,6 @@ consumeSpecialIntrinsicKind(StringView &MangledName) {
|
||||
static bool startsWithLocalScopePattern(StringView S) {
|
||||
if (!S.consumeFront('?'))
|
||||
return false;
|
||||
if (S.size() < 2)
|
||||
return false;
|
||||
|
||||
size_t End = S.find('?');
|
||||
if (End == StringView::npos)
|
||||
@ -2197,7 +2196,7 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
|
||||
MangledName = MangledName.dropFront();
|
||||
// 1 - single inheritance <name>
|
||||
// H - multiple inheritance <name> <number>
|
||||
// I - virtual inheritance <name> <number> <number> <number>
|
||||
// I - virtual inheritance <name> <number> <number>
|
||||
// J - unspecified inheritance <name> <number> <number> <number>
|
||||
char InheritanceSpecifier = MangledName.popFront();
|
||||
SymbolNode *S = nullptr;
|
||||
@ -2226,8 +2225,7 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
|
||||
case '1':
|
||||
break;
|
||||
default:
|
||||
Error = true;
|
||||
break;
|
||||
DEMANGLE_UNREACHABLE;
|
||||
}
|
||||
TPRN->Affinity = PointerAffinity::Pointer;
|
||||
TPRN->Symbol = S;
|
||||
@ -2254,12 +2252,9 @@ Demangler::demangleTemplateParameterList(StringView &MangledName) {
|
||||
demangleSigned(MangledName);
|
||||
TPRN->ThunkOffsets[TPRN->ThunkOffsetCount++] =
|
||||
demangleSigned(MangledName);
|
||||
DEMANGLE_FALLTHROUGH;
|
||||
case '0':
|
||||
break;
|
||||
default:
|
||||
Error = true;
|
||||
break;
|
||||
DEMANGLE_UNREACHABLE;
|
||||
}
|
||||
TPRN->IsMemberPointer = true;
|
||||
|
||||
|
@ -34,21 +34,20 @@ static void outputSpaceIfNecessary(OutputStream &OS) {
|
||||
OS << " ";
|
||||
}
|
||||
|
||||
static bool outputSingleQualifier(OutputStream &OS, Qualifiers Q) {
|
||||
static void outputSingleQualifier(OutputStream &OS, Qualifiers Q) {
|
||||
switch (Q) {
|
||||
case Q_Const:
|
||||
OS << "const";
|
||||
return true;
|
||||
break;
|
||||
case Q_Volatile:
|
||||
OS << "volatile";
|
||||
return true;
|
||||
break;
|
||||
case Q_Restrict:
|
||||
OS << "__restrict";
|
||||
return true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
static bool outputQualifierIfPresent(OutputStream &OS, Qualifiers Q,
|
||||
|
@ -220,7 +220,32 @@
|
||||
; CHECK-NEXT: ??_C@_0101234567@?$az
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
??_C@_1201234567@a?$az
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ??_C@_1201234567@a?$az
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
??@foo
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ??@foo
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
?foo@@3YA@A
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ?foo@@3YA@A
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
?foo@@3Y~01KA
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ?foo@@3Y~01KA
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
?foo@@3Y0~1KA
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ?foo@@3Y0~1KA
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
||||
?x@@3PEAY02$$CRHEA
|
||||
; CHECK-EMPTY:
|
||||
; CHECK-NEXT: ?x@@3PEAY02$$CRHEA
|
||||
; CHECK-NEXT: error: Invalid mangled name
|
||||
|
@ -11,6 +11,9 @@
|
||||
?x@@3PEAPEAHEA
|
||||
; CHECK: int **x
|
||||
|
||||
?foo@@3Y123KA
|
||||
; CHECK: unsigned long foo[3][4]
|
||||
|
||||
?x@@3PEAY02HEA
|
||||
; CHECK: int (*x)[3]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user