[llvm] r362506 - llvm-undname: Several behavior-preserving changes to increase coverage
Nico Weber via llvm-commits
llvm-commits at lists.llvm.org
Tue Jun 4 08:13:30 PDT 2019
Author: nico
Date: Tue Jun 4 08:13:30 2019
New Revision: 362506
URL: http://llvm.org/viewvc/llvm-project?rev=362506&view=rev
Log:
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
Modified:
llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
llvm/trunk/test/Demangle/invalid-manglings.test
llvm/trunk/test/Demangle/ms-basic.test
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=362506&r1=362505&r2=362506&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Tue Jun 4 08:13:30 2019
@@ -58,8 +58,9 @@ static bool isMemberPointer(StringView M
// 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 &
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
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
case '1':
break;
default:
- Error = true;
- break;
+ DEMANGLE_UNREACHABLE;
}
TPRN->Affinity = PointerAffinity::Pointer;
TPRN->Symbol = S;
@@ -2254,12 +2252,9 @@ Demangler::demangleTemplateParameterList
demangleSigned(MangledName);
TPRN->ThunkOffsets[TPRN->ThunkOffsetCount++] =
demangleSigned(MangledName);
- DEMANGLE_FALLTHROUGH;
- case '0':
break;
default:
- Error = true;
- break;
+ DEMANGLE_UNREACHABLE;
}
TPRN->IsMemberPointer = true;
Modified: llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp?rev=362506&r1=362505&r2=362506&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangleNodes.cpp Tue Jun 4 08:13:30 2019
@@ -34,21 +34,20 @@ static void outputSpaceIfNecessary(Outpu
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,
Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=362506&r1=362505&r2=362506&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Tue Jun 4 08:13:30 2019
@@ -220,7 +220,32 @@
; CHECK-NEXT: ??_C at _0101234567@?$az
; CHECK-NEXT: error: Invalid mangled name
+??_C at _1201234567@a?$az
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_C at _1201234567@a?$az
+; CHECK-NEXT: error: Invalid mangled name
+
??@foo
; CHECK-EMPTY:
; CHECK-NEXT: ??@foo
; CHECK-NEXT: error: Invalid mangled name
+
+?foo@@3YA at A
+; CHECK-EMPTY:
+; CHECK-NEXT: ?foo@@3YA at 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
Modified: llvm/trunk/test/Demangle/ms-basic.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/ms-basic.test?rev=362506&r1=362505&r2=362506&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/ms-basic.test (original)
+++ llvm/trunk/test/Demangle/ms-basic.test Tue Jun 4 08:13:30 2019
@@ -11,6 +11,9 @@
?x@@3PEAPEAHEA
; CHECK: int **x
+?foo@@3Y123KA
+; CHECK: unsigned long foo[3][4]
+
?x@@3PEAY02HEA
; CHECK: int (*x)[3]
More information about the llvm-commits
mailing list