summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/ASTUnit.cpp
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2016-07-15 00:55:40 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2016-07-15 00:55:40 +0000
commit03f8907f65c5581a3d2653210dcab07e116ebe2f (patch)
treeea4db0f5bd3b2d034aea3560a15d2c70d25fafb8 /clang/lib/Frontend/ASTUnit.cpp
parent38c5318662c51ea02415e81ff4a5fc52df1c9d35 (diff)
downloadbcm5719-llvm-03f8907f65c5581a3d2653210dcab07e116ebe2f.tar.gz
bcm5719-llvm-03f8907f65c5581a3d2653210dcab07e116ebe2f.zip
Frontend: Simplify ownership model for clang's output streams.
This changes the CompilerInstance::createOutputFile function to return a std::unique_ptr<llvm::raw_ostream>, rather than an llvm::raw_ostream implicitly owned by the CompilerInstance. This in most cases required that I move ownership of the output stream to the relevant ASTConsumer. The motivation for this change is to allow BackendConsumer to be a client of interfaces such as D20268 which take ownership of the output stream. Differential Revision: http://reviews.llvm.org/D21537 llvm-svn: 275507
Diffstat (limited to 'clang/lib/Frontend/ASTUnit.cpp')
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp13
1 files changed, 7 insertions, 6 deletions
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index e0bf1c51c85..76fd00a132b 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -920,17 +920,17 @@ class PrecompilePreambleConsumer : public PCHGenerator {
unsigned &Hash;
std::vector<Decl *> TopLevelDecls;
PrecompilePreambleAction *Action;
- raw_ostream *Out;
+ std::unique_ptr<raw_ostream> Out;
public:
PrecompilePreambleConsumer(ASTUnit &Unit, PrecompilePreambleAction *Action,
const Preprocessor &PP, StringRef isysroot,
- raw_ostream *Out)
+ std::unique_ptr<raw_ostream> Out)
: PCHGenerator(PP, "", nullptr, isysroot, std::make_shared<PCHBuffer>(),
ArrayRef<llvm::IntrusiveRefCntPtr<ModuleFileExtension>>(),
/*AllowASTWithErrors=*/true),
Unit(Unit), Hash(Unit.getCurrentTopLevelHashValue()), Action(Action),
- Out(Out) {
+ Out(std::move(Out)) {
Hash = 0;
}
@@ -982,8 +982,9 @@ PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
StringRef InFile) {
std::string Sysroot;
std::string OutputFile;
- raw_ostream *OS = GeneratePCHAction::ComputeASTConsumerArguments(
- CI, InFile, Sysroot, OutputFile);
+ std::unique_ptr<raw_ostream> OS =
+ GeneratePCHAction::ComputeASTConsumerArguments(CI, InFile, Sysroot,
+ OutputFile);
if (!OS)
return nullptr;
@@ -994,7 +995,7 @@ PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
llvm::make_unique<MacroDefinitionTrackerPPCallbacks>(
Unit.getCurrentTopLevelHashValue()));
return llvm::make_unique<PrecompilePreambleConsumer>(
- Unit, this, CI.getPreprocessor(), Sysroot, OS);
+ Unit, this, CI.getPreprocessor(), Sysroot, std::move(OS));
}
static bool isNonDriverDiag(const StoredDiagnostic &StoredDiag) {
OpenPOWER on IntegriCloud