Open llvmbot opened 4 years ago
In the following code:
template <template class C> struct S {}; template void bar(S);
TypeName::getFullyQualifiedName() crashes on the type of the ParmVarDecl S, whose type is:
TemplateSpecializationType 0x62100004b940 'S' dependent S `-TemplateArgument template U::template foo
Fully contained code with the crash is below:
using namespace clang; using namespace tooling;
class ParmVarVisitor : public RecursiveASTVisitor { 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 ast = buildASTFromCode( "template <template class C>\nstruct S {};\ntemplate \nvoid bar(S);", "foo.cc");
auto* TU = ast->getASTContext().getTranslationUnitDecl(); TU->dump(); llvm::errs() << "\n"; ParmVarVisitor{}.TraverseDecl(TU); return 0; }
@llvm/issue-subscribers-clang-frontend
@llvm/issue-subscribers-c-1
Extended Description
In the following code:
template <template class C>
struct S {};
template
void bar(S);
TypeName::getFullyQualifiedName() crashes on the type of the ParmVarDecl S, whose type is:
TemplateSpecializationType 0x62100004b940 'S' 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 {
public:
bool VisitParmVarDecl(ParmVarDecl* pv) {
const auto& context = pv->getASTContext();
auto type = pv->getType();
PrintingPolicy pp{LangOptions{}};
TypeName::getFullyQualifiedName(type, context, pp);
} };
int main() { std::unique_ptr ast = buildASTFromCode(
"template <template class C>\nstruct S {};\ntemplate \nvoid bar(S);",
"foo.cc");
auto* TU = ast->getASTContext().getTranslationUnitDecl(); TU->dump(); llvm::errs() << "\n"; ParmVarVisitor{}.TraverseDecl(TU); return 0; }