diff options
| author | 2017-01-24 08:32:59 +0000 | |
|---|---|---|
| committer | 2017-01-24 08:32:59 +0000 | |
| commit | 53d771aafdbe5b919f264f53cba3788e2c4cffd2 (patch) | |
| tree | 7eca39498be0ff1e3a6daf583cd9ca5886bb2636 /gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp | |
| parent | In preparation of compiling our kernels with -ffreestanding, explicitly map (diff) | |
| download | wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.tar.xz wireguard-openbsd-53d771aafdbe5b919f264f53cba3788e2c4cffd2.zip | |
Import LLVM 4.0.0 rc1 including clang and lld to help the current
development effort on OpenBSD/arm64.
Diffstat (limited to 'gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp')
| -rw-r--r-- | gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp | 45 |
1 files changed, 21 insertions, 24 deletions
diff --git a/gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp b/gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp index 5c42406876b..7f88c919e24 100644 --- a/gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp +++ b/gnu/llvm/tools/clang/lib/Frontend/SerializedDiagnosticPrinter.cpp @@ -10,9 +10,7 @@ #include "clang/Frontend/SerializedDiagnosticPrinter.h" #include "clang/Basic/Diagnostic.h" #include "clang/Basic/DiagnosticOptions.h" -#include "clang/Basic/FileManager.h" #include "clang/Basic/SourceManager.h" -#include "clang/Basic/Version.h" #include "clang/Frontend/DiagnosticRenderer.h" #include "clang/Frontend/FrontendDiagnostic.h" #include "clang/Frontend/SerializedDiagnosticReader.h" @@ -25,7 +23,6 @@ #include "llvm/ADT/StringRef.h" #include "llvm/Support/raw_ostream.h" #include <utility> -#include <vector> using namespace clang; using namespace clang::serialized_diags; @@ -146,7 +143,7 @@ class SDiagsWriter : public DiagnosticConsumer { struct SharedState; - explicit SDiagsWriter(IntrusiveRefCntPtr<SharedState> State) + explicit SDiagsWriter(std::shared_ptr<SharedState> State) : LangOpts(nullptr), OriginalInstance(false), MergeChildRecords(false), State(std::move(State)) {} @@ -154,7 +151,7 @@ public: SDiagsWriter(StringRef File, DiagnosticOptions *Diags, bool MergeChildRecords) : LangOpts(nullptr), OriginalInstance(true), MergeChildRecords(MergeChildRecords), - State(new SharedState(File, Diags)) { + State(std::make_shared<SharedState>(File, Diags)) { if (MergeChildRecords) RemoveOldDiagnostics(); EmitPreamble(); @@ -254,7 +251,7 @@ private: /// \brief State that is shared among the various clones of this diagnostic /// consumer. - struct SharedState : RefCountedBase<SharedState> { + struct SharedState { SharedState(StringRef File, DiagnosticOptions *Diags) : DiagOpts(Diags), Stream(Buffer), OutputFile(File.str()), EmittedAnyDiagBlocks(false) {} @@ -302,7 +299,7 @@ private: }; /// \brief State shared among the various clones of this diagnostic consumer. - IntrusiveRefCntPtr<SharedState> State; + std::shared_ptr<SharedState> State; }; } // end anonymous namespace @@ -425,21 +422,21 @@ void SDiagsWriter::EmitPreamble() { EmitMetaBlock(); } -static void AddSourceLocationAbbrev(llvm::BitCodeAbbrev *Abbrev) { +static void AddSourceLocationAbbrev(llvm::BitCodeAbbrev &Abbrev) { using namespace llvm; - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // File ID. - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Line. - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Column. - Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Offset; + Abbrev.Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // File ID. + Abbrev.Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Line. + Abbrev.Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Column. + Abbrev.Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Offset; } -static void AddRangeLocationAbbrev(llvm::BitCodeAbbrev *Abbrev) { +static void AddRangeLocationAbbrev(llvm::BitCodeAbbrev &Abbrev) { AddSourceLocationAbbrev(Abbrev); AddSourceLocationAbbrev(Abbrev); } void SDiagsWriter::EmitBlockInfoBlock() { - State->Stream.EnterBlockInfoBlock(3); + State->Stream.EnterBlockInfoBlock(); using namespace llvm; llvm::BitstreamWriter &Stream = State->Stream; @@ -452,7 +449,7 @@ void SDiagsWriter::EmitBlockInfoBlock() { EmitBlockID(BLOCK_META, "Meta", Stream, Record); EmitRecordID(RECORD_VERSION, "Version", Stream, Record); - BitCodeAbbrev *Abbrev = new BitCodeAbbrev(); + auto Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_VERSION)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); Abbrevs.set(RECORD_VERSION, Stream.EmitBlockInfoAbbrev(BLOCK_META, Abbrev)); @@ -470,10 +467,10 @@ void SDiagsWriter::EmitBlockInfoBlock() { EmitRecordID(RECORD_FIXIT, "FixIt", Stream, Record); // Emit abbreviation for RECORD_DIAG. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_DIAG)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 3)); // Diag level. - AddSourceLocationAbbrev(Abbrev); + AddSourceLocationAbbrev(*Abbrev); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Category. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Mapped Diag ID. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::VBR, 16)); // Text size. @@ -481,7 +478,7 @@ void SDiagsWriter::EmitBlockInfoBlock() { Abbrevs.set(RECORD_DIAG, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG, Abbrev)); // Emit abbrevation for RECORD_CATEGORY. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_CATEGORY)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Category ID. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 8)); // Text size. @@ -489,14 +486,14 @@ void SDiagsWriter::EmitBlockInfoBlock() { Abbrevs.set(RECORD_CATEGORY, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG, Abbrev)); // Emit abbrevation for RECORD_SOURCE_RANGE. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_SOURCE_RANGE)); - AddRangeLocationAbbrev(Abbrev); + AddRangeLocationAbbrev(*Abbrev); Abbrevs.set(RECORD_SOURCE_RANGE, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG, Abbrev)); // Emit the abbreviation for RECORD_DIAG_FLAG. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_DIAG_FLAG)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Mapped Diag ID. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Text size. @@ -505,7 +502,7 @@ void SDiagsWriter::EmitBlockInfoBlock() { Abbrev)); // Emit the abbreviation for RECORD_FILENAME. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_FILENAME)); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 10)); // Mapped file ID. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 32)); // Size. @@ -516,9 +513,9 @@ void SDiagsWriter::EmitBlockInfoBlock() { Abbrev)); // Emit the abbreviation for RECORD_FIXIT. - Abbrev = new BitCodeAbbrev(); + Abbrev = std::make_shared<BitCodeAbbrev>(); Abbrev->Add(BitCodeAbbrevOp(RECORD_FIXIT)); - AddRangeLocationAbbrev(Abbrev); + AddRangeLocationAbbrev(*Abbrev); Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Fixed, 16)); // Text size. Abbrev->Add(BitCodeAbbrevOp(BitCodeAbbrevOp::Blob)); // FixIt text. Abbrevs.set(RECORD_FIXIT, Stream.EmitBlockInfoAbbrev(BLOCK_DIAG, |
