aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGDecl.cpp
diff options
context:
space:
mode:
authorNick Desaulniers <ndesaulniers@google.com>2020-08-10 14:52:37 -0700
committerNick Desaulniers <ndesaulniers@google.com>2020-08-10 15:08:48 -0700
commit4f2ad15db535873dda9bfe248a2771023b64a43c (patch)
treeac5ca03af28af9e704aed843d2dbe730687b6a85 /clang/lib/CodeGen/CGDecl.cpp
parent41d4120017f99386a62a9c0aac25fd2a369d0e02 (diff)
downloadllvm-4f2ad15db535873dda9bfe248a2771023b64a43c.zip
llvm-4f2ad15db535873dda9bfe248a2771023b64a43c.tar.gz
llvm-4f2ad15db535873dda9bfe248a2771023b64a43c.tar.bz2
[Clang] implement -fno-eliminate-unused-debug-types
Fixes pr/11710. Signed-off-by: Nick Desaulniers <ndesaulniers@google.com> Resubmit after breaking Windows and OSX builds. Reviewed By: dblaikie Differential Revision: https://reviews.llvm.org/D80242
Diffstat (limited to 'clang/lib/CodeGen/CGDecl.cpp')
-rw-r--r--clang/lib/CodeGen/CGDecl.cpp19
1 files changed, 13 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGDecl.cpp b/clang/lib/CodeGen/CGDecl.cpp
index 1729c7ed..0ad5050 100644
--- a/clang/lib/CodeGen/CGDecl.cpp
+++ b/clang/lib/CodeGen/CGDecl.cpp
@@ -100,11 +100,19 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
case Decl::ObjCTypeParam:
case Decl::Binding:
llvm_unreachable("Declaration should not be in declstmts!");
- case Decl::Function: // void X();
case Decl::Record: // struct/union/class X;
+ case Decl::CXXRecord: // struct/union/class X; [C++]
+ if (CGDebugInfo *DI = getDebugInfo())
+ if (cast<RecordDecl>(D).getDefinition())
+ DI->EmitAndRetainType(getContext().getRecordType(cast<RecordDecl>(&D)));
+ return;
case Decl::Enum: // enum X;
+ if (CGDebugInfo *DI = getDebugInfo())
+ if (cast<EnumDecl>(D).getDefinition())
+ DI->EmitAndRetainType(getContext().getEnumType(cast<EnumDecl>(&D)));
+ return;
+ case Decl::Function: // void X();
case Decl::EnumConstant: // enum ? { X = ? }
- case Decl::CXXRecord: // struct/union/class X; [C++]
case Decl::StaticAssert: // static_assert(X, ""); [C++0x]
case Decl::Label: // __label__ x;
case Decl::Import:
@@ -157,12 +165,11 @@ void CodeGenFunction::EmitDecl(const Decl &D) {
case Decl::Typedef: // typedef int X;
case Decl::TypeAlias: { // using X = int; [C++0x]
- const TypedefNameDecl &TD = cast<TypedefNameDecl>(D);
- QualType Ty = TD.getUnderlyingType();
-
+ QualType Ty = cast<TypedefNameDecl>(D).getUnderlyingType();
+ if (CGDebugInfo *DI = getDebugInfo())
+ DI->EmitAndRetainType(Ty);
if (Ty->isVariablyModifiedType())
EmitVariablyModifiedType(Ty);
-
return;
}
}