r217793 - unique_ptrify ChainedDiagnosticConsumer's ctor parameters
David Blaikie
dblaikie at gmail.com
Mon Sep 15 10:50:10 PDT 2014
Author: dblaikie
Date: Mon Sep 15 12:50:10 2014
New Revision: 217793
URL: http://llvm.org/viewvc/llvm-project?rev=217793&view=rev
Log:
unique_ptrify ChainedDiagnosticConsumer's ctor parameters
Modified:
cfe/trunk/include/clang/Frontend/ChainedDiagnosticConsumer.h
cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
cfe/trunk/lib/Frontend/CompilerInstance.cpp
cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
Modified: cfe/trunk/include/clang/Frontend/ChainedDiagnosticConsumer.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ChainedDiagnosticConsumer.h?rev=217793&r1=217792&r2=217793&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ChainedDiagnosticConsumer.h (original)
+++ cfe/trunk/include/clang/Frontend/ChainedDiagnosticConsumer.h Mon Sep 15 12:50:10 2014
@@ -26,11 +26,9 @@ class ChainedDiagnosticConsumer : public
std::unique_ptr<DiagnosticConsumer> Secondary;
public:
- ChainedDiagnosticConsumer(DiagnosticConsumer *_Primary,
- DiagnosticConsumer *_Secondary) {
- Primary.reset(_Primary);
- Secondary.reset(_Secondary);
- }
+ ChainedDiagnosticConsumer(std::unique_ptr<DiagnosticConsumer> Primary,
+ std::unique_ptr<DiagnosticConsumer> Secondary)
+ : Primary(std::move(Primary)), Secondary(std::move(Secondary)) {}
void BeginSourceFile(const LangOptions &LO,
const Preprocessor *PP) override {
Modified: cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h?rev=217793&r1=217792&r2=217793&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h (original)
+++ cfe/trunk/include/clang/Frontend/SerializedDiagnosticPrinter.h Mon Sep 15 12:50:10 2014
@@ -67,8 +67,8 @@ enum Level {
/// This allows wrapper tools for Clang to get diagnostics from Clang
/// (via libclang) without needing to parse Clang's command line output.
///
-DiagnosticConsumer *create(std::unique_ptr<raw_ostream> OS,
- DiagnosticOptions *diags);
+std::unique_ptr<DiagnosticConsumer> create(std::unique_ptr<raw_ostream> OS,
+ DiagnosticOptions *diags);
} // end serialized_diags namespace
} // end clang namespace
Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=217793&r1=217792&r2=217793&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
+++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Mon Sep 15 12:50:10 2014
@@ -154,11 +154,14 @@ static void SetUpDiagnosticLog(Diagnosti
}
// Chain in the diagnostic client which will log the diagnostics.
- LogDiagnosticPrinter *Logger =
- new LogDiagnosticPrinter(*OS, DiagOpts, std::move(StreamOwner));
+ auto Logger = llvm::make_unique<LogDiagnosticPrinter>(*OS, DiagOpts,
+ std::move(StreamOwner));
if (CodeGenOpts)
Logger->setDwarfDebugFlags(CodeGenOpts->DwarfDebugFlags);
- Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(), Logger));
+ assert(Diags.ownsClient());
+ Diags.setClient(new ChainedDiagnosticConsumer(
+ std::unique_ptr<DiagnosticConsumer>(Diags.takeClient()),
+ std::move(Logger)));
}
static void SetupSerializedDiagnostics(DiagnosticOptions *DiagOpts,
@@ -174,11 +177,13 @@ static void SetupSerializedDiagnostics(D
return;
}
- DiagnosticConsumer *SerializedConsumer =
+ auto SerializedConsumer =
clang::serialized_diags::create(std::move(OS), DiagOpts);
- Diags.setClient(new ChainedDiagnosticConsumer(Diags.takeClient(),
- SerializedConsumer));
+ assert(Diags.ownsClient());
+ Diags.setClient(new ChainedDiagnosticConsumer(
+ std::unique_ptr<DiagnosticConsumer>(Diags.takeClient()),
+ std::move(SerializedConsumer)));
}
void CompilerInstance::createDiagnostics(DiagnosticConsumer *Client,
Modified: cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp?rev=217793&r1=217792&r2=217793&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp (original)
+++ cfe/trunk/lib/Frontend/SerializedDiagnosticPrinter.cpp Mon Sep 15 12:50:10 2014
@@ -236,9 +236,9 @@ private:
namespace clang {
namespace serialized_diags {
-DiagnosticConsumer *create(std::unique_ptr<raw_ostream> OS,
- DiagnosticOptions *diags) {
- return new SDiagsWriter(std::move(OS), diags);
+std::unique_ptr<DiagnosticConsumer> create(std::unique_ptr<raw_ostream> OS,
+ DiagnosticOptions *diags) {
+ return llvm::make_unique<SDiagsWriter>(std::move(OS), diags);
}
} // end namespace serialized_diags
} // end namespace clang
More information about the cfe-commits
mailing list