diff options
author | Aaron Smith <aaron.smith@microsoft.com> | 2018-10-02 20:28:15 +0000 |
---|---|---|
committer | Aaron Smith <aaron.smith@microsoft.com> | 2018-10-02 20:28:15 +0000 |
commit | da0602c15431ce8966545c8377c3ed726b97aa18 (patch) | |
tree | 24355ee9644b1f34a701aac499739ddf8e3d4e0d /llvm/lib/CodeGen/AsmPrinter | |
parent | 802b033d78b50a9824be32c78cc78a89ae7ac2c2 (diff) | |
download | bcm5719-llvm-da0602c15431ce8966545c8377c3ed726b97aa18.tar.gz bcm5719-llvm-da0602c15431ce8966545c8377c3ed726b97aa18.zip |
[CodeView] Only add the Scoped flag for an enum type when it has an immediate function scope to match MSVC
Reviewers: rnk, zturner, llvm-commits
Reviewed By: rnk
Differential Revision: https://reviews.llvm.org/D52706
llvm-svn: 343627
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r-- | llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp | 18 |
1 files changed, 13 insertions, 5 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp index ad957f3f450..4d45a103c5a 100644 --- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp @@ -1931,12 +1931,20 @@ static ClassOptions getCommonClassOptions(const DICompositeType *Ty) { if (ImmediateScope && isa<DICompositeType>(ImmediateScope)) CO |= ClassOptions::Nested; - // Put the Scoped flag on function-local types. - for (const DIScope *Scope = ImmediateScope; Scope != nullptr; - Scope = Scope->getScope().resolve()) { - if (isa<DISubprogram>(Scope)) { + // Put the Scoped flag on function-local types. MSVC puts this flag for enum + // type only when it has an immediate function scope. Clang never puts enums + // inside DILexicalBlock scopes. Enum types, as generated by clang, are + // always in function, class, or file scopes. + if (Ty->getTag() == dwarf::DW_TAG_enumeration_type) { + if (ImmediateScope && isa<DISubprogram>(ImmediateScope)) CO |= ClassOptions::Scoped; - break; + } else { + for (const DIScope *Scope = ImmediateScope; Scope != nullptr; + Scope = Scope->getScope().resolve()) { + if (isa<DISubprogram>(Scope)) { + CO |= ClassOptions::Scoped; + break; + } } } |