[llvm] r362520 - llvm-undname: Yet more coverage for error paths

Nico Weber via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 4 09:25:29 PDT 2019


Author: nico
Date: Tue Jun  4 09:25:28 2019
New Revision: 362520

URL: http://llvm.org/viewvc/llvm-project?rev=362520&view=rev
Log:
llvm-undname: Yet more coverage for error paths

- For error returns in demangleSpecialTableNode(),
  demangleLocalStaticGuard(), RTTITypeDescriptor,
  demangleRttiBaseClassDescriptorNode(), demangleUnsigned(),
  demangleUntypedVariable() (via RttiBaseClassArray)

- For ?_A and ?_P which are handled at early levels of the
  demangler but are not implemented in a later stage; this
  is now more obvious

- Replace a "default:" with an explicit list of cases, to
  get -Wswitch check we list all cases

Modified:
    llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
    llvm/trunk/test/Demangle/invalid-manglings.test

Modified: llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp?rev=362520&r1=362519&r2=362520&view=diff
==============================================================================
--- llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp (original)
+++ llvm/trunk/lib/Demangle/MicrosoftDemangle.cpp Tue Jun  4 09:25:28 2019
@@ -429,10 +429,10 @@ FunctionSymbolNode *Demangler::demangleI
 
 SymbolNode *Demangler::demangleSpecialIntrinsic(StringView &MangledName) {
   SpecialIntrinsicKind SIK = consumeSpecialIntrinsicKind(MangledName);
-  if (SIK == SpecialIntrinsicKind::None)
-    return nullptr;
 
   switch (SIK) {
+  case SpecialIntrinsicKind::None:
+    return nullptr;
   case SpecialIntrinsicKind::StringLiteralSymbol:
     return demangleStringLiteral(MangledName);
   case SpecialIntrinsicKind::Vftable:
@@ -468,8 +468,13 @@ SymbolNode *Demangler::demangleSpecialIn
     return demangleInitFiniStub(MangledName, false);
   case SpecialIntrinsicKind::DynamicAtexitDestructor:
     return demangleInitFiniStub(MangledName, true);
-  default:
+  case SpecialIntrinsicKind::Typeof:
+  case SpecialIntrinsicKind::UdtReturning:
+    // It's unclear which tools produces these manglings, so demangling
+    // support is not (yet?) implemented.
     break;
+  case SpecialIntrinsicKind::Unknown:
+    DEMANGLE_UNREACHABLE; // Never returned by consumeSpecialIntrinsicKind.
   }
   Error = true;
   return nullptr;

Modified: llvm/trunk/test/Demangle/invalid-manglings.test
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Demangle/invalid-manglings.test?rev=362520&r1=362519&r2=362520&view=diff
==============================================================================
--- llvm/trunk/test/Demangle/invalid-manglings.test (original)
+++ llvm/trunk/test/Demangle/invalid-manglings.test Tue Jun  4 09:25:28 2019
@@ -309,3 +309,48 @@
 ; CHECK-EMPTY:
 ; CHECK-NEXT: ?foo@?0?
 ; CHECK-NEXT: error: Invalid mangled name
+
+??_Sfoo@@1Abar@@
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_Sfoo@@1Abar@@
+; CHECK-NEXT: error: Invalid mangled name
+
+??_Bfoo@@1
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_Bfoo@@1
+; CHECK-NEXT: error: Invalid mangled name
+
+??_R0
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_R0
+; CHECK-NEXT: error: Invalid mangled name
+
+??_R0H
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_R0H
+; CHECK-NEXT: error: Invalid mangled name
+
+??_R0H at 8foo
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_R0H at 8foo
+; CHECK-NEXT: error: Invalid mangled name
+
+??_R1012?3foo@@
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_R1012?3foo@@
+; CHECK-NEXT: error: Invalid mangled name
+
+??_R2foo@@1
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_R2foo@@1
+; CHECK-NEXT: error: Invalid mangled name
+
+??_A
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_A
+; CHECK-NEXT: error: Invalid mangled name
+
+??_P
+; CHECK-EMPTY:
+; CHECK-NEXT: ??_P
+; CHECK-NEXT: error: Invalid mangled name




More information about the llvm-commits mailing list