Index: libcxxabi/src/demangle/ItaniumDemangle.h =================================================================== --- libcxxabi/src/demangle/ItaniumDemangle.h +++ libcxxabi/src/demangle/ItaniumDemangle.h @@ -2591,7 +2591,7 @@ Node *parseAbiTags(Node *N); /// Parse the production. - Node *parseUnresolvedName(); + Node *parseUnresolvedName(bool Global); Node *parseSimpleId(); Node *parseBaseUnresolvedName(); Node *parseUnresolvedType(); @@ -3418,6 +3418,7 @@ // ::= [gs] # x or (with "gs") ::x // ::= [gs] sr + E // # A::x, N::y, A::z; "gs" means leading "::" +// [gs] has been parsed by caller. // ::= sr # T::x / decltype(p)::x // extension ::= sr // # T::N::x /decltype(p)::N::x @@ -3425,7 +3426,7 @@ // // ::= template -Node *AbstractManglingParser::parseUnresolvedName() { +Node *AbstractManglingParser::parseUnresolvedName(bool Global) { Node *SoFar = nullptr; // srN [] * E @@ -3459,8 +3460,6 @@ return make(SoFar, Base); } - bool Global = consumeIf("gs"); - // [gs] # x or (with "gs") ::x if (!consumeIf("sr")) { SoFar = getDerived().parseBaseUnresolvedName(); @@ -4727,7 +4726,7 @@ return make(E, Global, /*is_array=*/false); } case 'n': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 's': { First += 2; Node *LHS = getDerived().parseExpr(); @@ -4899,7 +4898,7 @@ case 'o': switch (First[1]) { case 'n': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 'o': First += 2; return getDerived().parseBinaryExpr("||"); @@ -5017,7 +5016,7 @@ return make(Child); } case 'r': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 't': { First += 2; Node *Ty = getDerived().parseType(); @@ -5150,7 +5149,7 @@ case '7': case '8': case '9': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); } return nullptr; } Index: libcxxabi/test/test_demangle.pass.cpp =================================================================== --- libcxxabi/test/test_demangle.pass.cpp +++ libcxxabi/test/test_demangle.pass.cpp @@ -29861,6 +29861,8 @@ {"_ZN2FnIXgsdlLi4EEXdaLi4EEEEvv", "void Fn<::delete 4, delete[] 4>()"}, {"_ZN2FnIXdlLj4EEXgsdaLj4EEEEvv", "void Fn()"}, + {"_ZN2FnIXgs4BaseEX4BaseEEEvv","void Fn<::Base, Base>()"}, + {"_Z3TPLIiET_S0_", "int TPL(int)"}, // C++20 modules Index: llvm/include/llvm/Demangle/ItaniumDemangle.h =================================================================== --- llvm/include/llvm/Demangle/ItaniumDemangle.h +++ llvm/include/llvm/Demangle/ItaniumDemangle.h @@ -2591,7 +2591,7 @@ Node *parseAbiTags(Node *N); /// Parse the production. - Node *parseUnresolvedName(); + Node *parseUnresolvedName(bool Global); Node *parseSimpleId(); Node *parseBaseUnresolvedName(); Node *parseUnresolvedType(); @@ -3418,6 +3418,7 @@ // ::= [gs] # x or (with "gs") ::x // ::= [gs] sr + E // # A::x, N::y, A::z; "gs" means leading "::" +// [gs] has been parsed by caller. // ::= sr # T::x / decltype(p)::x // extension ::= sr // # T::N::x /decltype(p)::N::x @@ -3425,7 +3426,7 @@ // // ::= template -Node *AbstractManglingParser::parseUnresolvedName() { +Node *AbstractManglingParser::parseUnresolvedName(bool Global) { Node *SoFar = nullptr; // srN [] * E @@ -3459,8 +3460,6 @@ return make(SoFar, Base); } - bool Global = consumeIf("gs"); - // [gs] # x or (with "gs") ::x if (!consumeIf("sr")) { SoFar = getDerived().parseBaseUnresolvedName(); @@ -4727,7 +4726,7 @@ return make(E, Global, /*is_array=*/false); } case 'n': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 's': { First += 2; Node *LHS = getDerived().parseExpr(); @@ -4899,7 +4898,7 @@ case 'o': switch (First[1]) { case 'n': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 'o': First += 2; return getDerived().parseBinaryExpr("||"); @@ -5017,7 +5016,7 @@ return make(Child); } case 'r': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); case 't': { First += 2; Node *Ty = getDerived().parseType(); @@ -5150,7 +5149,7 @@ case '7': case '8': case '9': - return getDerived().parseUnresolvedName(); + return getDerived().parseUnresolvedName(Global); } return nullptr; }