Index: clang/lib/AST/ItaniumMangle.cpp =================================================================== --- clang/lib/AST/ItaniumMangle.cpp +++ clang/lib/AST/ItaniumMangle.cpp @@ -1317,9 +1317,13 @@ } if (const VarDecl *VD = dyn_cast(ND)) { + const RecordType* RT = VD->getType()->getAs(); + // FIXME:(jbcoe) find out why this check is needed. + if (!RT) + break; + // We must have an anonymous union or struct declaration. - const RecordDecl *RD = - cast(VD->getType()->getAs()->getDecl()); + const RecordDecl *RD = cast(RT->getDecl()); // Itanium C++ ABI 5.1.2: // Index: mangled-names-crash.py =================================================================== --- /dev/null +++ mangled-names-crash.py @@ -0,0 +1,20 @@ +from __future__ import print_function + +import clang.cindex + + +def traverse(node): + print('L:', node.location.line, node.spelling, node.type.spelling, node.mangled_name) + for child in node.get_children(): + traverse(child) + +with open('test.cpp', 'w') as o: + o.write('''struct S { + void(*g)(void); + void(*f)(void*); +}; +''') + +index = clang.cindex.Index.create() +tu = index.parse('test.cpp', args=['-Werror']) +traverse(tu.cursor)