<html>
    <head>
      <base href="https://bugs.llvm.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_NEW "
   title="NEW - clang::TypeName::getFullyQualifiedName crashes on certain input"
   href="https://bugs.llvm.org/show_bug.cgi?id=47774">47774</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>clang::TypeName::getFullyQualifiedName crashes on certain input
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>clang
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>trunk
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>PC
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>NEW
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>enhancement
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>P
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>-New Bugs
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>unassignedclangbugs@nondot.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>awoolf@fb.com
          </td>
        </tr>

        <tr>
          <th>CC</th>
          <td>htmldeveloper@gmail.com, llvm-bugs@lists.llvm.org, neeilans@live.com, richard-llvm@metafoo.co.uk
          </td>
        </tr></table>
      <p>
        <div>
        <pre>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;
}</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are on the CC list for the bug.</li>
      </ul>
    </body>
</html>