summaryrefslogtreecommitdiffstats
path: root/clang/lib/Frontend/FrontendActions.cpp
diff options
context:
space:
mode:
authorDavid Blaikie <dblaikie@gmail.com>2014-08-29 06:34:53 +0000
committerDavid Blaikie <dblaikie@gmail.com>2014-08-29 06:34:53 +0000
commitd6902a1403c46161db316c582a50acc0cb1dd60b (patch)
tree5dc19ebf63c9ad3933eb74df67d3624812a2e797 /clang/lib/Frontend/FrontendActions.cpp
parentae926ad24d2fffbffb1a6154f81600c33486babf (diff)
downloadbcm5719-llvm-d6902a1403c46161db316c582a50acc0cb1dd60b.tar.gz
bcm5719-llvm-d6902a1403c46161db316c582a50acc0cb1dd60b.zip
Improve unique_ptr-y ownership in ASTUnit::ComputePreamble
Rather than having a pair of pairs and a reference out parameter, build a structure with everything together and named. A raw pointer and a unique_ptr, rather than a raw pointer and a boolean, are used to communicate ownership transfer. It's possible one day we'll end up with a conditional pointer (probably represented by a raw pointer and a boolean) abstraction to use in places like this. Conditional ownership seems to be coming up more often than I'd hoped... llvm-svn: 216712
Diffstat (limited to 'clang/lib/Frontend/FrontendActions.cpp')
-rw-r--r--clang/lib/Frontend/FrontendActions.cpp5
1 files changed, 2 insertions, 3 deletions
diff --git a/clang/lib/Frontend/FrontendActions.cpp b/clang/lib/Frontend/FrontendActions.cpp
index 0e251276259..99cd4a2e6d6 100644
--- a/clang/lib/Frontend/FrontendActions.cpp
+++ b/clang/lib/Frontend/FrontendActions.cpp
@@ -683,9 +683,8 @@ void PrintPreambleAction::ExecuteAction() {
}
CompilerInstance &CI = getCompilerInstance();
- std::unique_ptr<llvm::MemoryBuffer> Buffer
- = CI.getFileManager().getBufferForFile(getCurrentFile());
- if (Buffer) {
+ if (std::unique_ptr<llvm::MemoryBuffer> Buffer =
+ CI.getFileManager().getBufferForFile(getCurrentFile())) {
unsigned Preamble =
Lexer::ComputePreamble(Buffer->getBuffer(), CI.getLangOpts()).first;
llvm::outs().write(Buffer->getBufferStart(), Preamble);
OpenPOWER on IntegriCloud