r213307 - unique_ptr-ify ownership of ASTConsumers

David Blaikie dblaikie at gmail.com
Thu Jul 17 16:05:26 PDT 2014


On Thu, Jul 17, 2014 at 3:51 PM, David Blaikie <dblaikie at gmail.com> wrote:
> On Thu, Jul 17, 2014 at 2:45 PM, Alp Toker <alp at nuanti.com> wrote:
>>
>> On 18/07/2014 00:22, David Blaikie wrote:
>>>
>>> On Thu, Jul 17, 2014 at 2:06 PM, Alp Toker <alp at nuanti.com> wrote:
>>>>
>>>> On 17/07/2014 23:40, David Blaikie wrote:
>>>>>
>>>>> Author: dblaikie
>>>>> Date: Thu Jul 17 15:40:36 2014
>>>>> New Revision: 213307
>>>>>
>>>>> URL: http://llvm.org/viewvc/llvm-project?rev=213307&view=rev
>>>>> Log:
>>>>> unique_ptr-ify ownership of ASTConsumers
>>>>>
>>>>> (after fixing a bug in MultiplexConsumer I noticed the ownership of the
>>>>> nested consumers was implemented with raw pointers - so this fixes
>>>>> that... and follows the source back to its origin pushing unique_ptr
>>>>> ownership up through there too)
>>>>
>>>>
>>>> David,
>>>>
>>>> Please back out this change and propose it on the list.
>>>>
>>>> I said just a couple of days ago that this probably isn't the way we want
>>>> to
>>>> go so I don't understand why you went ahead and made this commit.
>>>
>>> As I mentioned in that thread this is consistent with the general
>>> direction of the LLVM project overall (and Clang specifically).
>>
>>
>> I disagreed with that assertion when you made it the other day. If you want
>> to continue the discussion it's OK
>
> I did continue the discussion, explaining why I thought this was a
> valuable/valid direction to take the project and there was no further
> discussion on the matter. (if we're both talking about the same thing
> - the discussion in post-commit of r213324)

Sorry, copy/paste failure. That should be r212403.

