[cfe-commits] r129094 - in /cfe/trunk: include/clang/Frontend/LogDiagnosticPrinter.h lib/Frontend/LogDiagnosticPrinter.cpp
Daniel Dunbar
daniel at zuster.org
Thu Apr 7 11:51:54 PDT 2011
Author: ddunbar
Date: Thu Apr 7 13:51:54 2011
New Revision: 129094
URL: http://llvm.org/viewvc/llvm-project?rev=129094&view=rev
Log:
Fronted/CC_LOG_DIAGNOSTICS: Output main file name, and add support for
outputting dwarf-debug-flags.
Modified:
cfe/trunk/include/clang/Frontend/LogDiagnosticPrinter.h
cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp
Modified: cfe/trunk/include/clang/Frontend/LogDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/LogDiagnosticPrinter.h?rev=129094&r1=129093&r2=129094&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/LogDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Frontend/LogDiagnosticPrinter.h Thu Apr 7 13:51:54 2011
@@ -12,6 +12,7 @@
#include "clang/Basic/Diagnostic.h"
#include "clang/Basic/SourceLocation.h"
+#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/SmallVector.h"
namespace clang {
@@ -49,11 +50,18 @@
llvm::SmallVector<DiagEntry, 8> Entries;
+ std::string MainFilename;
+ std::string DwarfDebugFlags;
+
public:
LogDiagnosticPrinter(llvm::raw_ostream &OS, const DiagnosticOptions &Diags,
bool OwnsOutputStream = false);
virtual ~LogDiagnosticPrinter();
+ void setDwarfDebugFlags(llvm::StringRef Value) {
+ DwarfDebugFlags = Value;
+ }
+
void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) {
LangOpts = &LO;
}
Modified: cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp?rev=129094&r1=129093&r2=129094&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/LogDiagnosticPrinter.cpp Thu Apr 7 13:51:54 2011
@@ -53,8 +53,14 @@
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 @@
// 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();
More information about the cfe-commits
mailing list