aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp')
-rw-r--r--llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp43
1 files changed, 37 insertions, 6 deletions
diff --git a/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp b/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp
index f31d625..06ead92 100644
--- a/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp
+++ b/llvm/lib/Analysis/ModuleDebugInfoPrinter.cpp
@@ -43,13 +43,19 @@ static void printModuleDebugInfo(raw_ostream &O, const Module *M,
// filenames), so just print a few useful things.
for (DICompileUnit *CU : Finder.compile_units()) {
O << "Compile unit: ";
- auto Lang =
- dwarf::LanguageString(CU->getSourceLanguage().getUnversionedName());
- if (!Lang.empty())
- O << Lang;
+
+ DISourceLanguageName Lang = CU->getSourceLanguage();
+ auto LangStr =
+ Lang.hasVersionedName()
+ ? dwarf::SourceLanguageNameString(
+ static_cast<llvm::dwarf::SourceLanguageName>(Lang.getName()))
+ : dwarf::LanguageString(Lang.getName());
+
+ if (!LangStr.empty())
+ O << LangStr;
else
- O << "unknown-language(" << CU->getSourceLanguage().getUnversionedName()
- << ")";
+ O << "unknown-language(" << CU->getSourceLanguage().getName() << ")";
+
printFile(O, CU->getFilename(), CU->getDirectory());
O << '\n';
}
@@ -97,6 +103,31 @@ static void printModuleDebugInfo(raw_ostream &O, const Module *M,
}
O << '\n';
}
+
+ for (const auto &MacroEntry : Finder.macros()) {
+ const DIMacro *Macro = MacroEntry.first;
+ const DIMacroFile *MacroFile = MacroEntry.second;
+
+ O << "Macro: ";
+ auto MacroType = dwarf::MacinfoString(Macro->getMacinfoType());
+ if (!MacroType.empty())
+ O << MacroType;
+ else
+ O << "unknown-macinfo(" << Macro->getMacinfoType() << ")";
+
+ O << " '" << Macro->getName() << "'";
+ if (!Macro->getValue().empty())
+ O << " = '" << Macro->getValue() << "'";
+
+ if (MacroFile && MacroFile->getFile()) {
+ const DIFile *File = MacroFile->getFile();
+ printFile(O, File->getFilename(), File->getDirectory(),
+ MacroFile->getLine());
+ } else {
+ O << " at line " << Macro->getLine();
+ }
+ O << '\n';
+ }
}
ModuleDebugInfoPrinterPass::ModuleDebugInfoPrinterPass(raw_ostream &OS)