mirror of https://github.com/microsoft/clang.git
[codeview] Emit nested enums and typedefs from classes
Previously we limited ourselves to only emitting nested classes, but we need other kinds of types as well. This fixes the Visual Studio STL visualizers, so that users can visualize std::string and other objects. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@310410 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
350d0498a4
commit
9452fead78
|
@ -1183,13 +1183,13 @@ void CGDebugInfo::CollectRecordNormalField(
|
|||
elements.push_back(FieldType);
|
||||
}
|
||||
|
||||
void CGDebugInfo::CollectRecordNestedRecord(
|
||||
const RecordDecl *RD, SmallVectorImpl<llvm::Metadata *> &elements) {
|
||||
QualType Ty = CGM.getContext().getTypeDeclType(RD);
|
||||
void CGDebugInfo::CollectRecordNestedType(
|
||||
const TypeDecl *TD, SmallVectorImpl<llvm::Metadata *> &elements) {
|
||||
QualType Ty = CGM.getContext().getTypeDeclType(TD);
|
||||
// Injected class names are not considered nested records.
|
||||
if (isa<InjectedClassNameType>(Ty))
|
||||
return;
|
||||
SourceLocation Loc = RD->getLocation();
|
||||
SourceLocation Loc = TD->getLocation();
|
||||
llvm::DIType *nestedType = getOrCreateType(Ty, getOrCreateFile(Loc));
|
||||
elements.push_back(nestedType);
|
||||
}
|
||||
|
@ -1205,9 +1205,9 @@ void CGDebugInfo::CollectRecordFields(
|
|||
else {
|
||||
const ASTRecordLayout &layout = CGM.getContext().getASTRecordLayout(record);
|
||||
|
||||
// Debug info for nested records is included in the member list only for
|
||||
// Debug info for nested types is included in the member list only for
|
||||
// CodeView.
|
||||
bool IncludeNestedRecords = CGM.getCodeGenOpts().EmitCodeView;
|
||||
bool IncludeNestedTypes = CGM.getCodeGenOpts().EmitCodeView;
|
||||
|
||||
// Field number for non-static fields.
|
||||
unsigned fieldNo = 0;
|
||||
|
@ -1234,10 +1234,12 @@ void CGDebugInfo::CollectRecordFields(
|
|||
|
||||
// Bump field number for next field.
|
||||
++fieldNo;
|
||||
} else if (const auto *nestedRec = dyn_cast<CXXRecordDecl>(I))
|
||||
if (IncludeNestedRecords && !nestedRec->isImplicit() &&
|
||||
nestedRec->getDeclContext() == record)
|
||||
CollectRecordNestedRecord(nestedRec, elements);
|
||||
} else if (IncludeNestedTypes) {
|
||||
if (const auto *nestedType = dyn_cast<TypeDecl>(I))
|
||||
if (!nestedType->isImplicit() &&
|
||||
nestedType->getDeclContext() == record)
|
||||
CollectRecordNestedType(nestedType, elements);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -278,8 +278,8 @@ class CGDebugInfo {
|
|||
llvm::DIFile *F,
|
||||
SmallVectorImpl<llvm::Metadata *> &E,
|
||||
llvm::DIType *RecordTy, const RecordDecl *RD);
|
||||
void CollectRecordNestedRecord(const RecordDecl *RD,
|
||||
SmallVectorImpl<llvm::Metadata *> &E);
|
||||
void CollectRecordNestedType(const TypeDecl *RD,
|
||||
SmallVectorImpl<llvm::Metadata *> &E);
|
||||
void CollectRecordFields(const RecordDecl *Decl, llvm::DIFile *F,
|
||||
SmallVectorImpl<llvm::Metadata *> &E,
|
||||
llvm::DICompositeType *RecordTy);
|
||||
|
|
|
@ -0,0 +1,25 @@
|
|||
// RUN: %clang_cc1 %s -std=c++11 -triple=x86_64-pc-windows-msvc -debug-info-kind=limited -gcodeview -emit-llvm -o - | FileCheck %s
|
||||
|
||||
struct HasNested {
|
||||
enum InnerEnum { _BUF_SIZE = 1 };
|
||||
typedef int InnerTypedef;
|
||||
enum { InnerEnumerator = 2 };
|
||||
struct InnerStruct { };
|
||||
};
|
||||
HasNested f;
|
||||
|
||||
// CHECK: ![[INNERENUM:[0-9]+]] = !DICompositeType(tag: DW_TAG_enumeration_type, name: "InnerEnum", {{.*}})
|
||||
// CHECK: ![[HASNESTED:[0-9]+]] = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "HasNested",
|
||||
// CHECK-SAME: elements: ![[MEMBERS:[0-9]+]],
|
||||
//
|
||||
// CHECK: ![[MEMBERS]] = !{![[INNERENUM]], ![[INNERTYPEDEF:[0-9]+]], ![[UNNAMEDENUM:[0-9]+]], ![[INNERSTRUCT:[0-9]+]]}
|
||||
//
|
||||
// CHECK: ![[INNERTYPEDEF]] = !DIDerivedType(tag: DW_TAG_typedef, name: "InnerTypedef", scope: ![[HASNESTED]]{{.*}})
|
||||
//
|
||||
// CHECK: ![[UNNAMEDENUM]] = !DICompositeType(tag: DW_TAG_enumeration_type, scope: ![[HASNESTED]],
|
||||
// CHECK-SAME: elements: ![[UNNAMEDMEMBERS:[0-9]+]],
|
||||
// CHECK: ![[UNNAMEDMEMBERS]] = !{![[INNERENUMERATOR:[0-9]+]]}
|
||||
// CHECK: ![[INNERENUMERATOR]] = !DIEnumerator(name: "InnerEnumerator", value: 2)
|
||||
//
|
||||
// CHECK: ![[INNERSTRUCT]] = !DICompositeType(tag: DW_TAG_structure_type, name: "InnerStruct"
|
||||
// CHECK-SAME: flags: DIFlagFwdDecl
|
Loading…
Reference in New Issue