DebugInfo: Give externally defined types a size and alignment where
possible. Fixes PR22736. llvm-svn: 230914
This commit is contained in:
parent
3c63d666a3
commit
d251b0a60e
|
@ -647,11 +647,19 @@ CGDebugInfo::getOrCreateRecordFwdDecl(const RecordType *Ty,
|
|||
unsigned Line = getLineNumber(RD->getLocation());
|
||||
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.
|
||||
SmallString<256> FullName = getUniqueTagTypeName(Ty, CGM, TheCU);
|
||||
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);
|
||||
ReplaceMap.emplace_back(
|
||||
std::piecewise_construct, std::make_tuple(Ty),
|
||||
|
|
|
@ -99,3 +99,11 @@ template <>
|
|||
struct k<int>;
|
||||
template struct 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]}}
|
||||
|
|
Loading…
Reference in New Issue