diff options
Diffstat (limited to 'contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp')
-rw-r--r-- | contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp | 98 |
1 files changed, 56 insertions, 42 deletions
diff --git a/contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index 6514321..29c58a8 100644 --- a/contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/contrib/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -59,32 +59,32 @@ public: virtual ~SDiagsRenderer() {} protected: - virtual void emitDiagnosticMessage(SourceLocation Loc, - PresumedLoc PLoc, - DiagnosticsEngine::Level Level, - StringRef Message, - ArrayRef<CharSourceRange> Ranges, - const SourceManager *SM, - DiagOrStoredDiag D); - - virtual void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, - DiagnosticsEngine::Level Level, - ArrayRef<CharSourceRange> Ranges, - const SourceManager &SM) {} - - virtual void emitNote(SourceLocation Loc, StringRef Message, - const SourceManager *SM); - - virtual void emitCodeContext(SourceLocation Loc, - DiagnosticsEngine::Level Level, - SmallVectorImpl<CharSourceRange>& Ranges, - ArrayRef<FixItHint> Hints, - const SourceManager &SM); - - virtual void beginDiagnostic(DiagOrStoredDiag D, - DiagnosticsEngine::Level Level); - virtual void endDiagnostic(DiagOrStoredDiag D, - DiagnosticsEngine::Level Level); + void emitDiagnosticMessage(SourceLocation Loc, + PresumedLoc PLoc, + DiagnosticsEngine::Level Level, + StringRef Message, + ArrayRef<CharSourceRange> Ranges, + const SourceManager *SM, + DiagOrStoredDiag D) override; + + void emitDiagnosticLoc(SourceLocation Loc, PresumedLoc PLoc, + DiagnosticsEngine::Level Level, + ArrayRef<CharSourceRange> Ranges, + const SourceManager &SM) override {} + + void emitNote(SourceLocation Loc, StringRef Message, + const SourceManager *SM) override; + + void emitCodeContext(SourceLocation Loc, + DiagnosticsEngine::Level Level, + SmallVectorImpl<CharSourceRange>& Ranges, + ArrayRef<FixItHint> Hints, + const SourceManager &SM) override; + + void beginDiagnostic(DiagOrStoredDiag D, + DiagnosticsEngine::Level Level) override; + void endDiagnostic(DiagOrStoredDiag D, + DiagnosticsEngine::Level Level) override; }; class SDiagsWriter : public DiagnosticConsumer { @@ -93,26 +93,26 @@ class SDiagsWriter : public DiagnosticConsumer { struct SharedState; explicit SDiagsWriter(IntrusiveRefCntPtr<SharedState> State) - : LangOpts(0), OriginalInstance(false), State(State) { } + : LangOpts(nullptr), OriginalInstance(false), State(State) {} public: SDiagsWriter(raw_ostream *os, DiagnosticOptions *diags) - : LangOpts(0), OriginalInstance(true), State(new SharedState(os, diags)) + : LangOpts(nullptr), OriginalInstance(true), + State(new SharedState(os, diags)) { EmitPreamble(); } ~SDiagsWriter() {} - + void HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, - const Diagnostic &Info); - - void BeginSourceFile(const LangOptions &LO, - const Preprocessor *PP) { + const Diagnostic &Info) override; + + void BeginSourceFile(const LangOptions &LO, const Preprocessor *PP) override { LangOpts = &LO; } - virtual void finish(); + void finish() override; private: /// \brief Emit the preamble for the serialized diagnostics. @@ -174,7 +174,7 @@ private: const SourceManager &SM); /// \brief The version of the diagnostics file. - enum { Version = 1 }; + enum { Version = 2 }; /// \brief Language options, which can differ from one clone of this client /// to another. @@ -200,7 +200,7 @@ private: llvm::BitstreamWriter Stream; /// \brief The name of the diagnostics file. - OwningPtr<raw_ostream> OS; + std::unique_ptr<raw_ostream> OS; /// \brief The set of constructed record abbreviations. AbbreviationMap Abbrevs; @@ -255,7 +255,7 @@ static void EmitBlockID(unsigned ID, const char *Name, Stream.EmitRecord(llvm::bitc::BLOCKINFO_CODE_SETBID, Record); // Emit the block name if present. - if (Name == 0 || Name[0] == 0) + if (!Name || Name[0] == 0) return; Record.clear(); @@ -546,7 +546,7 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, EnterDiagBlock(); EmitDiagnosticMessage(SourceLocation(), PresumedLoc(), DiagLevel, - State->diagBuf, 0, &Info); + State->diagBuf, nullptr, &Info); if (DiagLevel == DiagnosticsEngine::Note) ExitDiagBlock(); @@ -560,12 +560,26 @@ void SDiagsWriter::HandleDiagnostic(DiagnosticsEngine::Level DiagLevel, Renderer.emitDiagnostic(Info.getLocation(), DiagLevel, State->diagBuf.str(), Info.getRanges(), - llvm::makeArrayRef(Info.getFixItHints(), - Info.getNumFixItHints()), + Info.getFixItHints(), &Info.getSourceManager(), &Info); } +static serialized_diags::Level getStableLevel(DiagnosticsEngine::Level Level) { + switch (Level) { +#define CASE(X) case DiagnosticsEngine::X: return serialized_diags::X; + CASE(Ignored) + CASE(Note) + CASE(Remark) + CASE(Warning) + CASE(Error) + CASE(Fatal) +#undef CASE + } + + llvm_unreachable("invalid diagnostic level"); +} + void SDiagsWriter::EmitDiagnosticMessage(SourceLocation Loc, PresumedLoc PLoc, DiagnosticsEngine::Level Level, @@ -579,7 +593,7 @@ void SDiagsWriter::EmitDiagnosticMessage(SourceLocation Loc, // Emit the RECORD_DIAG record. Record.clear(); Record.push_back(RECORD_DIAG); - Record.push_back(Level); + Record.push_back(getStableLevel(Level)); AddLocToRecord(Loc, SM, PLoc, Record); if (const Diagnostic *Info = D.dyn_cast<const Diagnostic*>()) { @@ -688,5 +702,5 @@ void SDiagsWriter::finish() { State->OS->write((char *)&State->Buffer.front(), State->Buffer.size()); State->OS->flush(); - State->OS.reset(0); + State->OS.reset(); } |