OSDN Git Service

[MS Demangler] Fix some minor formatting bugs.
authorZachary Turner <zturner@google.com>
Tue, 14 Aug 2018 18:54:28 +0000 (18:54 +0000)
committerZachary Turner <zturner@google.com>
Tue, 14 Aug 2018 18:54:28 +0000 (18:54 +0000)
1) We print __restrict twice on member pointers.  This is fixed
   and relevant tests are re-enabled.

2) Several tests were disabled because of printing slightly
   different output than undname.  These were confirmed to be
   bugs in undname, so we just re-enable the tests.

3) The test for printing reference temporaries is re-enabled.  This
   is a clang mangling extension, so we have some flexibility with
   how we demangle it.  The output currently looks fine, so we just
   re-enable the test with no fixes.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@339708 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Demangle/MicrosoftDemangle.cpp
test/Demangle/ms-back-references.test
test/Demangle/ms-mangle.test
test/Demangle/ms-return-qualifiers.test

index cab662f..0af93e1 100644 (file)
@@ -815,8 +815,6 @@ void MemberPointerType::outputPre(OutputStream &OS, NameResolver &Resolver) {
   // FIXME: We should output this, but it requires updating lots of tests.
   // if (Ty.Quals & Q_Pointer64)
   //  OS << " __ptr64";
-  if (Quals & Q_Restrict)
-    OS << " __restrict";
 }
 
 void MemberPointerType::outputPost(OutputStream &OS, NameResolver &Resolver) {
@@ -2028,12 +2026,12 @@ ArrayType *Demangler::demangleArrayType(StringView &MangledName) {
   }
 
   if (MangledName.consumeFront("$$C")) {
-    if (MangledName.consumeFront("B"))
-      ATy->Quals = Q_Const;
-    else if (MangledName.consumeFront("C") || MangledName.consumeFront("D"))
-      ATy->Quals = Qualifiers(Q_Const | Q_Volatile);
-    else if (!MangledName.consumeFront("A"))
+    bool IsMember = false;
+    std::tie(ATy->Quals, IsMember) = demangleQualifiers(MangledName);
+    if (IsMember) {
       Error = true;
+      return nullptr;
+    }
   }
 
   ATy->ElementType = demangleType(MangledName, QualifierMangleMode::Drop);
index ade9dd2..553d2ff 100644 (file)
@@ -23,8 +23,6 @@
 ?f7@@YAXHPAHH0_N1PA_N@Z
 ; CHECK: void __cdecl f7(int, int *, int, int *, bool, bool, bool *)
 
-; FIXME: tests for more than 10 types?
-
 ?g1@@YAXUS@@@Z
 ; CHECK: void __cdecl g1(struct S)
 
index b3fe67f..3a87a1e 100644 (file)
 ?anonymous@?A@N@@3HA
 ; CHECK: int N::`anonymous namespace'::anonymous
 
-; FIXME: Reference Temporaries
-; ?$RT1@NeedsReferenceTemporary@@3ABHB
-; ?$RT1@NeedsReferenceTemporary@@3AEBHEB
+?$RT1@NeedsReferenceTemporary@@3ABHB
+; CHECK: int const &NeedsReferenceTemporary::$RT1
+?$RT1@NeedsReferenceTemporary@@3AEBHEB
+; CHECK: int const &NeedsReferenceTemporary::$RT1
 
 ?_c@@YAHXZ
 ; CHECK: int __cdecl _c(void)
 ?color2@@3QBNB
 ; CHECK: double const *const color2
 
-; FIXME-EXTRACONST: These tests fails because we print an extra const inside the parens.
-?color3@@3QAY02$$CBNA
-; FIXME-EXTRACONST: double const (*color3)[3]
+; undname prints `double const (* color3)[3]`, but this is a bug in undname.
+?color3@@3QAY02$$CBNA
+; CHECK: double const (*const color3)[3]
 
-; ?color4@@3QAY02$$CBNA
-; FIXME-EXTRACONST: double const (*color4)[3]
+; undname prints `double const (* color4)[3]`, but this is a bug in undname.
+?color4@@3QAY02$$CBNA
+; CHECK: double const (*const color4)[3]
 
 ?memptr1@@3RESB@@HES1@
 ; CHECK: int volatile B::*volatile memptr1
index 7fedf6c..bad181e 100644 (file)
 ?f9@@YAQQS@@HXZ
 ; CHECK: int S::*const __cdecl f9(void)
 
-; We print __restrict twice here.
 ?f10@@YAPIQS@@HXZ
-; FIXME: int S::* __restrict __cdecl f10(void)
+; CHECK: int S::*__restrict __cdecl f10(void)
 
-; We print __restrict twice here.
 ?f11@@YAQIQS@@HXZ
-; FIXME: int S::* __restrict __cdecl f11(void)
+; CHECK: int S::*const __restrict __cdecl f11(void)
 
 ?g1@@YAP6AHH@ZXZ
 ; CHECK: int (__cdecl * __cdecl g1(void))(int)