Index: lib/CodeGen/CGDeclCXX.cpp =================================================================== --- lib/CodeGen/CGDeclCXX.cpp +++ lib/CodeGen/CGDeclCXX.cpp @@ -68,6 +68,16 @@ // FIXME: __attribute__((cleanup)) ? + // 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; + } + QualType type = D.getType(); QualType::DestructionKind dtorKind = type.isDestructedType();