summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2013-06-20 21:17:24 +0000
committerAdrian Prantl <aprantl@apple.com>2013-06-20 21:17:24 +0000
commitdba725c0bef93923437d4c6d5ab75896d604c4ba (patch)
treee244112a40e3ed27f5a562c70da82f69ff7d00fa /clang/lib/CodeGen
parent2cd24bd52d090bc9454c56fa19592a2a2acac58c (diff)
downloadbcm5719-llvm-dba725c0bef93923437d4c6d5ab75896d604c4ba.tar.gz
bcm5719-llvm-dba725c0bef93923437d4c6d5ab75896d604c4ba.zip
Debug Info: Attempt to resolve forward declarations if we are not emitting
limited debug info. This is another small addendum to r184252. rdar://problem/14101097 llvm-svn: 184473
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp29
1 files changed, 27 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index 8240c0846d5..f8c814cb94f 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -1886,6 +1886,22 @@ llvm::DIType CGDebugInfo::getTypeOrNull(QualType Ty) {
return llvm::DIType();
}
+/// ContainsFwdDecl - True if Ty is either a forward declaration or a
+/// derived type of a forward declaration.
+static bool ContainsFwdDecl(llvm::DIType Ty) {
+ // Composite types such as structs inherit from DIDerivedType, so
+ // check this first and do an early exit.
+ if (Ty.isForwardDecl())
+ return true;
+
+ if (Ty.isDerivedType()) {
+ llvm::DIDerivedType DTy(Ty);
+ return ContainsFwdDecl(DTy.getTypeDerivedFrom());
+ }
+
+ return false;
+}
+
/// getCompletedTypeOrNull - Get the type from the cache or return null if it
/// doesn't exist.
llvm::DIType CGDebugInfo::getCompletedTypeOrNull(QualType Ty) {
@@ -1904,8 +1920,17 @@ llvm::DIType CGDebugInfo::getCompletedTypeOrNull(QualType Ty) {
}
// Verify that any cached debug info still exists.
- if (V != 0)
- return llvm::DIType(cast<llvm::MDNode>(V));
+ if (V != 0) {
+ llvm::DIType CachedType(cast<llvm::MDNode>(V));
+
+ // Unless we are limiting debug info, attempt to resolve any
+ // forward declarations.
+ if (DebugKind > CodeGenOptions::LimitedDebugInfo &&
+ ContainsFwdDecl(CachedType))
+ return llvm::DIType();
+
+ return CachedType;
+ }
return llvm::DIType();
}
OpenPOWER on IntegriCloud