Start down the path of getting clang to internally agree on structs versus
classes.
Part of rdar://10520586 and a couple others.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@146778 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index fa057e2..dd76640 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -499,7 +499,12 @@
llvm::DIDescriptor FDContext =
getContextDescriptor(cast<Decl>(RD->getDeclContext()));
- if (RD->isStruct())
+ CXXRecordDecl *CXXDecl = dyn_cast<CXXRecordDecl>(RD);
+ if (CXXDecl)
+ return DBuilder.createClassType(FDContext, RD->getName(), DefUnit,
+ Line, 0, 0, 0, llvm::DIType::FlagFwdDecl,
+ llvm::DIType(), llvm::DIArray());
+ else if (RD->isStruct())
return DBuilder.createStructType(FDContext, RD->getName(), DefUnit,
Line, 0, 0, llvm::DIType::FlagFwdDecl,
llvm::DIArray());
@@ -507,12 +512,8 @@
return DBuilder.createUnionType(FDContext, RD->getName(), DefUnit,
Line, 0, 0, llvm::DIType::FlagFwdDecl,
llvm::DIArray());
- else {
- assert(RD->isClass() && "Unknown RecordType!");
- return DBuilder.createClassType(FDContext, RD->getName(), DefUnit,
- Line, 0, 0, 0, llvm::DIType::FlagFwdDecl,
- llvm::DIType(), llvm::DIArray());
- }
+ else
+ llvm_unreachable("Unknown RecordDecl type!");
}
return getOrCreateType(PointeeTy, Unit);
@@ -1175,11 +1176,13 @@
else if (CXXDecl->isDynamicClass())
ContainingType = FwdDecl;
- RealDecl = DBuilder.createClassType(RDContext, RDName, DefUnit, Line,
- Size, Align, 0, 0, llvm::DIType(),
- Elements, ContainingType,
- TParamsArray);
- } else
+ // FIXME: This could be a struct type giving a default visibility different
+ // than C++ class type, but needs llvm metadata changes first.
+ RealDecl = DBuilder.createClassType(RDContext, RDName, DefUnit, Line,
+ Size, Align, 0, 0, llvm::DIType(),
+ Elements, ContainingType,
+ TParamsArray);
+ } else
RealDecl = DBuilder.createStructType(RDContext, RDName, DefUnit, Line,
Size, Align, 0, Elements);