PR16214, PR14467: DebugInfo: use "RequireCompleteType" to decide when to emit the full definition of a type in -flimit-debug-info
This simplifies the core benefit of -flimit-debug-info by taking a more
systematic approach to avoid emitting debug info definitions for types
that only require declarations. The previous ad-hoc approach (3 cases
removed in this patch) had many holes.
The general approach (adding a bit to TagDecl and callback through
ASTConsumer) has been discussed with Richard Smith - though always open
to revision.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@186262 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index 11149f4..4c27546 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -1379,7 +1379,8 @@
RecordDecl *RD = Ty->getDecl();
// Limited debug info should only remove struct definitions that can
// safely be replaced by a forward declaration in the source code.
- if (DebugKind <= CodeGenOptions::LimitedDebugInfo && Declaration) {
+ if (DebugKind <= CodeGenOptions::LimitedDebugInfo && Declaration &&
+ !RD->isCompleteDefinitionRequired()) {
// FIXME: This implementation is problematic; there are some test
// cases where we violate the above principle, such as
// test/CodeGen/debug-info-records.c .