summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGDebugInfo.cpp
diff options
context:
space:
mode:
authorAdrian Prantl <aprantl@apple.com>2015-06-30 17:39:51 +0000
committerAdrian Prantl <aprantl@apple.com>2015-06-30 17:39:51 +0000
commitc4bb47e301c4d4902f6ddf6d1ec92d2213d23095 (patch)
tree6d58f7c6ebdea7feb9684b636245257be0bdecc7 /clang/lib/CodeGen/CGDebugInfo.cpp
parent15bcf70cdf843d3070af3e811b7b0412b55e9500 (diff)
downloadbcm5719-llvm-c4bb47e301c4d4902f6ddf6d1ec92d2213d23095.tar.gz
bcm5719-llvm-c4bb47e301c4d4902f6ddf6d1ec92d2213d23095.zip
Debug Info: Emit debug info for @import declarations.
This allows a module-aware debugger such as LLDB to import the currently visible modules before dropping into the expression evaluator. rdar://problem/20965932 llvm-svn: 241084
Diffstat (limited to 'clang/lib/CodeGen/CGDebugInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGDebugInfo.cpp54
1 files changed, 54 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGDebugInfo.cpp b/clang/lib/CodeGen/CGDebugInfo.cpp
index a139ce0e073..8daf8af4e18 100644
--- a/clang/lib/CodeGen/CGDebugInfo.cpp
+++ b/clang/lib/CodeGen/CGDebugInfo.cpp
@@ -27,6 +27,8 @@
#include "clang/Basic/SourceManager.h"
#include "clang/Basic/Version.h"
#include "clang/Frontend/CodeGenOptions.h"
+#include "clang/Lex/HeaderSearchOptions.h"
+#include "clang/Lex/PreprocessorOptions.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/IR/Constants.h"
@@ -1661,6 +1663,49 @@ llvm::DIType *CGDebugInfo::CreateType(const ObjCInterfaceType *Ty,
return CreateTypeDefinition(Ty, Unit);
}
+llvm::DIModule *
+CGDebugInfo::getOrCreateModuleRef(ExternalASTSource::ASTSourceDescriptor Mod) {
+ llvm::DIModule *ModuleRef = nullptr;
+ auto it = ModuleRefCache.find(Mod.Signature);
+ if (it != ModuleRefCache.end())
+ ModuleRef = it->second;
+ else {
+ // Macro definitions that were defined with "-D" on the command line.
+ SmallString<128> ConfigMacros;
+ {
+ llvm::raw_svector_ostream OS(ConfigMacros);
+ const auto &PPOpts = CGM.getPreprocessorOpts();
+ unsigned I = 0;
+ // Translate the macro definitions back into a commmand line.
+ for (auto &M : PPOpts.Macros) {
+ if (++I > 1)
+ OS << " ";
+ const std::string &Macro = M.first;
+ bool Undef = M.second;
+ OS << "\"-" << (Undef ? 'U' : 'D');
+ for (char c : Macro)
+ switch (c) {
+ case '\\' : OS << "\\\\"; break;
+ case '"' : OS << "\\\""; break;
+ default: OS << c;
+ }
+ OS << '\"';
+ }
+ }
+ llvm::DIBuilder DIB(CGM.getModule());
+ auto *CU = DIB.createCompileUnit(
+ TheCU->getSourceLanguage(), internString(Mod.ModuleName),
+ internString(Mod.Path), TheCU->getProducer(), true, StringRef(), 0,
+ internString(Mod.ASTFile), llvm::DIBuilder::FullDebug, Mod.Signature);
+ ModuleRef = DIB.createModule(
+ CU, Mod.ModuleName, ConfigMacros, internString(Mod.Path),
+ internString(CGM.getHeaderSearchOpts().Sysroot));
+ DIB.finalize();
+ ModuleRefCache.insert(std::make_pair(Mod.Signature, ModuleRef));
+ }
+ return ModuleRef;
+}
+
llvm::DIType *CGDebugInfo::CreateTypeDefinition(const ObjCInterfaceType *Ty,
llvm::DIFile *Unit) {
ObjCInterfaceDecl *ID = Ty->getDecl();
@@ -3304,6 +3349,15 @@ void CGDebugInfo::EmitUsingDecl(const UsingDecl &UD) {
getLineNumber(USD.getLocation()));
}
+void CGDebugInfo::EmitImportDecl(const ImportDecl &ID) {
+ auto *Reader = CGM.getContext().getExternalSource();
+ auto Info = Reader->getSourceDescriptor(*ID.getImportedModule());
+ DBuilder.createImportedDeclaration(
+ getCurrentContextDescriptor(cast<Decl>(ID.getDeclContext())),
+ getOrCreateModuleRef(Info),
+ getLineNumber(ID.getLocation()));
+}
+
llvm::DIImportedEntity *
CGDebugInfo::EmitNamespaceAlias(const NamespaceAliasDecl &NA) {
if (CGM.getCodeGenOpts().getDebugInfo() < CodeGenOptions::LimitedDebugInfo)
OpenPOWER on IntegriCloud