diff options
author | Alexander Kornienko <alexfh@google.com> | 2014-11-17 23:46:02 +0000 |
---|---|---|
committer | Alexander Kornienko <alexfh@google.com> | 2014-11-17 23:46:02 +0000 |
commit | 41c247a677f0dafaa13fc05a028275334d5df779 (patch) | |
tree | ed924630113ca0750c462364131a85f1894d8bdf /clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | |
parent | d60b82f93eee090650d848c45f34dcf9d3ffa0ea (diff) | |
download | bcm5719-llvm-41c247a677f0dafaa13fc05a028275334d5df779.tar.gz bcm5719-llvm-41c247a677f0dafaa13fc05a028275334d5df779.zip |
Make DiagnosticsEngine::takeClient return std::unique_ptr<>
Summary:
Make DiagnosticsEngine::takeClient return std::unique_ptr<>. Updated
callers to store conditional ownership using a pair of pointer and unique_ptr
instead of a pointer + bool. Updated code that temporarily registers clients to
use the non-owning registration (+ removed extra calls to takeClient).
Reviewers: dblaikie
Reviewed By: dblaikie
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D6294
llvm-svn: 222193
Diffstat (limited to 'clang/lib/Frontend/VerifyDiagnosticConsumer.cpp')
-rw-r--r-- | clang/lib/Frontend/VerifyDiagnosticConsumer.cpp | 16 |
1 files changed, 6 insertions, 10 deletions
diff --git a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp index 531deb01771..3ff6b18e219 100644 --- a/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp +++ b/clang/lib/Frontend/VerifyDiagnosticConsumer.cpp @@ -29,12 +29,11 @@ typedef VerifyDiagnosticConsumer::ExpectedData ExpectedData; VerifyDiagnosticConsumer::VerifyDiagnosticConsumer(DiagnosticsEngine &Diags_) : Diags(Diags_), - PrimaryClient(Diags.getClient()), OwnsPrimaryClient(Diags.ownsClient()), + PrimaryClient(Diags.getClient()), PrimaryClientOwner(Diags.takeClient()), Buffer(new TextDiagnosticBuffer()), CurrentPreprocessor(nullptr), LangOpts(nullptr), SrcManager(nullptr), ActiveSourceFiles(0), Status(HasNoDirectives) { - Diags.takeClient(); if (Diags.hasSourceManager()) setSourceManager(Diags.getSourceManager()); } @@ -43,10 +42,8 @@ VerifyDiagnosticConsumer::~VerifyDiagnosticConsumer() { assert(!ActiveSourceFiles && "Incomplete parsing of source files!"); assert(!CurrentPreprocessor && "CurrentPreprocessor should be invalid!"); SrcManager = nullptr; - CheckDiagnostics(); - Diags.takeClient(); - if (OwnsPrimaryClient) - delete PrimaryClient; + CheckDiagnostics(); + Diags.takeClient().release(); } #ifndef NDEBUG @@ -802,8 +799,8 @@ void VerifyDiagnosticConsumer::UpdateParsedFileStatus(SourceManager &SM, void VerifyDiagnosticConsumer::CheckDiagnostics() { // Ensure any diagnostics go to the primary client. - bool OwnsCurClient = Diags.ownsClient(); - DiagnosticConsumer *CurClient = Diags.takeClient(); + DiagnosticConsumer *CurClient = Diags.getClient(); + std::unique_ptr<DiagnosticConsumer> Owner = Diags.takeClient(); Diags.setClient(PrimaryClient, false); #ifndef NDEBUG @@ -865,8 +862,7 @@ void VerifyDiagnosticConsumer::CheckDiagnostics() { Buffer->note_end(), "note")); } - Diags.takeClient(); - Diags.setClient(CurClient, OwnsCurClient); + Diags.setClient(CurClient, Owner.release() != nullptr); // Reset the buffer, we have processed all the diagnostics in it. Buffer.reset(new TextDiagnosticBuffer()); |