>
>> but this commit hasn't been approved,
>
> Nor do I believe it needed to be. I believe this meets the bar for
> post-commit review for my contributions to the project.
>
>> certainly isn't an obvious direction,
>
> It's one of many patches in this direction since the start of this
> year when we switched to C++11. Code owners across the board seem to
> have been fairly happy with these changes (either made by myself or
> other people doing cleanup work (Aaron, Ahmed, Benjamin, Craig, etc)
> or by code owners themselves) and it's a not uncommon piece of review
> feedback to encourage use of owning smart pointers in new/touched
> code.
>
>> and needs to be posted to the list for review.
>
> I don't believe it does - but I've reverted these patches (r213325 and
> r213324) & will start a conversation on llvm/cfe-dev to ensure we've
> covered all the bases.
>
>> (You asked me to revert a commit the other week
>
> I did so because you asked for review and committed before that review
> was complete. That's not the case here.
>
>> and I did so out of
>> courtesy, so I think you can do the same here regardless of whether you
>> personally agree. The change is large and needs to be discussed.)
>
> I don't think it needs to, based on the hundreds of patches moving to
> owning smart pointers both before (in the form of OwningPtr) and after
> the C++11 switch that have already been contributed to the project,
> but no harm in having a bit of a chat about it. This was just
> opportunistic cleanup I noticed when fixing a bug (213211).
>
> Thanks,
> - David
>
>>
>>
>>
>>> Changes like this have been happening (by myself and others) since we
>>> switched to C++11 at the start of this year. Some of the earliest was
>>> simple transformation from OwningPtr to std::unique_ptr, but there's a
>>> lot more that's now possible with move semantics that couldn't be
>>> represented with a pre-move OwningPtr, so we'll see this sort of
>>> cleanup/improvement continue over time as people have time to do it.
>>>
>>> - David
>>>
>>>>> Modified:
>>>>>       cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp
>>>>>       cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h
>>>>>       cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
>>>>>       cfe/trunk/include/clang/CodeGen/CodeGenAction.h
>>>>>       cfe/trunk/include/clang/Frontend/ASTConsumers.h
>>>>>       cfe/trunk/include/clang/Frontend/CompilerInstance.h
>>>>>       cfe/trunk/include/clang/Frontend/FrontendAction.h
>>>>>       cfe/trunk/include/clang/Frontend/FrontendActions.h
>>>>>       cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>>>>>       cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h
>>>>>       cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
>>>>>       cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
>>>>>       cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
>>>>>       cfe/trunk/include/clang/Tooling/Tooling.h
>>>>>       cfe/trunk/lib/ARCMigrate/ARCMT.cpp
>>>>>       cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>>>>>       cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
>>>>>       cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>>>>>       cfe/trunk/lib/Frontend/ASTConsumers.cpp
>>>>>       cfe/trunk/lib/Frontend/ASTMerge.cpp
>>>>>       cfe/trunk/lib/Frontend/ASTUnit.cpp
>>>>>       cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
>>>>>       cfe/trunk/lib/Frontend/CompilerInstance.cpp
>>>>>       cfe/trunk/lib/Frontend/FrontendAction.cpp
>>>>>       cfe/trunk/lib/Frontend/FrontendActions.cpp
>>>>>       cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>>>>>       cfe/trunk/lib/Frontend/Rewrite/FrontendActions.cpp
>>>>>       cfe/trunk/lib/Frontend/Rewrite/HTMLPrint.cpp
>>>>>       cfe/trunk/lib/Frontend/Rewrite/RewriteModernObjC.cpp
>>>>>       cfe/trunk/lib/Frontend/Rewrite/RewriteObjC.cpp
>>>>>       cfe/trunk/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
>>>>>       cfe/trunk/lib/StaticAnalyzer/Frontend/FrontendActions.cpp
>>>>>       cfe/trunk/tools/clang-check/ClangCheck.cpp
>>>>>       cfe/trunk/tools/libclang/Indexing.cpp
>>>>>       cfe/trunk/unittests/AST/EvaluateAsRValueTest.cpp
>>>>>       cfe/trunk/unittests/AST/ExternalASTSourceTest.cpp
>>>>>       cfe/trunk/unittests/AST/NamedDeclPrinterTest.cpp
>>>>>       cfe/trunk/unittests/Frontend/FrontendActionTest.cpp
>>>>>       cfe/trunk/unittests/Sema/ExternalSemaSourceTest.cpp
>>>>>       cfe/trunk/unittests/Tooling/RefactoringTest.cpp
>>>>>       cfe/trunk/unittests/Tooling/TestVisitor.h
>>>>>       cfe/trunk/unittests/Tooling/ToolingTest.cpp
>>>>>
>>>>> Modified: cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp
>>>>> (original)
>>>>> +++ cfe/trunk/examples/PrintFunctionNames/PrintFunctionNames.cpp Thu Jul
>>>>> 17 15:40:36 2014
>>>>> @@ -36,8 +36,9 @@ public:
>>>>>      class PrintFunctionNamesAction : public PluginASTAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI, llvm::StringRef)
>>>>> {
>>>>> -    return new PrintFunctionsConsumer();
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 llvm::StringRef) {
>>>>> +    return llvm::make_unique<PrintFunctionsConsumer>();
>>>>>      }
>>>>>        bool ParseArgs(const CompilerInstance &CI,
>>>>>
>>>>> Modified: cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h (original)
>>>>> +++ cfe/trunk/include/clang/ARCMigrate/ARCMTActions.h Thu Jul 17
>>>>> 15:40:36
>>>>> 2014
>>>>> @@ -37,8 +37,8 @@ class MigrateSourceAction : public ASTFr
>>>>>      FileRemapper Remapper;
>>>>>    protected:
>>>>>      bool BeginInvocation(CompilerInstance &CI) override;
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class MigrateAction : public WrapperFrontendAction {
>>>>> @@ -65,8 +65,8 @@ public:
>>>>>                        unsigned migrateAction);
>>>>>      protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      bool BeginInvocation(CompilerInstance &CI) override;
>>>>>    };
>>>>>
>>>>> Modified: cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h (original)
>>>>> +++ cfe/trunk/include/clang/ASTMatchers/ASTMatchFinder.h Thu Jul 17
>>>>> 15:40:36 2014
>>>>> @@ -148,7 +148,7 @@ public:
>>>>>                             MatchCallback *Action);
>>>>>        /// \brief Creates a clang ASTConsumer that finds all matches.
>>>>> -  clang::ASTConsumer *newASTConsumer();
>>>>> +  std::unique_ptr<clang::ASTConsumer> newASTConsumer();
>>>>>        /// \brief Calls the registered callbacks on all matches on the
>>>>> given \p Node.
>>>>>      ///
>>>>>
>>>>> Modified: cfe/trunk/include/clang/CodeGen/CodeGenAction.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/CodeGen/CodeGenAction.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/CodeGen/CodeGenAction.h (original)
>>>>> +++ cfe/trunk/include/clang/CodeGen/CodeGenAction.h Thu Jul 17 15:40:36
>>>>> 2014
>>>>> @@ -37,8 +37,8 @@ protected:
>>>>>        bool hasIRSupport() const override;
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        void ExecuteAction() override;
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Frontend/ASTConsumers.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTConsumers.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Frontend/ASTConsumers.h (original)
>>>>> +++ cfe/trunk/include/clang/Frontend/ASTConsumers.h Thu Jul 17 15:40:36
>>>>> 2014
>>>>> @@ -16,6 +16,8 @@
>>>>>      #include "clang/Basic/LLVM.h"
>>>>>    +#include <memory>
>>>>> +
>>>>>    namespace clang {
>>>>>      class ASTConsumer;
>>>>> @@ -30,24 +32,26 @@ class TargetOptions;
>>>>>    // original C code.  The output is intended to be in a format such
>>>>> that
>>>>>    // clang could re-parse the output back into the same AST, but the
>>>>>    // implementation is still incomplete.
>>>>> -ASTConsumer *CreateASTPrinter(raw_ostream *OS, StringRef FilterString);
>>>>> +std::unique_ptr<ASTConsumer> CreateASTPrinter(raw_ostream *OS,
>>>>> +                                              StringRef FilterString);
>>>>>      // AST dumper: dumps the raw AST in human-readable form to stderr;
>>>>> this is
>>>>>    // intended for debugging.
>>>>> -ASTConsumer *CreateASTDumper(StringRef FilterString, bool DumpLookups =
>>>>> false);
>>>>> +std::unique_ptr<ASTConsumer> CreateASTDumper(StringRef FilterString,
>>>>> +                                             bool DumpLookups = false);
>>>>>      // AST Decl node lister: prints qualified names of all filterable
>>>>> AST
>>>>> Decl
>>>>>    // nodes.
>>>>> -ASTConsumer *CreateASTDeclNodeLister();
>>>>> +std::unique_ptr<ASTConsumer> CreateASTDeclNodeLister();
>>>>>      // Graphical AST viewer: for each function definition, creates a
>>>>> graph
>>>>> of
>>>>>    // the AST and displays it with the graph viewer "dotty".  Also
>>>>> outputs
>>>>>    // function declarations to stderr.
>>>>> -ASTConsumer *CreateASTViewer();
>>>>> +std::unique_ptr<ASTConsumer> CreateASTViewer();
>>>>>      // DeclContext printer: prints out the DeclContext tree in
>>>>> human-readable form
>>>>>    // to stderr; this is intended for debugging.
>>>>> -ASTConsumer *CreateDeclContextPrinter();
>>>>> +std::unique_ptr<ASTConsumer> CreateDeclContextPrinter();
>>>>>      } // end clang namespace
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Frontend/CompilerInstance.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/CompilerInstance.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Frontend/CompilerInstance.h (original)
>>>>> +++ cfe/trunk/include/clang/Frontend/CompilerInstance.h Thu Jul 17
>>>>> 15:40:36 2014
>>>>> @@ -14,6 +14,7 @@
>>>>>    #include "clang/Basic/SourceManager.h"
>>>>>    #include "clang/Frontend/CompilerInvocation.h"
>>>>>    #include "clang/Frontend/Utils.h"
>>>>> +#include "clang/AST/ASTConsumer.h"
>>>>>    #include "clang/Lex/ModuleLoader.h"
>>>>>    #include "llvm/ADT/ArrayRef.h"
>>>>>    #include "llvm/ADT/DenseMap.h"
>>>>> @@ -443,11 +444,11 @@ public:
>>>>>        /// takeASTConsumer - Remove the current AST consumer and give
>>>>> ownership to
>>>>>      /// the caller.
>>>>> -  ASTConsumer *takeASTConsumer() { return Consumer.release(); }
>>>>> +  std::unique_ptr<ASTConsumer> takeASTConsumer() { return
>>>>> std::move(Consumer); }
>>>>>        /// setASTConsumer - Replace the current AST consumer; the
>>>>> compiler
>>>>> instance
>>>>>      /// takes ownership of \p Value.
>>>>> -  void setASTConsumer(ASTConsumer *Value);
>>>>> +  void setASTConsumer(std::unique_ptr<ASTConsumer> Value);
>>>>>        /// }
>>>>>      /// @name Semantic analysis
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Frontend/FrontendAction.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendAction.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Frontend/FrontendAction.h (original)
>>>>> +++ cfe/trunk/include/clang/Frontend/FrontendAction.h Thu Jul 17
>>>>> 15:40:36
>>>>> 2014
>>>>> @@ -41,8 +41,8 @@ class FrontendAction {
>>>>>      friend class WrapperFrontendAction;
>>>>>      private:
>>>>> -  ASTConsumer* CreateWrappedASTConsumer(CompilerInstance &CI,
>>>>> -                                        StringRef InFile);
>>>>> +  std::unique_ptr<ASTConsumer>
>>>>> CreateWrappedASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> +                                                        StringRef
>>>>> InFile);
>>>>>      protected:
>>>>>      /// @name Implementation Action Interface
>>>>> @@ -61,8 +61,8 @@ protected:
>>>>>      /// getCurrentFile().
>>>>>      ///
>>>>>      /// \return The new AST consumer, or null on failure.
>>>>> -  virtual ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                         StringRef InFile) = 0;
>>>>> +  virtual std::unique_ptr<ASTConsumer>
>>>>> CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> +                                                         StringRef
>>>>> InFile) = 0;
>>>>>        /// \brief Callback before starting processing a single input,
>>>>> giving the
>>>>>      /// opportunity to modify the CompilerInvocation or do some other
>>>>> action
>>>>> @@ -227,11 +227,10 @@ public:
>>>>>      class PluginASTAction : public ASTFrontendAction {
>>>>>      virtual void anchor();
>>>>> -protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override = 0;
>>>>> -
>>>>>    public:
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override = 0;
>>>>> +
>>>>>      /// \brief Parse the given plugin command line arguments.
>>>>>      ///
>>>>>      /// \param CI - The compiler instance, for use in reporting
>>>>> diagnostics.
>>>>> @@ -247,8 +246,8 @@ class PreprocessorFrontendAction : publi
>>>>>    protected:
>>>>>      /// \brief Provide a default implementation which returns aborts;
>>>>>      /// this method should never be called by FrontendAction clients.
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      public:
>>>>>      bool usesPreprocessorOnly() const override { return true; }
>>>>> @@ -264,8 +263,8 @@ class WrapperFrontendAction : public Fro
>>>>>      std::unique_ptr<FrontendAction> WrappedAction;
>>>>>      protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      bool BeginInvocation(CompilerInstance &CI) override;
>>>>>      bool BeginSourceFileAction(CompilerInstance &CI, StringRef
>>>>> Filename)
>>>>> override;
>>>>>      void ExecuteAction() override;
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Frontend/FrontendActions.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/FrontendActions.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Frontend/FrontendActions.h (original)
>>>>> +++ cfe/trunk/include/clang/Frontend/FrontendActions.h Thu Jul 17
>>>>> 15:40:36
>>>>> 2014
>>>>> @@ -26,8 +26,8 @@ class FileEntry;
>>>>>    class InitOnlyAction : public FrontendAction {
>>>>>      void ExecuteAction() override;
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      public:
>>>>>      // Don't claim to only use the preprocessor, we want to follow the
>>>>> AST
>>>>> path,
>>>>> @@ -41,38 +41,38 @@ public:
>>>>>      class ASTPrintAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class ASTDumpAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class ASTDeclListAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class ASTViewAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class DeclContextPrintAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class GeneratePCHAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        TranslationUnitKind getTranslationUnitKind() override {
>>>>>        return TU_Prefix;
>>>>> @@ -98,8 +98,8 @@ class GenerateModuleAction : public ASTF
>>>>>      bool IsSystem;
>>>>>        protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        TranslationUnitKind getTranslationUnitKind() override {
>>>>>        return TU_Module;
>>>>> @@ -128,8 +128,8 @@ public:
>>>>>      class SyntaxOnlyAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                         StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      public:
>>>>>      bool hasCodeCompletionSupport() const override { return true; }
>>>>> @@ -139,8 +139,8 @@ public:
>>>>>    /// basic debugging and discovery.
>>>>>    class DumpModuleInfoAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      void ExecuteAction() override;
>>>>>      public:
>>>>> @@ -152,8 +152,8 @@ public:
>>>>>      class VerifyPCHAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        void ExecuteAction() override;
>>>>>    @@ -177,8 +177,8 @@ class ASTMergeAction : public FrontendAc
>>>>>      std::vector<std::string> ASTFiles;
>>>>>      protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        bool BeginSourceFileAction(CompilerInstance &CI,
>>>>>                                 StringRef Filename) override;
>>>>> @@ -200,7 +200,8 @@ public:
>>>>>    class PrintPreambleAction : public FrontendAction {
>>>>>    protected:
>>>>>      void ExecuteAction() override;
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &, StringRef)
>>>>> override
>>>>> {
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &,
>>>>> +                                                 StringRef) override {
>>>>>        return nullptr;
>>>>>      }
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Frontend/MultiplexConsumer.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/MultiplexConsumer.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Frontend/MultiplexConsumer.h (original)
>>>>> +++ cfe/trunk/include/clang/Frontend/MultiplexConsumer.h Thu Jul 17
>>>>> 15:40:36 2014
>>>>> @@ -29,7 +29,7 @@ class MultiplexASTDeserializationListene
>>>>>    class MultiplexConsumer : public SemaConsumer {
>>>>>    public:
>>>>>      // Takes ownership of the pointers in C.
>>>>> -  MultiplexConsumer(ArrayRef<ASTConsumer*> C);
>>>>> +  MultiplexConsumer(std::vector<std::unique_ptr<ASTConsumer>> C);
>>>>>      ~MultiplexConsumer();
>>>>>        // ASTConsumer
>>>>> @@ -59,7 +59,7 @@ public:
>>>>>      void ForgetSema() override;
>>>>>      private:
>>>>> -  std::vector<ASTConsumer*> Consumers;  // Owns these.
>>>>> +  std::vector<std::unique_ptr<ASTConsumer>> Consumers; // Owns these.
>>>>>      std::unique_ptr<MultiplexASTMutationListener> MutationListener;
>>>>>      std::unique_ptr<MultiplexASTDeserializationListener>
>>>>> DeserializationListener;
>>>>>    };
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h (original)
>>>>> +++ cfe/trunk/include/clang/Rewrite/Frontend/ASTConsumers.h Thu Jul 17
>>>>> 15:40:36 2014
>>>>> @@ -15,6 +15,8 @@
>>>>>    #define REWRITE_ASTCONSUMERS_H
>>>>>      #include "clang/Basic/LLVM.h"
>>>>> +
>>>>> +#include <memory>
>>>>>    #include <string>
>>>>>      namespace clang {
>>>>> @@ -26,23 +28,21 @@ class Preprocessor;
>>>>>      // ObjC rewriter: attempts to rewrite ObjC constructs into pure C
>>>>> code.
>>>>>    // This is considered experimental, and only works with Apple's ObjC
>>>>> runtime.
>>>>> -ASTConsumer *CreateObjCRewriter(const std::string &InFile,
>>>>> -                                raw_ostream *OS,
>>>>> -                                DiagnosticsEngine &Diags,
>>>>> -                                const LangOptions &LOpts,
>>>>> -                                bool SilenceRewriteMacroWarning);
>>>>> -ASTConsumer *CreateModernObjCRewriter(const std::string &InFile,
>>>>> -                                raw_ostream *OS,
>>>>> -                                DiagnosticsEngine &Diags,
>>>>> -                                const LangOptions &LOpts,
>>>>> -                                bool SilenceRewriteMacroWarning,
>>>>> -                                bool LineInfo);
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +CreateObjCRewriter(const std::string &InFile, raw_ostream *OS,
>>>>> +                   DiagnosticsEngine &Diags, const LangOptions &LOpts,
>>>>> +                   bool SilenceRewriteMacroWarning);
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +CreateModernObjCRewriter(const std::string &InFile, raw_ostream *OS,
>>>>> +                         DiagnosticsEngine &Diags, const LangOptions
>>>>> &LOpts,
>>>>> +                         bool SilenceRewriteMacroWarning, bool
>>>>> LineInfo);
>>>>>      /// CreateHTMLPrinter - Create an AST consumer which rewrites
>>>>> source
>>>>> code to
>>>>>    /// HTML with syntax highlighting suitable for viewing in a
>>>>> web-browser.
>>>>> -ASTConsumer *CreateHTMLPrinter(raw_ostream *OS, Preprocessor &PP,
>>>>> -                               bool SyntaxHighlight = true,
>>>>> -                               bool HighlightMacros = true);
>>>>> +std::unique_ptr<ASTConsumer> CreateHTMLPrinter(raw_ostream *OS,
>>>>> +                                               Preprocessor &PP,
>>>>> +                                               bool SyntaxHighlight =
>>>>> true,
>>>>> +                                               bool HighlightMacros =
>>>>> true);
>>>>>      } // end clang namespace
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h
>>>>> (original)
>>>>> +++ cfe/trunk/include/clang/Rewrite/Frontend/FrontendActions.h Thu Jul
>>>>> 17
>>>>> 15:40:36 2014
>>>>> @@ -22,8 +22,8 @@ class FixItOptions;
>>>>>      class HTMLPrintAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class FixItAction : public ASTFrontendAction {
>>>>> @@ -31,8 +31,8 @@ protected:
>>>>>      std::unique_ptr<FixItRewriter> Rewriter;
>>>>>      std::unique_ptr<FixItOptions> FixItOpts;
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>        bool BeginSourceFileAction(CompilerInstance &CI,
>>>>>                                 StringRef Filename) override;
>>>>> @@ -59,8 +59,8 @@ protected:
>>>>>      class RewriteObjCAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      class RewriteMacrosAction : public PreprocessorFrontendAction {
>>>>>
>>>>> Modified:
>>>>> cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
>>>>> (original)
>>>>> +++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/AnalysisConsumer.h
>>>>> Thu
>>>>> Jul 17 15:40:36 2014
>>>>> @@ -37,10 +37,9 @@ public:
>>>>>    /// CreateAnalysisConsumer - Creates an ASTConsumer to run various
>>>>> code
>>>>>    /// analysis passes.  (The set of analyses run is controlled by
>>>>> command-line
>>>>>    /// options.)
>>>>> -AnalysisASTConsumer *CreateAnalysisConsumer(const Preprocessor &pp,
>>>>> -                                            const std::string &output,
>>>>> -                                            AnalyzerOptionsRef opts,
>>>>> -                                            ArrayRef<std::string>
>>>>> plugins);
>>>>> +std::unique_ptr<AnalysisASTConsumer>
>>>>> +CreateAnalysisConsumer(const Preprocessor &pp, const std::string
>>>>> &output,
>>>>> +                       AnalyzerOptionsRef opts, ArrayRef<std::string>
>>>>> plugins);
>>>>>      } // end GR namespace
>>>>>
>>>>> Modified:
>>>>> cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
>>>>> (original)
>>>>> +++ cfe/trunk/include/clang/StaticAnalyzer/Frontend/FrontendActions.h
>>>>> Thu
>>>>> Jul 17 15:40:36 2014
>>>>> @@ -22,8 +22,8 @@ namespace ento {
>>>>>      class AnalysisAction : public ASTFrontendAction {
>>>>>    protected:
>>>>> -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>    };
>>>>>      void printCheckerHelp(raw_ostream &OS, ArrayRef<std::string>
>>>>> plugins);
>>>>>
>>>>> Modified: cfe/trunk/include/clang/Tooling/Tooling.h
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Tooling/Tooling.h?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/include/clang/Tooling/Tooling.h (original)
>>>>> +++ cfe/trunk/include/clang/Tooling/Tooling.h Thu Jul 17 15:40:36 2014
>>>>> @@ -30,6 +30,7 @@
>>>>>    #ifndef LLVM_CLANG_TOOLING_TOOLING_H
>>>>>    #define LLVM_CLANG_TOOLING_TOOLING_H
>>>>>    +#include "clang/AST/ASTConsumer.h"
>>>>>    #include "clang/Basic/Diagnostic.h"
>>>>>    #include "clang/Basic/FileManager.h"
>>>>>    #include "clang/Basic/LLVM.h"
>>>>> @@ -335,8 +336,8 @@ inline std::unique_ptr<FrontendActionFac
>>>>>                                 SourceFileCallbacks *Callbacks)
>>>>>            : ConsumerFactory(ConsumerFactory), Callbacks(Callbacks) {}
>>>>>    -      clang::ASTConsumer *CreateASTConsumer(clang::CompilerInstance
>>>>> &,
>>>>> -                                            StringRef) override {
>>>>> +      std::unique_ptr<clang::ASTConsumer>
>>>>> +      CreateASTConsumer(clang::CompilerInstance &, StringRef) override
>>>>> {
>>>>>            return ConsumerFactory->newASTConsumer();
>>>>>          }
>>>>>
>>>>> Modified: cfe/trunk/lib/ARCMigrate/ARCMT.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ARCMT.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/ARCMigrate/ARCMT.cpp (original)
>>>>> +++ cfe/trunk/lib/ARCMigrate/ARCMT.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -446,11 +446,11 @@ public:
>>>>>      ARCMTMacroTrackerAction(std::vector<SourceLocation>
>>>>> &ARCMTMacroLocs)
>>>>>        : ARCMTMacroLocs(ARCMTMacroLocs) { }
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override {
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override {
>>>>>        CI.getPreprocessor().addPPCallbacks(
>>>>>                                  new
>>>>> ARCMTMacroTrackerPPCallbacks(ARCMTMacroLocs));
>>>>> -    return new ASTConsumer();
>>>>> +    return llvm::make_unique<ASTConsumer>();
>>>>>      }
>>>>>    };
>>>>>
>>>>> Modified: cfe/trunk/lib/ARCMigrate/ObjCMT.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ARCMigrate/ObjCMT.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/ARCMigrate/ObjCMT.cpp (original)
>>>>> +++ cfe/trunk/lib/ARCMigrate/ObjCMT.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -185,23 +185,17 @@ ObjCMigrateAction::ObjCMigrateAction(Fro
>>>>>        MigrateDir = "."; // user current directory if none is given.
>>>>>    }
>>>>>    -ASTConsumer *ObjCMigrateAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                  StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ObjCMigrateAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>>      PPConditionalDirectiveRecord *
>>>>>        PPRec = new
>>>>> PPConditionalDirectiveRecord(CompInst->getSourceManager());
>>>>>      CompInst->getPreprocessor().addPPCallbacks(PPRec);
>>>>> -  ASTConsumer *
>>>>> -    WrappedConsumer = WrapperFrontendAction::CreateASTConsumer(CI,
>>>>> InFile);
>>>>> -  ASTConsumer *MTConsumer = new ObjCMigrateASTConsumer(MigrateDir,
>>>>> -                                                       ObjCMigAction,
>>>>> -                                                       Remapper,
>>>>> -
>>>>> CompInst->getFileManager(),
>>>>> -                                                       PPRec,
>>>>> -
>>>>> CompInst->getPreprocessor(),
>>>>> -                                                       false,
>>>>> -
>>>>> ArrayRef<std::string>());
>>>>> -  ASTConsumer *Consumers[] = { MTConsumer, WrappedConsumer };
>>>>> -  return new MultiplexConsumer(Consumers);
>>>>> +  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
>>>>> +  Consumers.push_back(WrapperFrontendAction::CreateASTConsumer(CI,
>>>>> InFile));
>>>>> +  Consumers.push_back(llvm::make_unique<ObjCMigrateASTConsumer>(
>>>>> +      MigrateDir, ObjCMigAction, Remapper, CompInst->getFileManager(),
>>>>> PPRec,
>>>>> +      CompInst->getPreprocessor(), false, ArrayRef<std::string>()));
>>>>> +  return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
>>>>>    }
>>>>>      bool ObjCMigrateAction::BeginInvocation(CompilerInstance &CI) {
>>>>> @@ -1865,8 +1859,8 @@ static std::vector<std::string> getWhite
>>>>>      return Filenames;
>>>>>    }
>>>>>    -ASTConsumer *MigrateSourceAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                  StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +MigrateSourceAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>>      PPConditionalDirectiveRecord *
>>>>>        PPRec = new PPConditionalDirectiveRecord(CI.getSourceManager());
>>>>>      unsigned ObjCMTAction = CI.getFrontendOpts().ObjCMTAction;
>>>>> @@ -1883,14 +1877,10 @@ ASTConsumer *MigrateSourceAction::Create
>>>>>      CI.getPreprocessor().addPPCallbacks(PPRec);
>>>>>      std::vector<std::string> WhiteList =
>>>>>        getWhiteListFilenames(CI.getFrontendOpts().ObjCMTWhiteListPath);
>>>>> -  return new ObjCMigrateASTConsumer(CI.getFrontendOpts().OutputFile,
>>>>> -                                    ObjCMTAction,
>>>>> -                                    Remapper,
>>>>> -                                    CI.getFileManager(),
>>>>> -                                    PPRec,
>>>>> -                                    CI.getPreprocessor(),
>>>>> -                                    /*isOutputFile=*/true,
>>>>> -                                    WhiteList);
>>>>> +  return llvm::make_unique<ObjCMigrateASTConsumer>(
>>>>> +      CI.getFrontendOpts().OutputFile, ObjCMTAction, Remapper,
>>>>> +      CI.getFileManager(), PPRec, CI.getPreprocessor(),
>>>>> +      /*isOutputFile=*/true, WhiteList);
>>>>>    }
>>>>>      namespace {
>>>>>
>>>>> Modified: cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp (original)
>>>>> +++ cfe/trunk/lib/ASTMatchers/ASTMatchFinder.cpp Thu Jul 17 15:40:36
>>>>> 2014
>>>>> @@ -823,8 +823,8 @@ bool MatchFinder::addDynamicMatcher(cons
>>>>>      return false;
>>>>>    }
>>>>>    -ASTConsumer *MatchFinder::newASTConsumer() {
>>>>> -  return new internal::MatchASTConsumer(this, ParsingDone);
>>>>> +std::unique_ptr<ASTConsumer> MatchFinder::newASTConsumer() {
>>>>> +  return llvm::make_unique<internal::MatchASTConsumer>(this,
>>>>> ParsingDone);
>>>>>    }
>>>>>      void MatchFinder::match(const clang::ast_type_traits::DynTypedNode
>>>>> &Node,
>>>>>
>>>>> Modified: cfe/trunk/lib/CodeGen/CodeGenAction.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenAction.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/CodeGen/CodeGenAction.cpp (original)
>>>>> +++ cfe/trunk/lib/CodeGen/CodeGenAction.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -590,8 +590,8 @@ static raw_ostream *GetOutputStream(Comp
>>>>>      llvm_unreachable("Invalid action!");
>>>>>    }
>>>>>    -ASTConsumer *CodeGenAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                              StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>>      BackendAction BA = static_cast<BackendAction>(Act);
>>>>>      std::unique_ptr<raw_ostream> OS(GetOutputStream(CI, InFile, BA));
>>>>>      if (BA != Backend_EmitNothing && !OS)
>>>>> @@ -623,11 +623,12 @@ ASTConsumer *CodeGenAction::CreateASTCon
>>>>>        LinkModuleToUse = ModuleOrErr.get();
>>>>>      }
>>>>>    -  BEConsumer = new BackendConsumer(BA, CI.getDiagnostics(),
>>>>> CI.getCodeGenOpts(),
>>>>> -                                   CI.getTargetOpts(),
>>>>> CI.getLangOpts(),
>>>>> -                                   CI.getFrontendOpts().ShowTimers,
>>>>> InFile,
>>>>> -                                   LinkModuleToUse, OS.release(),
>>>>> *VMContext);
>>>>> -  return BEConsumer;
>>>>> +  auto Result = llvm::make_unique<BackendConsumer>(
>>>>> +      BA, CI.getDiagnostics(), CI.getCodeGenOpts(), CI.getTargetOpts(),
>>>>> +      CI.getLangOpts(), (bool)CI.getFrontendOpts().ShowTimers, InFile,
>>>>> +      LinkModuleToUse, OS.release(), *VMContext);
>>>>> +  BEConsumer = Result.get();
>>>>> +  return std::move(Result);
>>>>>    }
>>>>>      void CodeGenAction::ExecuteAction() {
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/ASTConsumers.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTConsumers.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/ASTConsumers.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/ASTConsumers.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -118,17 +118,19 @@ namespace {
>>>>>      };
>>>>>    } // end anonymous namespace
>>>>>    -ASTConsumer *clang::CreateASTPrinter(raw_ostream *Out,
>>>>> -                                     StringRef FilterString) {
>>>>> -  return new ASTPrinter(Out, /*Dump=*/ false, FilterString);
>>>>> +std::unique_ptr<ASTConsumer> clang::CreateASTPrinter(raw_ostream *Out,
>>>>> +                                                     StringRef
>>>>> FilterString) {
>>>>> +  return llvm::make_unique<ASTPrinter>(Out, /*Dump=*/false,
>>>>> FilterString);
>>>>>    }
>>>>>    -ASTConsumer *clang::CreateASTDumper(StringRef FilterString, bool
>>>>> DumpLookups) {
>>>>> -  return new ASTPrinter(nullptr, /*Dump=*/true, FilterString,
>>>>> DumpLookups);
>>>>> +std::unique_ptr<ASTConsumer> clang::CreateASTDumper(StringRef
>>>>> FilterString,
>>>>> +                                                    bool DumpLookups) {
>>>>> +  return llvm::make_unique<ASTPrinter>(nullptr, /*Dump=*/true,
>>>>> FilterString,
>>>>> +                                       DumpLookups);
>>>>>    }
>>>>>    -ASTConsumer *clang::CreateASTDeclNodeLister() {
>>>>> -  return new ASTDeclNodeLister(nullptr);
>>>>> +std::unique_ptr<ASTConsumer> clang::CreateASTDeclNodeLister() {
>>>>> +  return llvm::make_unique<ASTDeclNodeLister>(nullptr);
>>>>>    }
>>>>>
>>>>>
>>>>> //===----------------------------------------------------------------------===//
>>>>> @@ -164,8 +166,9 @@ void ASTViewer::HandleTopLevelSingleDecl
>>>>>      }
>>>>>    }
>>>>>    -
>>>>> -ASTConsumer *clang::CreateASTViewer() { return new ASTViewer(); }
>>>>> +std::unique_ptr<ASTConsumer> clang::CreateASTViewer() {
>>>>> +  return llvm::make_unique<ASTViewer>();
>>>>> +}
>>>>>
>>>>>
>>>>> //===----------------------------------------------------------------------===//
>>>>>    /// DeclContextPrinter - Decl and DeclContext Visualization
>>>>> @@ -475,6 +478,6 @@ void DeclContextPrinter::PrintDeclContex
>>>>>        }
>>>>>      }
>>>>>    }
>>>>> -ASTConsumer *clang::CreateDeclContextPrinter() {
>>>>> -  return new DeclContextPrinter();
>>>>> +std::unique_ptr<ASTConsumer> clang::CreateDeclContextPrinter() {
>>>>> +  return llvm::make_unique<DeclContextPrinter>();
>>>>>    }
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/ASTMerge.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTMerge.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/ASTMerge.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/ASTMerge.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -16,8 +16,8 @@
>>>>>      using namespace clang;
>>>>>    -ASTConsumer *ASTMergeAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                               StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ASTMergeAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>>      return AdaptedAction->CreateASTConsumer(CI, InFile);
>>>>>    }
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -891,12 +891,12 @@ class TopLevelDeclTrackerAction : public
>>>>>    public:
>>>>>      ASTUnit &Unit;
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override {
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override {
>>>>>        CI.getPreprocessor().addPPCallbacks(
>>>>>         new
>>>>> MacroDefinitionTrackerPPCallbacks(Unit.getCurrentTopLevelHashValue()));
>>>>> -    return new TopLevelDeclTrackerConsumer(Unit,
>>>>> -
>>>>> Unit.getCurrentTopLevelHashValue());
>>>>> +    return llvm::make_unique<TopLevelDeclTrackerConsumer>(
>>>>> +        Unit, Unit.getCurrentTopLevelHashValue());
>>>>>      }
>>>>>      public:
>>>>> @@ -916,8 +916,8 @@ public:
>>>>>      explicit PrecompilePreambleAction(ASTUnit &Unit)
>>>>>          : Unit(Unit), HasEmittedPreamblePCH(false) {}
>>>>>    -  ASTConsumer *CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                 StringRef InFile) override;
>>>>> +  std::unique_ptr<ASTConsumer> CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                                 StringRef InFile)
>>>>> override;
>>>>>      bool hasEmittedPreamblePCH() const { return HasEmittedPreamblePCH;
>>>>> }
>>>>>      void setHasEmittedPreamblePCH() { HasEmittedPreamblePCH = true; }
>>>>>      bool shouldEraseOutputFiles() override { return
>>>>> !hasEmittedPreamblePCH(); }
>>>>> @@ -979,8 +979,9 @@ public:
>>>>>      }
>>>>>    -ASTConsumer
>>>>> *PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                                         StringRef
>>>>> InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +PrecompilePreambleAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                            StringRef InFile) {
>>>>>      std::string Sysroot;
>>>>>      std::string OutputFile;
>>>>>      raw_ostream *OS = nullptr;
>>>>> @@ -993,8 +994,8 @@ ASTConsumer *PrecompilePreambleAction::C
>>>>>        CI.getPreprocessor().addPPCallbacks(new
>>>>> MacroDefinitionTrackerPPCallbacks(
>>>>>          Unit.getCurrentTopLevelHashValue()));
>>>>> -  return new PrecompilePreambleConsumer(Unit, this,
>>>>> CI.getPreprocessor(),
>>>>> -                                        Sysroot, OS);
>>>>> +  return llvm::make_unique<PrecompilePreambleConsumer>(
>>>>> +      Unit, this, CI.getPreprocessor(), Sysroot, OS);
>>>>>    }
>>>>>      static bool isNonDriverDiag(const StoredDiagnostic &StoredDiag) {
>>>>> @@ -1689,7 +1690,7 @@ void ASTUnit::transferASTDataFromCompile
>>>>>      assert(CI.hasInvocation() && "missing invocation");
>>>>>      LangOpts = CI.getInvocation().LangOpts;
>>>>>      TheSema.reset(CI.takeSema());
>>>>> -  Consumer.reset(CI.takeASTConsumer());
>>>>> +  Consumer = CI.takeASTConsumer();
>>>>>      if (CI.hasASTContext())
>>>>>        Ctx = &CI.getASTContext();
>>>>>      if (CI.hasPreprocessor())
>>>>> @@ -1863,12 +1864,13 @@ ASTUnit *ASTUnit::LoadFromCompilerInvoca
>>>>>      if (Persistent && !TrackerAct) {
>>>>>        Clang->getPreprocessor().addPPCallbacks(
>>>>>         new
>>>>> MacroDefinitionTrackerPPCallbacks(AST->getCurrentTopLevelHashValue()));
>>>>> -    std::vector<ASTConsumer*> Consumers;
>>>>> +    std::vector<std::unique_ptr<ASTConsumer>> Consumers;
>>>>>        if (Clang->hasASTConsumer())
>>>>>          Consumers.push_back(Clang->takeASTConsumer());
>>>>> -    Consumers.push_back(new TopLevelDeclTrackerConsumer(*AST,
>>>>> -
>>>>> AST->getCurrentTopLevelHashValue()));
>>>>> -    Clang->setASTConsumer(new MultiplexConsumer(Consumers));
>>>>> +    Consumers.push_back(llvm::make_unique<TopLevelDeclTrackerConsumer>(
>>>>> +        *AST, AST->getCurrentTopLevelHashValue()));
>>>>> +    Clang->setASTConsumer(
>>>>> +        llvm::make_unique<MultiplexConsumer>(std::move(Consumers)));
>>>>>      }
>>>>>      if (!Act->Execute()) {
>>>>>        AST->transferASTDataFromCompilerInstance(*Clang);
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/ChainedIncludesSource.cpp Thu Jul 17 15:40:36
>>>>> 2014
>>>>> @@ -158,12 +158,12 @@ IntrusiveRefCntPtr<ExternalSemaSource> c
>>>>>          SmallVector<char, 256> serialAST;
>>>>>        llvm::raw_svector_ostream OS(serialAST);
>>>>> -    std::unique_ptr<ASTConsumer> consumer;
>>>>> -    consumer.reset(new PCHGenerator(Clang->getPreprocessor(), "-",
>>>>> nullptr,
>>>>> -                                    /*isysroot=*/"", &OS));
>>>>> +    auto consumer =
>>>>> +        llvm::make_unique<PCHGenerator>(Clang->getPreprocessor(), "-",
>>>>> nullptr,
>>>>> +                                        /*isysroot=*/"", &OS);
>>>>>        Clang->getASTContext().setASTMutationListener(
>>>>>
>>>>> consumer->GetASTMutationListener());
>>>>> -    Clang->setASTConsumer(consumer.release());
>>>>> +    Clang->setASTConsumer(std::move(consumer));
>>>>>        Clang->createSema(TU_Prefix, nullptr);
>>>>>          if (firstInclude) {
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/CompilerInstance.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/CompilerInstance.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/CompilerInstance.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/CompilerInstance.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -101,8 +101,8 @@ void CompilerInstance::setSema(Sema *S)
>>>>>      TheSema.reset(S);
>>>>>    }
>>>>>    -void CompilerInstance::setASTConsumer(ASTConsumer *Value) {
>>>>> -  Consumer.reset(Value);
>>>>> +void CompilerInstance::setASTConsumer(std::unique_ptr<ASTConsumer>
>>>>> Value)
>>>>> {
>>>>> +  Consumer = std::move(Value);
>>>>>    }
>>>>>      void
>>>>> CompilerInstance::setCodeCompletionConsumer(CodeCompleteConsumer
>>>>> *Value) {
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/FrontendAction.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendAction.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/FrontendAction.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/FrontendAction.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -134,9 +134,10 @@ void FrontendAction::setCurrentInput(con
>>>>>      CurrentASTUnit.reset(AST);
>>>>>    }
>>>>>    -ASTConsumer*
>>>>> FrontendAction::CreateWrappedASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                      StringRef InFile)
>>>>> {
>>>>> -  ASTConsumer* Consumer = CreateASTConsumer(CI, InFile);
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +FrontendAction::CreateWrappedASTConsumer(CompilerInstance &CI,
>>>>> +                                         StringRef InFile) {
>>>>> +  std::unique_ptr<ASTConsumer> Consumer = CreateASTConsumer(CI,
>>>>> InFile);
>>>>>      if (!Consumer)
>>>>>        return nullptr;
>>>>>    @@ -145,7 +146,8 @@ ASTConsumer* FrontendAction::CreateWrapp
>>>>>        // Make sure the non-plugin consumer is first, so that plugins
>>>>> can't
>>>>>      // modifiy the AST.
>>>>> -  std::vector<ASTConsumer*> Consumers(1, Consumer);
>>>>> +  std::vector<std::unique_ptr<ASTConsumer>> Consumers;
>>>>> +  Consumers.push_back(std::move(Consumer));
>>>>>        for (size_t i = 0, e =
>>>>> CI.getFrontendOpts().AddPluginActions.size();
>>>>>           i != e; ++i) {
>>>>> @@ -155,16 +157,15 @@ ASTConsumer* FrontendAction::CreateWrapp
>>>>>            it = FrontendPluginRegistry::begin(),
>>>>>            ie = FrontendPluginRegistry::end();
>>>>>            it != ie; ++it) {
>>>>> -      if (it->getName() == CI.getFrontendOpts().AddPluginActions[i]) {
>>>>> -        std::unique_ptr<PluginASTAction> P(it->instantiate());
>>>>> -        FrontendAction* c = P.get();
>>>>> -        if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i]))
>>>>> -          Consumers.push_back(c->CreateASTConsumer(CI, InFile));
>>>>> -      }
>>>>> +      if (it->getName() != CI.getFrontendOpts().AddPluginActions[i])
>>>>> +        continue;
>>>>> +      std::unique_ptr<PluginASTAction> P = it->instantiate();
>>>>> +      if (P->ParseArgs(CI, CI.getFrontendOpts().AddPluginArgs[i]))
>>>>> +        Consumers.push_back(P->CreateASTConsumer(CI, InFile));
>>>>>        }
>>>>>      }
>>>>>    -  return new MultiplexConsumer(Consumers);
>>>>> +  return llvm::make_unique<MultiplexConsumer>(std::move(Consumers));
>>>>>    }
>>>>>      bool FrontendAction::BeginSourceFile(CompilerInstance &CI,
>>>>> @@ -307,8 +308,8 @@ bool FrontendAction::BeginSourceFile(Com
>>>>>      if (!usesPreprocessorOnly()) {
>>>>>        CI.createASTContext();
>>>>>    -    std::unique_ptr<ASTConsumer> Consumer(
>>>>> -        CreateWrappedASTConsumer(CI, InputFile));
>>>>> +    std::unique_ptr<ASTConsumer> Consumer =
>>>>> +        CreateWrappedASTConsumer(CI, InputFile);
>>>>>        if (!Consumer)
>>>>>          goto failure;
>>>>>    @@ -349,7 +350,7 @@ bool FrontendAction::BeginSourceFile(Com
>>>>>            goto failure;
>>>>>        }
>>>>>    -    CI.setASTConsumer(Consumer.release());
>>>>> +    CI.setASTConsumer(std::move(Consumer));
>>>>>        if (!CI.hasASTConsumer())
>>>>>          goto failure;
>>>>>      }
>>>>> @@ -444,7 +445,7 @@ void FrontendAction::EndSourceFile() {
>>>>>          CI.resetAndLeakSema();
>>>>>          CI.resetAndLeakASTContext();
>>>>>        }
>>>>> -    BuryPointer(CI.takeASTConsumer());
>>>>> +    BuryPointer(CI.takeASTConsumer().get());
>>>>>      } else {
>>>>>        if (!isCurrentFileAST()) {
>>>>>          CI.setSema(nullptr);
>>>>> @@ -516,14 +517,15 @@ void ASTFrontendAction::ExecuteAction()
>>>>>      void PluginASTAction::anchor() { }
>>>>>    -ASTConsumer *
>>>>> +std::unique_ptr<ASTConsumer>
>>>>>    PreprocessorFrontendAction::CreateASTConsumer(CompilerInstance &CI,
>>>>>                                                  StringRef InFile) {
>>>>>      llvm_unreachable("Invalid CreateASTConsumer on preprocessor
>>>>> action!");
>>>>>    }
>>>>>    -ASTConsumer
>>>>> *WrapperFrontendAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                      StringRef InFile)
>>>>> {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +WrapperFrontendAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                         StringRef InFile) {
>>>>>      return WrappedAction->CreateASTConsumer(CI, InFile);
>>>>>    }
>>>>>    bool WrapperFrontendAction::BeginInvocation(CompilerInstance &CI) {
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/FrontendActions.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/FrontendActions.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/FrontendActions.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/FrontendActions.cpp Thu Jul 17 15:40:36 2014
>>>>> @@ -33,9 +33,9 @@ using namespace clang;
>>>>>    // Custom Actions
>>>>>
>>>>>
>>>>> //===----------------------------------------------------------------------===//
>>>>>    -ASTConsumer *InitOnlyAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                               StringRef InFile) {
>>>>> -  return new ASTConsumer();
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +InitOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>> +  return llvm::make_unique<ASTConsumer>();
>>>>>    }
>>>>>      void InitOnlyAction::ExecuteAction() {
>>>>> @@ -45,36 +45,37 @@ void InitOnlyAction::ExecuteAction() {
>>>>>    // AST Consumer Actions
>>>>>
>>>>>
>>>>> //===----------------------------------------------------------------------===//
>>>>>    -ASTConsumer *ASTPrintAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                               StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ASTPrintAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>>      if (raw_ostream *OS = CI.createDefaultOutputFile(false, InFile))
>>>>>        return CreateASTPrinter(OS, CI.getFrontendOpts().ASTDumpFilter);
>>>>>      return nullptr;
>>>>>    }
>>>>>    -ASTConsumer *ASTDumpAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                              StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ASTDumpAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>>      return CreateASTDumper(CI.getFrontendOpts().ASTDumpFilter,
>>>>>                             CI.getFrontendOpts().ASTDumpLookups);
>>>>>    }
>>>>>    -ASTConsumer *ASTDeclListAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                  StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ASTDeclListAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>>      return CreateASTDeclNodeLister();
>>>>>    }
>>>>>    -ASTConsumer *ASTViewAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> -                                              StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +ASTViewAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile)
>>>>> {
>>>>>      return CreateASTViewer();
>>>>>    }
>>>>>    -ASTConsumer
>>>>> *DeclContextPrintAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                       StringRef
>>>>> InFile)
>>>>> {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +DeclContextPrintAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                          StringRef InFile) {
>>>>>      return CreateDeclContextPrinter();
>>>>>    }
>>>>>    -ASTConsumer *GeneratePCHAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                  StringRef InFile) {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +GeneratePCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>>      std::string Sysroot;
>>>>>      std::string OutputFile;
>>>>>      raw_ostream *OS = nullptr;
>>>>> @@ -83,8 +84,8 @@ ASTConsumer *GeneratePCHAction::CreateAS
>>>>>        if (!CI.getFrontendOpts().RelocatablePCH)
>>>>>        Sysroot.clear();
>>>>> -  return new PCHGenerator(CI.getPreprocessor(), OutputFile, nullptr,
>>>>> Sysroot,
>>>>> -                          OS);
>>>>> +  return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(),
>>>>> OutputFile,
>>>>> +                                         nullptr, Sysroot, OS);
>>>>>    }
>>>>>      bool
>>>>> GeneratePCHAction::ComputeASTConsumerArguments(CompilerInstance
>>>>> &CI,
>>>>> @@ -111,16 +112,17 @@ bool GeneratePCHAction::ComputeASTConsum
>>>>>      return false;
>>>>>    }
>>>>>    -ASTConsumer
>>>>> *GenerateModuleAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                     StringRef InFile)
>>>>> {
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +GenerateModuleAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                        StringRef InFile) {
>>>>>      std::string Sysroot;
>>>>>      std::string OutputFile;
>>>>>      raw_ostream *OS = nullptr;
>>>>>      if (ComputeASTConsumerArguments(CI, InFile, Sysroot, OutputFile,
>>>>> OS))
>>>>>        return nullptr;
>>>>>    -  return new PCHGenerator(CI.getPreprocessor(), OutputFile, Module,
>>>>> -                          Sysroot, OS);
>>>>> +  return llvm::make_unique<PCHGenerator>(CI.getPreprocessor(),
>>>>> OutputFile,
>>>>> +                                         Module, Sysroot, OS);
>>>>>    }
>>>>>      static SmallVectorImpl<char> &
>>>>> @@ -363,19 +365,20 @@ bool GenerateModuleAction::ComputeASTCon
>>>>>      return false;
>>>>>    }
>>>>>    -ASTConsumer *SyntaxOnlyAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                 StringRef InFile) {
>>>>> -  return new ASTConsumer();
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +SyntaxOnlyAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>> +  return llvm::make_unique<ASTConsumer>();
>>>>>    }
>>>>>    -ASTConsumer
>>>>> *DumpModuleInfoAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                     StringRef InFile)
>>>>> {
>>>>> -  return new ASTConsumer();
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +DumpModuleInfoAction::CreateASTConsumer(CompilerInstance &CI,
>>>>> +                                        StringRef InFile) {
>>>>> +  return llvm::make_unique<ASTConsumer>();
>>>>>    }
>>>>>    -ASTConsumer *VerifyPCHAction::CreateASTConsumer(CompilerInstance
>>>>> &CI,
>>>>> -                                                StringRef InFile) {
>>>>> -  return new ASTConsumer();
>>>>> +std::unique_ptr<ASTConsumer>
>>>>> +VerifyPCHAction::CreateASTConsumer(CompilerInstance &CI, StringRef
>>>>> InFile) {
>>>>> +  return llvm::make_unique<ASTConsumer>();
>>>>>    }
>>>>>      void VerifyPCHAction::ExecuteAction() {
>>>>>
>>>>> Modified: cfe/trunk/lib/Frontend/MultiplexConsumer.cpp
>>>>> URL:
>>>>>
>>>>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/MultiplexConsumer.cpp?rev=213307&r1=213306&r2=213307&view=diff
>>>>>
>>>>>
>>>>> ==============================================================================
>>>>> --- cfe/trunk/lib/Frontend/MultiplexConsumer.cpp (original)
>>>>> +++ cfe/trunk/lib/Frontend/MultiplexConsumer.cpp Thu Jul 17 15:40:36
>>>>> 2014
>>>>> @@ -183,118 +183,113 @@ void MultiplexASTMutationListener::Decla
>>>>>      }  // end namespace clang
>>>>>    -MultiplexConsumer::MultiplexConsumer(ArrayRef<ASTConsumer *> C)
>>>>> -    : Consumers(C.begin(), C.end()), MutationListener(),
>>>>> -      DeserializationListener() {
>>>>> +MultiplexConsumer::MultiplexConsumer(
>>>>> +    std::vector<std::unique_ptr<ASTConsumer>> C)
>>>>> +    : Consumers(std::move(C)), MutationListener(),
>>>>> DeserializationListener() {
>>>>>      // Collect the mutation listeners and deserialization listeners of
>>>>> all
>>>>>      // children, and create a multiplex listener each if so.
>>>>>      std::vector<ASTMutationListener*> mutationListeners;
>>>>>      std::vector<ASTDeserializationListener*> serializationListeners;
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i) {
>>>>> -    ASTMutationListener* mutationListener =
>>>>> -        Consumers[i]->GetASTMutationListener();
>>>>> -    if (mutationListener)
>>>>> +  for (auto &Consumer : Consumers) {
>>>>> +    if (auto *mutationListener = Consumer->GetASTMutationListener())
>>>>>          mutationListeners.push_back(mutationListener);
>>>>> -    ASTDeserializationListener* serializationListener =
>>>>> -        Consumers[i]->GetASTDeserializationListener();
>>>>> -    if (serializationListener)
>>>>> +    if (auto *serializationListener =
>>>>> Consumer->GetASTDeserializationListener())
>>>>>          serializationListeners.push_back(serializationListener);
>>>>>      }
>>>>> -  if (mutationListeners.size()) {
>>>>> -    MutationListener.reset(new
>>>>> MultiplexASTMutationListener(mutationListeners));
>>>>> +  if (!mutationListeners.empty()) {
>>>>> +    MutationListener =
>>>>> +
>>>>> llvm::make_unique<MultiplexASTMutationListener>(mutationListeners);
>>>>>      }
>>>>> -  if (serializationListeners.size()) {
>>>>> -    DeserializationListener.reset(
>>>>> -        new
>>>>> MultiplexASTDeserializationListener(serializationListeners));
>>>>> +  if (!serializationListeners.empty()) {
>>>>> +    DeserializationListener =
>>>>> +        llvm::make_unique<MultiplexASTDeserializationListener>(
>>>>> +            serializationListeners);
>>>>>      }
>>>>>    }
>>>>>    -MultiplexConsumer::~MultiplexConsumer() {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    delete Consumers[i];
>>>>> -}
>>>>> +MultiplexConsumer::~MultiplexConsumer() {}
>>>>>      void MultiplexConsumer::Initialize(ASTContext &Context) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->Initialize(Context);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->Initialize(Context);
>>>>>    }
>>>>>      bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) {
>>>>>      bool Continue = true;
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Continue = Continue && Consumers[i]->HandleTopLevelDecl(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Continue = Continue && Consumer->HandleTopLevelDecl(D);
>>>>>      return Continue;
>>>>>    }
>>>>>      void MultiplexConsumer::HandleInlineMethodDefinition(CXXMethodDecl
>>>>> *D)
>>>>> {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleInlineMethodDefinition(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleInlineMethodDefinition(D);
>>>>>    }
>>>>>    -void
>>>>> MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl
>>>>> *VD) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleCXXStaticMemberVarInstantiation(VD);
>>>>> +void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl
>>>>> *VD) {
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleCXXStaticMemberVarInstantiation(VD);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleInterestingDecl(DeclGroupRef D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleInterestingDecl(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleInterestingDecl(D);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleTranslationUnit(ASTContext &Ctx) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleTranslationUnit(Ctx);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleTranslationUnit(Ctx);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleTagDeclDefinition(TagDecl *D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleTagDeclDefinition(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleTagDeclDefinition(D);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleTagDeclRequiredDefinition(const
>>>>> TagDecl
>>>>> *D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleTagDeclRequiredDefinition(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleTagDeclRequiredDefinition(D);
>>>>>    }
>>>>>      void
>>>>> MultiplexConsumer::HandleCXXImplicitFunctionInstantiation(FunctionDecl
>>>>> *D){
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleCXXImplicitFunctionInstantiation(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleCXXImplicitFunctionInstantiation(D);
>>>>>    }
>>>>>      void
>>>>> MultiplexConsumer::HandleTopLevelDeclInObjCContainer(DeclGroupRef
>>>>> D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleTopLevelDeclInObjCContainer(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleTopLevelDeclInObjCContainer(D);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleImplicitImportDecl(ImportDecl *D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleImplicitImportDecl(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleImplicitImportDecl(D);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleLinkerOptionPragma(llvm::StringRef
>>>>> Opts)
>>>>> {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleLinkerOptionPragma(Opts);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleLinkerOptionPragma(Opts);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleDetectMismatch(llvm::StringRef Name,
>>>>> llvm::StringRef Value) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleDetectMismatch(Name, Value);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleDetectMismatch(Name, Value);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleDependentLibrary(llvm::StringRef Lib)
>>>>> {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleDependentLibrary(Lib);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->HandleDependentLibrary(Lib);
>>>>>    }
>>>>>      void MultiplexConsumer::CompleteTentativeDefinition(VarDecl *D) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->CompleteTentativeDefinition(D);
>>>>> +  for (auto &Consumer : Consumers)
>>>>> +    Consumer->CompleteTentativeDefinition(D);
>>>>>    }
>>>>>      void MultiplexConsumer::HandleVTable(
>>>>>        CXXRecordDecl *RD, bool DefinitionRequired) {
>>>>> -  for (size_t i = 0, e = Consumers.size(); i != e; ++i)
>>>>> -    Consumers[i]->HandleVTable(RD, DefinitionRequired);



More information about the cfe-commits mailing list