summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp38
1 files changed, 28 insertions, 10 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index c0a3db4d61b..6af8d6626b4 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -28,6 +28,7 @@
#include "clang/Basic/Version.h"
#include "clang/Frontend/CodeGenOptions.h"
#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/ModuleMap.h"
#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
@@ -2159,17 +2160,34 @@ ObjCInterfaceDecl *CGDebugInfo::getObjCInterfaceDecl(QualType Ty) {
}
llvm::DIModule *CGDebugInfo::getParentModuleOrNull(const Decl *D) {
- if (!DebugTypeExtRefs || !D->isFromASTFile())
- return nullptr;
+ ExternalASTSource::ASTSourceDescriptor Info;
+ if (ClangModuleMap) {
+ // We are building a clang module or a precompiled header.
+ //
+ // TODO: When D is a CXXRecordDecl or a C++ Enum, the ODR applies
+ // and it wouldn't be necessary to specify the parent scope
+ // because the type is already unique by definition (it would look
+ // like the output of -fno-standalone-debug). On the other hand,
+ // the parent scope helps a consumer to quickly locate the object
+ // file where the type's definition is located, so it might be
+ // best to make this behavior a command line or debugger tuning
+ // option.
+ FullSourceLoc Loc(D->getLocation(), CGM.getContext().getSourceManager());
+ if (Module *M = ClangModuleMap->inferModuleFromLocation(Loc)) {
+ auto Info = ExternalASTSource::ASTSourceDescriptor(*M);
+ return getOrCreateModuleRef(Info, /*SkeletonCU=*/false);
+ }
+ }
- // Record a reference to an imported clang module or precompiled header.
- llvm::DIModule *ModuleRef = nullptr;
- auto *Reader = CGM.getContext().getExternalSource();
- auto Idx = D->getOwningModuleID();
- auto Info = Reader->getSourceDescriptor(Idx);
- if (Info)
- ModuleRef = getOrCreateModuleRef(*Info, true);
- return ModuleRef;
+ if (DebugTypeExtRefs && D->isFromASTFile()) {
+ // Record a reference to an imported clang module or precompiled header.
+ auto *Reader = CGM.getContext().getExternalSource();
+ auto Idx = D->getOwningModuleID();
+ auto Info = Reader->getSourceDescriptor(Idx);
+ if (Info)
+ return getOrCreateModuleRef(*Info, /*SkeletonCU=*/true);
+ }
+ return nullptr;
}
llvm::DIType *CGDebugInfo::CreateTypeNode(QualType Ty, llvm::DIFile *Unit) {
OpenPOWER on IntegriCloud