diff options
author | Daniel Dunbar <daniel@zuster.org> | 2011-04-07 18:51:54 +0000 |
---|---|---|
committer | Daniel Dunbar <daniel@zuster.org> | 2011-04-07 18:51:54 +0000 |
commit | 28f14933edc863821e4f2ffa3663835c62440dcb (patch) | |
tree | 9de3193b23ff5b49f2b2593eb03050eb64ed24cd /lib/Frontend/LogDiagnosticPrinter.cpp | |
parent | 5dccf575ad0b45a268d4026047234a6872440c95 (diff) |
Fronted/CC_LOG_DIAGNOSTICS: Output main file name, and add support for
outputting dwarf-debug-flags.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@129094 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Frontend/LogDiagnosticPrinter.cpp')
-rw-r--r-- | lib/Frontend/LogDiagnosticPrinter.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/lib/Frontend/LogDiagnosticPrinter.cpp b/lib/Frontend/LogDiagnosticPrinter.cpp index 9eee843dbe..954bad4e7c 100644 --- a/lib/Frontend/LogDiagnosticPrinter.cpp +++ b/lib/Frontend/LogDiagnosticPrinter.cpp @@ -53,8 +53,14 @@ void LogDiagnosticPrinter::EndSourceFile() { llvm::raw_svector_ostream OS(Msg); OS << "<dict>\n"; - // FIXME: Output main translation unit file name. - // FIXME: Include the invocation, if dwarf-debug-flags is available. + if (!MainFilename.empty()) { + OS << " <key>main-file</key>\n" + << " <string>" << MainFilename << "</string>\n"; + } + if (!DwarfDebugFlags.empty()) { + OS << " <key>dwarf-debug-flags</key>\n" + << " <string>" << DwarfDebugFlags << "</string>\n"; + } OS << " <key>diagnostics</key>\n"; OS << " <array>\n"; for (unsigned i = 0, e = Entries.size(); i != e; ++i) { @@ -92,6 +98,17 @@ void LogDiagnosticPrinter::HandleDiagnostic(Diagnostic::Level Level, // Default implementation (Warnings/errors count). DiagnosticClient::HandleDiagnostic(Level, Info); + // Initialize the main file name, if we haven't already fetched it. + if (MainFilename.empty()) { + const SourceManager &SM = Info.getSourceManager(); + FileID FID = SM.getMainFileID(); + if (!FID.isInvalid()) { + const FileEntry *FE = SM.getFileEntryForID(FID); + if (FE && FE->getName()) + MainFilename = FE->getName(); + } + } + // Create the diag entry. DiagEntry DE; DE.DiagnosticID = Info.getID(); |