Index: lib/AST/ItaniumMangle.cpp =================================================================== --- lib/AST/ItaniumMangle.cpp +++ lib/AST/ItaniumMangle.cpp @@ -1323,9 +1323,16 @@ } if (const VarDecl *VD = dyn_cast(ND)) { + + QualType valDecl = VD->getType(); + if (valDecl.isNull()) + break; + + const RecordType* RT = VD->getType()->getAs(); + 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: //