diff --git a/libcxxabi/src/demangle/ItaniumDemangle.h b/libcxxabi/src/demangle/ItaniumDemangle.h index 88de234a6e0b92..cfa40bad192c19 100644 --- a/libcxxabi/src/demangle/ItaniumDemangle.h +++ b/libcxxabi/src/demangle/ItaniumDemangle.h @@ -2677,7 +2677,7 @@ template struct AbstractManglingParser { bool TryToParseTemplateArgs = true; bool PermitForwardTemplateReferences = false; - bool InConstraintExpr = false; + bool HasIncompleteTemplateParameterTracking = false; size_t ParsingLambdaParamsAtLevel = (size_t)-1; unsigned NumSyntheticTemplateParameters[3] = {}; @@ -4818,7 +4818,7 @@ template Node *AbstractManglingParser::parseConstraintExpr() { // Within this expression, all enclosing template parameter lists are in // scope. - ScopedOverride SaveInConstraintExpr(InConstraintExpr, true); + ScopedOverride SaveIncompleteTemplateParameterTracking(HasIncompleteTemplateParameterTracking, true); return getDerived().parseExpr(); } @@ -5676,7 +5676,7 @@ Node *AbstractManglingParser::parseTemplateParam() { // substitute them all within a , so print the // parameter numbering instead for now. // TODO: Track all enclosing template parameters and substitute them here. - if (InConstraintExpr) { + if (HasIncompleteTemplateParameterTracking) { return make(std::string_view(Begin, First - 1 - Begin)); } @@ -5737,6 +5737,12 @@ Node *AbstractManglingParser::parseTemplateParamDecl( } if (consumeIf("Tk")) { + // We don't track enclosing template parameter levels well enough to reliably + // demangle template parameter substitutions, so print an arbitrary + // string in place of a parameter for now. + // TODO: Track all enclosing template parameters and demangle substitutions. + ScopedOverride SaveIncompleteTemplateParameterTrackingExpr( + HasIncompleteTemplateParameterTracking, true); Node *Constraint = getDerived().parseName(); if (!Constraint) return nullptr; diff --git a/llvm/include/llvm/Demangle/ItaniumDemangle.h b/llvm/include/llvm/Demangle/ItaniumDemangle.h index fb2060fa07f724..c0511cbcec8bad 100644 --- a/llvm/include/llvm/Demangle/ItaniumDemangle.h +++ b/llvm/include/llvm/Demangle/ItaniumDemangle.h @@ -2677,7 +2677,7 @@ template struct AbstractManglingParser { bool TryToParseTemplateArgs = true; bool PermitForwardTemplateReferences = false; - bool InConstraintExpr = false; + bool HasIncompleteTemplateParameterTracking = false; size_t ParsingLambdaParamsAtLevel = (size_t)-1; unsigned NumSyntheticTemplateParameters[3] = {}; @@ -4818,7 +4818,7 @@ template Node *AbstractManglingParser::parseConstraintExpr() { // Within this expression, all enclosing template parameter lists are in // scope. - ScopedOverride SaveInConstraintExpr(InConstraintExpr, true); + ScopedOverride SaveIncompleteTemplateParameterTracking(HasIncompleteTemplateParameterTracking, true); return getDerived().parseExpr(); } @@ -5676,7 +5676,7 @@ Node *AbstractManglingParser::parseTemplateParam() { // substitute them all within a , so print the // parameter numbering instead for now. // TODO: Track all enclosing template parameters and substitute them here. - if (InConstraintExpr) { + if (HasIncompleteTemplateParameterTracking) { return make(std::string_view(Begin, First - 1 - Begin)); } @@ -5737,6 +5737,12 @@ Node *AbstractManglingParser::parseTemplateParamDecl( } if (consumeIf("Tk")) { + // We don't track enclosing template parameter levels well enough to reliably + // demangle template parameter substitutions, so print an arbitrary + // string in place of a parameter for now. + // TODO: Track all enclosing template parameters and demangle substitutions. + ScopedOverride SaveIncompleteTemplateParameterTrackingExpr( + HasIncompleteTemplateParameterTracking, true); Node *Constraint = getDerived().parseName(); if (!Constraint) return nullptr; diff --git a/llvm/test/tools/llvm-cxxfilt/demangle-constrained-template.test b/llvm/test/tools/llvm-cxxfilt/demangle-constrained-template.test new file mode 100644 index 00000000000000..7a038ebb77a06d --- /dev/null +++ b/llvm/test/tools/llvm-cxxfilt/demangle-constrained-template.test @@ -0,0 +1,3 @@ +RUN: llvm-cxxfilt -n _ZN3FooIiE6methodITk4TrueIT_EiEEvS3_ | FileCheck %s + +CHECK: void Foo::method(T) \ No newline at end of file