DebugInfo: Give externally defined types a size and alignment where

possible. Fixes PR22736.

llvm-svn: 230914
This commit is contained in:
Peter Collingbourne 2015-03-01 22:07:04 +00:00
parent 3c63d666a3
commit d251b0a60e
2 changed files with 17 additions and 1 deletions

View File

@ -647,11 +647,19 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
unsigned Line = getLineNumber(RD->getLocation()); unsigned Line = getLineNumber(RD->getLocation());
StringRef RDName = getClassName(RD); StringRef RDName = getClassName(RD);
uint64_t Size = 0;
uint64_t Align = 0;
const RecordDecl *D = RD->getDefinition();
if (D && D->isCompleteDefinition()) {
Size = CGM.getContext().getTypeSize(Ty);
Align = CGM.getContext().getTypeAlign(Ty);
}
// Create the type. // Create the type.
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU); SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
llvm::DICompositeType RetTy = DBuilder.createReplaceableCompositeType( llvm::DICompositeType RetTy = DBuilder.createReplaceableCompositeType(
getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, 0, 0, getTagForRecord(RD), RDName, Ctx, DefUnit, Line, 0, Size, Align,
llvm::DIDescriptor::FlagFwdDecl, FullName); llvm::DIDescriptor::FlagFwdDecl, FullName);
ReplaceMap.emplace_back( ReplaceMap.emplace_back(
std::piecewise_construct, std::make_tuple(Ty), std::piecewise_construct, std::make_tuple(Ty),

View File

@ -99,3 +99,11 @@ template <>
struct k<int>; struct k<int>;
template struct k<int>; template struct k<int>;
// CHECK-NOT: ; [ DW_TAG_structure_type ] [k<int>] // CHECK-NOT: ; [ DW_TAG_structure_type ] [k<int>]
template <typename T>
struct l {
int x;
};
extern template class l<int>;
l<int> li;
// CHECK: [ DW_TAG_structure_type ] [l<int>] {{.*}}size {{[^0]}}