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 | c0325032744d900d8648b10e0a2b2e9251c8d1d5 (patch) | |
| tree | 40f5858c74ccd3aad24f4cd79c2fd0e85acbf472 /clang/lib/Frontend | |
| parent | 719393a56ba26d0c302a7691ae2b34b2fd675c3a (diff) | |
| download | bcm5719-llvm-c0325032744d900d8648b10e0a2b2e9251c8d1d5.tar.gz bcm5719-llvm-c0325032744d900d8648b10e0a2b2e9251c8d1d5.zip | |
Fronted/CC_LOG_DIAGNOSTICS: Output main file name, and add support for
outputting dwarf-debug-flags.
llvm-svn: 129094
Diffstat (limited to 'clang/lib/Frontend')
| -rw-r--r-- | clang/lib/Frontend/LogDiagnosticPrinter.cpp | 21 |
1 files changed, 19 insertions, 2 deletions
diff --git a/clang/lib/Frontend/LogDiagnosticPrinter.cpp b/clang/lib/Frontend/LogDiagnosticPrinter.cpp index 9eee843dbe5..954bad4e7c5 100644 --- a/clang/lib/Frontend/LogDiagnosticPrinter.cpp +++ b/clang/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(); |

