<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 - Crash in MicrosoftMangle.cpp mangleType"
   href="https://bugs.llvm.org/show_bug.cgi?id=47650">47650</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>Crash in MicrosoftMangle.cpp mangleType
          </td>
        </tr>

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

        <tr>
          <th>Version</th>
          <td>10.0
          </td>
        </tr>

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

        <tr>
          <th>OS</th>
          <td>Windows NT
          </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>bigwalrus@gmail.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>clang msvc-compat

I'm using clang::parseAST to parse wrl\event.h from the Windows 10 SDK. In my
Visitor::VisitFunctionDecl, I'm using the mangler to generate mangled names and
it is crashing on Microsoft::WRL::Callback.

The type is TemplateTypeParam, not RecordType, hence the crash.

I suspect the function in question is this:

// Construct a COM/WinRT delegate, an object with an Invoke() method, from an
object and member function.
template<typename TDelegateInterface, typename TCallbackObject, typename...
TArgs>
ComPtr<typename
Details::DelegateArgTraitsHelper<TDelegateInterface>::Interface> Callback(_In_
TCallbackObject *object, _In_ HRESULT(TCallbackObject::* method)(TArgs...))
throw()
{
    return Callback<TDelegateInterface>([=](auto&& ...args) { return
((*object).*(method))(args ...); });
}

        ocgen.exe!clang::Type::castAs<clang::RecordType>() Line 83      C++
<span class="quote">>        ocgen.exe!`anonymous namespace'::MicrosoftCXXNameMangler::mangleType(const clang::MemberPointerType * T, clang::Qualifiers Quals, clang::SourceRange Range) Line 2575   C++</span >
        ocgen.exe!`anonymous
namespace'::MicrosoftCXXNameMangler::mangleType(clang::QualType T,
clang::SourceRange Range,
`anonymous-namespace'::MicrosoftCXXNameMangler::QualifierMangleMode QMM) Line
48      C++
        ocgen.exe!`anonymous
namespace'::MicrosoftCXXNameMangler::mangleFunctionArgumentType(clang::QualType
T, clang::SourceRange Range) Line 1785     C++
        ocgen.exe!`anonymous
namespace'::MicrosoftCXXNameMangler::mangleFunctionType(const
clang::FunctionType * T, const clang::FunctionDecl * D, bool ForceThisQuals,
bool MangleExceptionSpec) Line 2300     C++
        ocgen.exe!`anonymous
namespace'::MicrosoftCXXNameMangler::mangleFunctionEncoding(const
clang::FunctionDecl * FD, bool ShouldMangle) Line 533    C++
        ocgen.exe!`anonymous namespace'::MicrosoftCXXNameMangler::mangle(const
clang::NamedDecl * D, llvm::StringRef Prefix) Line 499   C++
        ocgen.exe!`anonymous
namespace'::MicrosoftMangleContextImpl::mangleCXXName(const clang::NamedDecl *
D, llvm::raw_ostream & Out) Line 2965       C++
        ocgen.exe!clang::MangleContext::mangleName(const clang::NamedDecl * D,
llvm::raw_ostream & Out) Line 153        C++
<trim></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>