Index: lib/CodeGen/CGDeclCXX.cpp =================================================================== --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -64,10 +64,19 @@ /// static storage duration. static void EmitDeclDestroy(CodeGenFunction &CGF, const VarDecl &D, ConstantAddress addr) { - CodeGenModule &CGM = CGF.CGM; + // Workaround for a bug that causes a reference to a nonexistent + // destructor under odd circumstances, when attribute no_destroy + // is used. This code should not be reachable under normal + // circumstances, this workaround simply checks for the attribute + // again and bails if it's present instead of following a path + // that's either going to assert or emit incorrect code if reached. + if (D.hasAttr()) + return; // FIXME: __attribute__((cleanup)) ? + CodeGenModule &CGM = CGF.CGM; + QualType type = D.getType(); QualType::DestructionKind dtorKind = type.isDestructedType();