https://bugs.llvm.org/show_bug.cgi?id=47774

            Bug ID: 47774
           Summary: clang::TypeName::getFullyQualifiedName crashes on
                    certain input
           Product: clang
           Version: trunk
          Hardware: PC
                OS: All
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: -New Bugs
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected], [email protected],
                    [email protected], [email protected]

In the following code:

template <template <typename T> class C>
struct S {};
template <typename U>
void bar(S<U::template foo>);

TypeName::getFullyQualifiedName() crashes on the type of the ParmVarDecl
S<U::template foo>, whose type is:

TemplateSpecializationType 0x62100004b940 'S<U::template foo>' dependent S
`-TemplateArgument template U::template foo

Fully contained code with the crash is below:
#include "clang/AST/QualTypeNames.h"
#include "clang/AST/RecursiveASTVisitor.h"
#include "clang/Frontend/ASTUnit.h"
#include "clang/Tooling/Tooling.h"

using namespace clang;
using namespace tooling;

class ParmVarVisitor : public RecursiveASTVisitor<ParmVarVisitor> {
 public:
  bool VisitParmVarDecl(ParmVarDecl* pv) {
    const auto& context = pv->getASTContext();
    auto type = pv->getType();
    PrintingPolicy pp{LangOptions{}};
    TypeName::getFullyQualifiedName(type, context, pp);

    return true;
  }
};

int main() {
  std::unique_ptr<ASTUnit> ast = buildASTFromCode(
      "template <template <typename T> class C>\nstruct S {};\ntemplate
<typename U>\nvoid bar(S<U::template foo>);",
      "foo.cc");

  auto* TU = ast->getASTContext().getTranslationUnitDecl();
  TU->dump();
  llvm::errs() << "\n";
  ParmVarVisitor{}.TraverseDecl(TU);
  return 0;
}

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to