From ea225fb41269eb0a8c6bcb1f7778d23a8881c526 Mon Sep 17 00:00:00 2001 From: Eric Christopher Date: Fri, 16 Dec 2011 23:40:14 +0000 Subject: Start down the path of getting clang to internally agree on structs versus classes. Part of rdar://10520586 and a couple others. llvm-svn: 146778 --- clang/lib/CodeGen/CGDebugInfo.cpp | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) (limited to 'clang/lib/CodeGen') diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp index fa057e2e4be..dd76640ba3d 100644 --- a/clang/lib/CodeGen/CGDebugInfo.cpp +++ b/clang/lib/CodeGen/CGDebugInfo.cpp @@ -499,7 +499,12 @@ llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy, llvm::DIDescriptor FDContext = getContextDescriptor(cast(RD->getDeclContext())); - if (RD->isStruct()) + CXXRecordDecl *CXXDecl = dyn_cast(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 @@ llvm::DIType CGDebugInfo::CreatePointeeType(QualType PointeeTy, 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 @@ llvm::DIType CGDebugInfo::CreateType(const RecordType *Ty) { 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); -- cgit v1.2.3