]> granicus.if.org Git - clang/commitdiff
Revert "IntrusiveRefCntPtr -> std::shared_ptr for CompilerInvocationBase and CodeComp...
authorDavid Blaikie <dblaikie@gmail.com>
Fri, 6 Jan 2017 17:47:10 +0000 (17:47 +0000)
committerDavid Blaikie <dblaikie@gmail.com>
Fri, 6 Jan 2017 17:47:10 +0000 (17:47 +0000)
Caused a memory leak reported by asan. Reverting while I investigate.

This reverts commit r291184.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@291249 91177308-0d34-0410-b5e6-96231b3b80d8

24 files changed:
include/clang/Frontend/ASTUnit.h
include/clang/Frontend/CompilerInstance.h
include/clang/Frontend/CompilerInvocation.h
include/clang/Frontend/Utils.h
include/clang/Sema/CodeCompleteConsumer.h
include/clang/Tooling/Tooling.h
lib/ARCMigrate/ARCMT.cpp
lib/Frontend/ASTUnit.cpp
lib/Frontend/ChainedIncludesSource.cpp
lib/Frontend/CompilerInstance.cpp
lib/Frontend/CompilerInvocation.cpp
lib/Frontend/CreateInvocationFromCommandLine.cpp
lib/StaticAnalyzer/Frontend/ModelInjector.cpp
lib/Tooling/Tooling.cpp
tools/c-index-test/core_main.cpp
tools/clang-import-test/clang-import-test.cpp
tools/diagtool/ShowEnabledWarnings.cpp
tools/libclang/CIndex.cpp
tools/libclang/CIndexCodeCompletion.cpp
tools/libclang/CXTranslationUnit.h
tools/libclang/Indexing.cpp
unittests/AST/ExternalASTSourceTest.cpp
unittests/Frontend/CodeGenActionTest.cpp
unittests/Frontend/FrontendActionTest.cpp

index b1cdb46d505bfd0d2451908c9f9ea1aea3ccaa2c..65841d708212c0614c8a0c931f4d692ed9d596c0 100644 (file)
@@ -108,8 +108,8 @@ private:
 
   /// Optional owned invocation, just used to make the invocation used in
   /// LoadFromCommandLine available.
-  std::shared_ptr<CompilerInvocation> Invocation;
-
+  IntrusiveRefCntPtr<CompilerInvocation> Invocation;
+  
   // OnlyLocalDecls - when true, walking this AST should only visit declarations
   // that come from the AST itself, not from included precompiled headers.
   // FIXME: This is temporary; eventually, CIndex will always do this.
@@ -358,21 +358,22 @@ public:
   }
   
   /// \brief Retrieve the allocator used to cache global code completions.
-  std::shared_ptr<GlobalCodeCompletionAllocator>
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator>
   getCachedCompletionAllocator() {
     return CachedCompletionAllocator;
   }
 
   CodeCompletionTUInfo &getCodeCompletionTUInfo() {
     if (!CCTUInfo)
-      CCTUInfo = llvm::make_unique<CodeCompletionTUInfo>(
-          std::make_shared<GlobalCodeCompletionAllocator>());
+      CCTUInfo.reset(new CodeCompletionTUInfo(
+                                            new GlobalCodeCompletionAllocator));
     return *CCTUInfo;
   }
 
 private:
   /// \brief Allocator used to store cached code completions.
-  std::shared_ptr<GlobalCodeCompletionAllocator> CachedCompletionAllocator;
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator>
+    CachedCompletionAllocator;
 
   std::unique_ptr<CodeCompletionTUInfo> CCTUInfo;
 
@@ -701,11 +702,11 @@ public:
   /// remapped contents of that file.
   typedef std::pair<std::string, llvm::MemoryBuffer *> RemappedFile;
 
-  /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation.
-  static std::unique_ptr<ASTUnit>
-  create(std::shared_ptr<CompilerInvocation> CI,
-         IntrusiveRefCntPtr<DiagnosticsEngine> Diags, bool CaptureDiagnostics,
-         bool UserFilesAreVolatile);
+  /// \brief Create a ASTUnit. Gets ownership of the passed CompilerInvocation. 
+  static ASTUnit *create(CompilerInvocation *CI,
+                         IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+                         bool CaptureDiagnostics,
+                         bool UserFilesAreVolatile);
 
   /// \brief Create a ASTUnit from an AST file.
   ///
@@ -770,7 +771,7 @@ public:
   /// created ASTUnit was passed in \p Unit then the caller can check that.
   ///
   static ASTUnit *LoadFromCompilerInvocationAction(
-      std::shared_ptr<CompilerInvocation> CI,
+      CompilerInvocation *CI,
       std::shared_ptr<PCHContainerOperations> PCHContainerOps,
       IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
       FrontendAction *Action = nullptr, ASTUnit *Unit = nullptr,
@@ -797,7 +798,7 @@ public:
   // FIXME: Move OnlyLocalDecls, UseBumpAllocator to setters on the ASTUnit, we
   // shouldn't need to specify them at construction time.
   static std::unique_ptr<ASTUnit> LoadFromCompilerInvocation(
-      std::shared_ptr<CompilerInvocation> CI,
+      CompilerInvocation *CI,
       std::shared_ptr<PCHContainerOperations> PCHContainerOps,
       IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
       bool OnlyLocalDecls = false, bool CaptureDiagnostics = false,
index 3ebbc61515c660ff1f094fe64a4d95c9761fbb1e..b8fd6cc12595fb2d7e0e906add830972b7b4c6d3 100644 (file)
@@ -70,7 +70,7 @@ class TargetInfo;
 /// and a long form that takes explicit instances of any required objects.
 class CompilerInstance : public ModuleLoader {
   /// The options used in this compiler instance.
-  std::shared_ptr<CompilerInvocation> Invocation;
+  IntrusiveRefCntPtr<CompilerInvocation> Invocation;
 
   /// The diagnostics engine instance.
   IntrusiveRefCntPtr<DiagnosticsEngine> Diagnostics;
@@ -228,7 +228,7 @@ public:
   }
 
   /// setInvocation - Replace the current invocation.
-  void setInvocation(std::shared_ptr<CompilerInvocation> Value);
+  void setInvocation(CompilerInvocation *Value);
 
   /// \brief Indicates whether we should (re)build the global module index.
   bool shouldBuildGlobalModuleIndex() const;
index cef7f73ecaa0f97160942563d9bcd77d947aaf27..939ff3cc9f0fbe53f8632f6866bdd268b99c8788 100644 (file)
@@ -51,7 +51,7 @@ bool ParseDiagnosticArgs(DiagnosticOptions &Opts, llvm::opt::ArgList &Args,
                          bool DefaultDiagColor = true,
                          bool DefaultShowOpt = true);
 
-class CompilerInvocationBase {
+class CompilerInvocationBase : public RefCountedBase<CompilerInvocation> {
   void operator=(const CompilerInvocationBase &) = delete;
 
 public:
index 0ee46846c804e5a6d5a5449e04e7acdc7ca818d9..60419ff9b41d639499dae0f3cbd1172fef20599e 100644 (file)
@@ -184,10 +184,10 @@ createChainedIncludesSource(CompilerInstance &CI,
 ///
 /// \return A CompilerInvocation, or 0 if none was built for the given
 /// argument vector.
-std::unique_ptr<CompilerInvocation>
+CompilerInvocation *
 createInvocationFromCommandLine(ArrayRef<const char *> Args,
-                                IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
-                                    IntrusiveRefCntPtr<DiagnosticsEngine>());
+                            IntrusiveRefCntPtr<DiagnosticsEngine> Diags =
+                                IntrusiveRefCntPtr<DiagnosticsEngine>());
 
 /// Return the value of the last argument as an integer, or a default. If Diags
 /// is non-null, emits an error if the argument is given, but non-integral.
index dee53dc14a8caf6c95c4116f5ca2cfdca1ba2f52..b80924ea11fcdeee2c71d72d7e31e020982d0642 100644 (file)
@@ -509,18 +509,23 @@ public:
 };
 
 /// \brief Allocator for a cached set of global code completions.
-class GlobalCodeCompletionAllocator : public CodeCompletionAllocator {};
+class GlobalCodeCompletionAllocator 
+  : public CodeCompletionAllocator,
+    public RefCountedBase<GlobalCodeCompletionAllocator>
+{
+
+};
 
 class CodeCompletionTUInfo {
   llvm::DenseMap<const DeclContext *, StringRef> ParentNames;
-  std::shared_ptr<GlobalCodeCompletionAllocator> AllocatorRef;
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> AllocatorRef;
 
 public:
   explicit CodeCompletionTUInfo(
-      std::shared_ptr<GlobalCodeCompletionAllocator> Allocator)
+      IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> Allocator)
       : AllocatorRef(std::move(Allocator)) {}
 
-  std::shared_ptr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
+  IntrusiveRefCntPtr<GlobalCodeCompletionAllocator> getAllocatorRef() const {
     return AllocatorRef;
   }
   CodeCompletionAllocator &getAllocator() const {
@@ -960,8 +965,8 @@ public:
   /// results to the given raw output stream.
   PrintingCodeCompleteConsumer(const CodeCompleteOptions &CodeCompleteOpts,
                                raw_ostream &OS)
-      : CodeCompleteConsumer(CodeCompleteOpts, false), OS(OS),
-        CCTUInfo(std::make_shared<GlobalCodeCompletionAllocator>()) {}
+    : CodeCompleteConsumer(CodeCompleteOpts, false), OS(OS),
+      CCTUInfo(new GlobalCodeCompletionAllocator) {}
 
   /// \brief Prints the finalized code-completion results.
   void ProcessCodeCompleteResults(Sema &S, CodeCompletionContext Context,
index 10e26ac25d174b5f0ccc5830467a755fec7882b1..ca232f40983180fd59f5e6998aa72af65ba5c7b5 100644 (file)
@@ -69,8 +69,7 @@ public:
 
   /// \brief Perform an action for an invocation.
   virtual bool
-  runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
-                FileManager *Files,
+  runInvocation(clang::CompilerInvocation *Invocation, FileManager *Files,
                 std::shared_ptr<PCHContainerOperations> PCHContainerOps,
                 DiagnosticConsumer *DiagConsumer) = 0;
 };
@@ -86,8 +85,7 @@ public:
   ~FrontendActionFactory() override;
 
   /// \brief Invokes the compiler with a FrontendAction created by create().
-  bool runInvocation(std::shared_ptr<clang::CompilerInvocation> Invocation,
-                     FileManager *Files,
+  bool runInvocation(clang::CompilerInvocation *Invocation, FileManager *Files,
                      std::shared_ptr<PCHContainerOperations> PCHContainerOps,
                      DiagnosticConsumer *DiagConsumer) override;
 
@@ -263,7 +261,7 @@ public:
 
   bool runInvocation(const char *BinaryName,
                      clang::driver::Compilation *Compilation,
-                     std::shared_ptr<clang::CompilerInvocation> Invocation,
+                     clang::CompilerInvocation *Invocation,
                      std::shared_ptr<PCHContainerOperations> PCHContainerOps);
 
   std::vector<std::string> CommandLine;
index cf7cddefc03d62e7fd14ad35fc0e1637345d063f..680aa3e48da401ef3fab94625a69698cd647d4a9 100644 (file)
@@ -271,7 +271,7 @@ bool arcmt::checkForManualIssues(
   Diags->setClient(&errRec, /*ShouldOwnClient=*/false);
 
   std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction(
-      std::move(CInvok), PCHContainerOps, Diags));
+      CInvok.release(), PCHContainerOps, Diags));
   if (!Unit) {
     errRec.FinishCapture();
     return true;
@@ -547,7 +547,7 @@ bool MigrationProcess::applyTransform(TransformFn trans,
   ASTAction.reset(new ARCMTMacroTrackerAction(ARCMTMacroLocs));
 
   std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction(
-      std::move(CInvok), PCHContainerOps, Diags, ASTAction.get()));
+      CInvok.release(), PCHContainerOps, Diags, ASTAction.get()));
   if (!Unit) {
     errRec.FinishCapture();
     return true;
index d8929969e6c1cf8437ed7016051e9456bee721ca..5b77b31e1268f63fefd689d5408b8dde6dfe28f9 100644 (file)
@@ -245,7 +245,7 @@ ASTUnit::~ASTUnit() {
   // perform this operation here because we explicitly request that the
   // compiler instance *not* free these buffers for each invocation of the
   // parser.
-  if (Invocation && OwnsRemappedFileBuffers) {
+  if (Invocation.get() && OwnsRemappedFileBuffers) {
     PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
     for (const auto &RB : PPOpts.RemappedFileBuffers)
       delete RB.second;
@@ -348,7 +348,7 @@ void ASTUnit::CacheCodeCompletionResults() {
   // Gather the set of global code completions.
   typedef CodeCompletionResult Result;
   SmallVector<Result, 8> Results;
-  CachedCompletionAllocator = std::make_shared<GlobalCodeCompletionAllocator>();
+  CachedCompletionAllocator = new GlobalCodeCompletionAllocator;
   CodeCompletionTUInfo CCTUInfo(CachedCompletionAllocator);
   TheSema->GatherGlobalCodeCompletions(*CachedCompletionAllocator,
                                        CCTUInfo, Results);
@@ -1048,7 +1048,10 @@ bool ASTUnit::Parse(std::shared_ptr<PCHContainerOperations> PCHContainerOps,
   llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
     CICleanup(Clang.get());
 
-  Clang->setInvocation(std::make_shared<CompilerInvocation>(*Invocation));
+  IntrusiveRefCntPtr<CompilerInvocation>
+    CCInvocation(new CompilerInvocation(*Invocation));
+
+  Clang->setInvocation(CCInvocation.get());
   OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
     
   // Set up diagnostics, capturing any diagnostics that would
@@ -1341,8 +1344,8 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
     const CompilerInvocation &PreambleInvocationIn, bool AllowRebuild,
     unsigned MaxLines) {
 
-  auto PreambleInvocation =
-      std::make_shared<CompilerInvocation>(PreambleInvocationIn);
+  IntrusiveRefCntPtr<CompilerInvocation>
+    PreambleInvocation(new CompilerInvocation(PreambleInvocationIn));
   FrontendOptions &FrontendOpts = PreambleInvocation->getFrontendOpts();
   PreprocessorOptions &PreprocessorOpts
     = PreambleInvocation->getPreprocessorOpts();
@@ -1520,7 +1523,7 @@ ASTUnit::getMainBufferWithPrecompiledPreamble(
   llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
     CICleanup(Clang.get());
 
-  Clang->setInvocation(std::move(PreambleInvocation));
+  Clang->setInvocation(&*PreambleInvocation);
   OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
   
   // Set up diagnostics, capturing all of the diagnostics produced.
@@ -1706,29 +1709,30 @@ StringRef ASTUnit::getASTFileName() const {
   return Mod.FileName;
 }
 
-std::unique_ptr<ASTUnit>
-ASTUnit::create(std::shared_ptr<CompilerInvocation> CI,
-                IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
-                bool CaptureDiagnostics, bool UserFilesAreVolatile) {
-  std::unique_ptr<ASTUnit> AST(new ASTUnit(false));
+ASTUnit *ASTUnit::create(CompilerInvocation *CI,
+                         IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
+                         bool CaptureDiagnostics,
+                         bool UserFilesAreVolatile) {
+  std::unique_ptr<ASTUnit> AST;
+  AST.reset(new ASTUnit(false));
   ConfigureDiags(Diags, *AST, CaptureDiagnostics);
+  AST->Diagnostics = Diags;
+  AST->Invocation = CI;
+  AST->FileSystemOpts = CI->getFileSystemOpts();
   IntrusiveRefCntPtr<vfs::FileSystem> VFS =
       createVFSFromCompilerInvocation(*CI, *Diags);
   if (!VFS)
     return nullptr;
-  AST->Diagnostics = Diags;
-  AST->FileSystemOpts = CI->getFileSystemOpts();
-  AST->Invocation = std::move(CI);
   AST->FileMgr = new FileManager(AST->FileSystemOpts, VFS);
   AST->UserFilesAreVolatile = UserFilesAreVolatile;
   AST->SourceMgr = new SourceManager(AST->getDiagnostics(), *AST->FileMgr,
                                      UserFilesAreVolatile);
 
-  return AST;
+  return AST.release();
 }
 
 ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
-    std::shared_ptr<CompilerInvocation> CI,
+    CompilerInvocation *CI,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps,
     IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FrontendAction *Action,
     ASTUnit *Unit, bool Persistent, StringRef ResourceFilesPath,
@@ -1742,7 +1746,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
   ASTUnit *AST = Unit;
   if (!AST) {
     // Create the AST unit.
-    OwnAST = create(CI, Diags, CaptureDiagnostics, UserFilesAreVolatile);
+    OwnAST.reset(create(CI, Diags, CaptureDiagnostics, UserFilesAreVolatile));
     AST = OwnAST.get();
     if (!AST)
       return nullptr;
@@ -1781,7 +1785,7 @@ ASTUnit *ASTUnit::LoadFromCompilerInvocationAction(
   llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
     CICleanup(Clang.get());
 
-  Clang->setInvocation(std::move(CI));
+  Clang->setInvocation(CI);
   AST->OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
     
   // Set up diagnostics, capturing any diagnostics that would
@@ -1899,7 +1903,7 @@ bool ASTUnit::LoadFromCompilerInvocation(
 }
 
 std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
-    std::shared_ptr<CompilerInvocation> CI,
+    CompilerInvocation *CI,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps,
     IntrusiveRefCntPtr<DiagnosticsEngine> Diags, FileManager *FileMgr,
     bool OnlyLocalDecls, bool CaptureDiagnostics,
@@ -1916,7 +1920,7 @@ std::unique_ptr<ASTUnit> ASTUnit::LoadFromCompilerInvocation(
   AST->ShouldCacheCodeCompletionResults = CacheCodeCompletionResults;
   AST->IncludeBriefCommentsInCodeCompletion
     = IncludeBriefCommentsInCodeCompletion;
-  AST->Invocation = std::move(CI);
+  AST->Invocation = CI;
   AST->FileSystemOpts = FileMgr->getFileSystemOpts();
   AST->FileMgr = FileMgr;
   AST->UserFilesAreVolatile = UserFilesAreVolatile;
@@ -1948,8 +1952,8 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
   assert(Diags.get() && "no DiagnosticsEngine was provided");
 
   SmallVector<StoredDiagnostic, 4> StoredDiagnostics;
-
-  std::shared_ptr<CompilerInvocation> CI;
+  
+  IntrusiveRefCntPtr<CompilerInvocation> CI;
 
   {
 
@@ -1957,7 +1961,8 @@ ASTUnit *ASTUnit::LoadFromCommandLine(
                                       StoredDiagnostics);
 
     CI = clang::createInvocationFromCommandLine(
-        llvm::makeArrayRef(ArgBegin, ArgEnd), Diags);
+                                           llvm::makeArrayRef(ArgBegin, ArgEnd),
+                                           Diags);
     if (!CI)
       return nullptr;
   }
@@ -2328,7 +2333,8 @@ void ASTUnit::CodeComplete(
   CompletionTimer.setOutput("Code completion @ " + File + ":" +
                             Twine(Line) + ":" + Twine(Column));
 
-  auto CCInvocation = std::make_shared<CompilerInvocation>(*Invocation);
+  IntrusiveRefCntPtr<CompilerInvocation>
+    CCInvocation(new CompilerInvocation(*Invocation));
 
   FrontendOptions &FrontendOpts = CCInvocation->getFrontendOpts();
   CodeCompleteOptions &CodeCompleteOpts = FrontendOpts.CodeCompleteOpts;
@@ -2360,8 +2366,7 @@ void ASTUnit::CodeComplete(
   llvm::CrashRecoveryContextCleanupRegistrar<CompilerInstance>
     CICleanup(Clang.get());
 
-  auto &Inv = *CCInvocation;
-  Clang->setInvocation(std::move(CCInvocation));
+  Clang->setInvocation(&*CCInvocation);
   OriginalSourceFile = Clang->getFrontendOpts().Inputs[0].getFile();
     
   // Set up diagnostics, capturing any diagnostics produced.
@@ -2369,8 +2374,8 @@ void ASTUnit::CodeComplete(
   CaptureDroppedDiagnostics Capture(true, 
                                     Clang->getDiagnostics(), 
                                     StoredDiagnostics);
-  ProcessWarningOptions(Diag, Inv.getDiagnosticOpts());
-
+  ProcessWarningOptions(Diag, CCInvocation->getDiagnosticOpts());
+  
   // Create the target instance.
   Clang->setTarget(TargetInfo::CreateTargetInfo(
       Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
@@ -2426,7 +2431,7 @@ void ASTUnit::CodeComplete(
       if (!llvm::sys::fs::getUniqueID(MainPath, MainID)) {
         if (CompleteFileID == MainID && Line > 1)
           OverrideMainBuffer = getMainBufferWithPrecompiledPreamble(
-              PCHContainerOps, Inv, false, Line - 1);
+              PCHContainerOps, *CCInvocation, false, Line - 1);
       }
     }
   }
index b984c2ed0dd51dfe7ebb077df18f21e3456e08a4..b621facf409043cf9db0f9bb0808767e4c7eba87 100644 (file)
@@ -147,7 +147,7 @@ IntrusiveRefCntPtr<ExternalSemaSource> clang::createChainedIncludesSource(
 
     std::unique_ptr<CompilerInstance> Clang(
         new CompilerInstance(CI.getPCHContainerOperations()));
-    Clang->setInvocation(std::move(CInvok));
+    Clang->setInvocation(CInvok.release());
     Clang->setDiagnostics(Diags.get());
     Clang->setTarget(TargetInfo::CreateTargetInfo(
         Clang->getDiagnostics(), Clang->getInvocation().TargetOpts));
index afcaa6e87878436dd59df5b9ed9c3c75229eb9e1..6f39d48f5967ff5c0e740094b5e89c6ba8523da2 100644 (file)
@@ -66,9 +66,8 @@ CompilerInstance::~CompilerInstance() {
   assert(OutputFiles.empty() && "Still output files in flight?");
 }
 
-void CompilerInstance::setInvocation(
-    std::shared_ptr<CompilerInvocation> Value) {
-  Invocation = std::move(Value);
+void CompilerInstance::setInvocation(CompilerInvocation *Value) {
+  Invocation = Value;
 }
 
 bool CompilerInstance::shouldBuildGlobalModuleIndex() const {
@@ -1020,8 +1019,8 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
     = ImportingInstance.getPreprocessor().getHeaderSearchInfo().getModuleMap();
     
   // Construct a compiler invocation for creating this module.
-  auto Invocation =
-      std::make_shared<CompilerInvocation>(ImportingInstance.getInvocation());
+  IntrusiveRefCntPtr<CompilerInvocation> Invocation
+    (new CompilerInvocation(ImportingInstance.getInvocation()));
 
   PreprocessorOptions &PPOpts = Invocation->getPreprocessorOpts();
   
@@ -1077,8 +1076,7 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
   // module.
   CompilerInstance Instance(ImportingInstance.getPCHContainerOperations(),
                             /*BuildingModule=*/true);
-  auto &Inv = *Invocation;
-  Instance.setInvocation(std::move(Invocation));
+  Instance.setInvocation(&*Invocation);
 
   Instance.createDiagnostics(new ForwardingDiagnosticConsumer(
                                    ImportingInstance.getDiagnosticClient()),
@@ -1100,7 +1098,7 @@ static bool compileModuleImpl(CompilerInstance &ImportingInstance,
   // between all of the module CompilerInstances. Other than that, we don't
   // want to produce any dependency output from the module build.
   Instance.setModuleDepCollector(ImportingInstance.getModuleDepCollector());
-  Inv.getDependencyOutputOpts() = DependencyOutputOptions();
+  Invocation->getDependencyOutputOpts() = DependencyOutputOptions();
 
   // Get or create the module map that we'll use to build this module.
   std::string InferredModuleMapContent;
index 93bbcc42da1a35651e2ba243a8ce68183edef211..86d58a2431709cb75ebc0e21e7c9e84eb8904778 100644 (file)
@@ -60,11 +60,12 @@ CompilerInvocationBase::CompilerInvocationBase()
     PreprocessorOpts(new PreprocessorOptions()) {}
 
 CompilerInvocationBase::CompilerInvocationBase(const CompilerInvocationBase &X)
-    : LangOpts(new LangOptions(*X.getLangOpts())),
-      TargetOpts(new TargetOptions(X.getTargetOpts())),
-      DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
-      HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
-      PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
+  : RefCountedBase<CompilerInvocation>(),
+    LangOpts(new LangOptions(*X.getLangOpts())),
+    TargetOpts(new TargetOptions(X.getTargetOpts())),
+    DiagnosticOpts(new DiagnosticOptions(X.getDiagnosticOpts())),
+    HeaderSearchOpts(new HeaderSearchOptions(X.getHeaderSearchOpts())),
+    PreprocessorOpts(new PreprocessorOptions(X.getPreprocessorOpts())) {}
 
 CompilerInvocationBase::~CompilerInvocationBase() {}
 
index 16269064b6e1bc8d73e96ceed37842108cbbea38..1e9e57afb6bdf3f29df9eb2dfc81df24d243ebe7 100644 (file)
@@ -30,9 +30,9 @@ using namespace llvm::opt;
 ///
 /// \return A CompilerInvocation, or 0 if none was built for the given
 /// argument vector.
-std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
-    ArrayRef<const char *> ArgList,
-    IntrusiveRefCntPtr<DiagnosticsEngine> Diags) {
+CompilerInvocation *
+clang::createInvocationFromCommandLine(ArrayRef<const char *> ArgList,
+                            IntrusiveRefCntPtr<DiagnosticsEngine> Diags) {
   if (!Diags.get()) {
     // No diagnostics engine was provided, so create our own diagnostics object
     // with the default options.
@@ -93,12 +93,12 @@ std::unique_ptr<CompilerInvocation> clang::createInvocationFromCommandLine(
   }
 
   const ArgStringList &CCArgs = Cmd.getArguments();
-  auto CI = llvm::make_unique<CompilerInvocation>();
+  std::unique_ptr<CompilerInvocation> CI(new CompilerInvocation());
   if (!CompilerInvocation::CreateFromArgs(*CI,
                                      const_cast<const char **>(CCArgs.data()),
                                      const_cast<const char **>(CCArgs.data()) +
                                      CCArgs.size(),
                                      *Diags))
     return nullptr;
-  return CI;
+  return CI.release();
 }
index c6f3baa7e3b2159b4bd89a2afed27a95e6e70c70..5baa78904bf35c521435b57618846ddef871f628 100644 (file)
@@ -62,7 +62,8 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
     return;
   }
 
-  auto Invocation = std::make_shared<CompilerInvocation>(CI.getInvocation());
+  IntrusiveRefCntPtr<CompilerInvocation> Invocation(
+      new CompilerInvocation(CI.getInvocation()));
 
   FrontendOptions &FrontendOpts = Invocation->getFrontendOpts();
   InputKind IK = IK_CXX; // FIXME
@@ -75,7 +76,7 @@ void ModelInjector::onBodySynthesis(const NamedDecl *D) {
   // Modules are parsed by a separate CompilerInstance, so this code mimics that
   // behavior for models
   CompilerInstance Instance(CI.getPCHContainerOperations());
-  Instance.setInvocation(std::move(Invocation));
+  Instance.setInvocation(&*Invocation);
   Instance.createDiagnostics(
       new ForwardingDiagnosticConsumer(CI.getDiagnosticClient()),
       /*ShouldOwnClient=*/true);
index 25cee98078f3776892292bcde5855372bd2774d4..529c47ef1e7a840b5c6f9d36310b9c45f598b663 100644 (file)
@@ -275,13 +275,13 @@ bool ToolInvocation::run() {
     Invocation->getPreprocessorOpts().addRemappedFile(It.getKey(),
                                                       Input.release());
   }
-  return runInvocation(BinaryName, Compilation.get(), std::move(Invocation),
+  return runInvocation(BinaryName, Compilation.get(), Invocation.release(),
                        std::move(PCHContainerOps));
 }
 
 bool ToolInvocation::runInvocation(
     const char *BinaryName, clang::driver::Compilation *Compilation,
-    std::shared_ptr<clang::CompilerInvocation> Invocation,
+    clang::CompilerInvocation *Invocation,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps) {
   // Show the invocation, with -v.
   if (Invocation->getHeaderSearchOpts().Verbose) {
@@ -290,17 +290,17 @@ bool ToolInvocation::runInvocation(
     llvm::errs() << "\n";
   }
 
-  return Action->runInvocation(std::move(Invocation), Files,
-                               std::move(PCHContainerOps), DiagConsumer);
+  return Action->runInvocation(Invocation, Files, std::move(PCHContainerOps),
+                               DiagConsumer);
 }
 
 bool FrontendActionFactory::runInvocation(
-    std::shared_ptr<CompilerInvocation> Invocation, FileManager *Files,
+    CompilerInvocation *Invocation, FileManager *Files,
     std::shared_ptr<PCHContainerOperations> PCHContainerOps,
     DiagnosticConsumer *DiagConsumer) {
   // Create a compiler instance to handle the actual work.
   clang::CompilerInstance Compiler(std::move(PCHContainerOps));
-  Compiler.setInvocation(std::move(Invocation));
+  Compiler.setInvocation(Invocation);
   Compiler.setFileManager(Files);
 
   // The FrontendAction can have lifetime requirements for Compiler or its
@@ -474,8 +474,7 @@ class ASTBuilderAction : public ToolAction {
 public:
   ASTBuilderAction(std::vector<std::unique_ptr<ASTUnit>> &ASTs) : ASTs(ASTs) {}
 
-  bool runInvocation(std::shared_ptr<CompilerInvocation> Invocation,
-                     FileManager *Files,
+  bool runInvocation(CompilerInvocation *Invocation, FileManager *Files,
                      std::shared_ptr<PCHContainerOperations> PCHContainerOps,
                      DiagnosticConsumer *DiagConsumer) override {
     std::unique_ptr<ASTUnit> AST = ASTUnit::LoadFromCompilerInvocation(
index 015e4cca1038cca2f3d1c231f69d061be3a9d4d6..3e4052c93ef58358943a02d87983e4886237f96e 100644 (file)
@@ -140,7 +140,8 @@ static bool printSourceSymbols(ArrayRef<const char *> Args) {
   ArgsWithProgName.append(Args.begin(), Args.end());
   IntrusiveRefCntPtr<DiagnosticsEngine>
     Diags(CompilerInstance::createDiagnostics(new DiagnosticOptions));
-  auto CInvok = createInvocationFromCommandLine(ArgsWithProgName, Diags);
+  IntrusiveRefCntPtr<CompilerInvocation>
+    CInvok(createInvocationFromCommandLine(ArgsWithProgName, Diags));
   if (!CInvok)
     return true;
 
@@ -151,8 +152,8 @@ static bool printSourceSymbols(ArrayRef<const char *> Args) {
                                      /*WrappedAction=*/nullptr);
 
   auto PCHContainerOps = std::make_shared<PCHContainerOperations>();
-  auto Unit = ASTUnit::LoadFromCompilerInvocationAction(
-      std::move(CInvok), PCHContainerOps, Diags, IndexAction.get());
+  std::unique_ptr<ASTUnit> Unit(ASTUnit::LoadFromCompilerInvocationAction(
+      CInvok.get(), PCHContainerOps, Diags, IndexAction.get()));
 
   if (!Unit)
     return true;
index 33190af4bf459d2868de7693c0ed2d14116da3fe..47598fc918132f18f48c603d9840ace824d39555 100644 (file)
@@ -157,7 +157,7 @@ BuildCompilerInstance(ArrayRef<const char *> ClangArgv) {
   Inv->getCodeGenOpts().setDebugInfo(codegenoptions::FullDebugInfo);
   Inv->getTargetOpts().Triple = llvm::sys::getDefaultTargetTriple();
 
-  Ins->setInvocation(std::move(Inv));
+  Ins->setInvocation(Inv.release());
 
   TargetInfo *TI = TargetInfo::CreateTargetInfo(
       Ins->getDiagnostics(), Ins->getInvocation().TargetOpts);
index e6ea786a9ade76f6ac17ff8244ac1ceafef481c4..abbd3afbd58c6efb864970f60b7667f4171a5534 100644 (file)
@@ -67,8 +67,8 @@ createDiagnostics(unsigned int argc, char **argv) {
   SmallVector<const char *, 4> Args;
   Args.push_back("diagtool");
   Args.append(argv, argv + argc);
-  std::unique_ptr<CompilerInvocation> Invocation =
-      createInvocationFromCommandLine(Args, InterimDiags);
+  std::unique_ptr<CompilerInvocation> Invocation(
+      createInvocationFromCommandLine(Args, InterimDiags));
   if (!Invocation)
     return nullptr;
 
index 9cdb2ee8d697130bc5848772fecc9bb66fe4ec0b..40eea39f3bdbf32877fadab0170db23b4bed9868 100644 (file)
@@ -68,14 +68,13 @@ using namespace clang::cxcursor;
 using namespace clang::cxtu;
 using namespace clang::cxindex;
 
-CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx,
-                                              std::unique_ptr<ASTUnit> AU) {
+CXTranslationUnit cxtu::MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU) {
   if (!AU)
     return nullptr;
   assert(CIdx);
   CXTranslationUnit D = new CXTranslationUnitImpl();
   D->CIdx = CIdx;
-  D->TheASTUnit = AU.release();
+  D->TheASTUnit = AU;
   D->StringPool = new cxstring::CXStringPool();
   D->Diagnostics = nullptr;
   D->OverridenCursorsPool = createOverridenCXCursorsPool();
@@ -3232,7 +3231,7 @@ enum CXErrorCode clang_createTranslationUnit2(CXIndex CIdx,
       /*CaptureDiagnostics=*/true,
       /*AllowPCHWithCompilerErrors=*/true,
       /*UserFilesAreVolatile=*/true);
-  *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(AU));
+  *out_TU = MakeCXTranslationUnit(CXXIdx, AU.release());
   return *out_TU ? CXError_Success : CXError_Failure;
 }
 
@@ -3384,7 +3383,7 @@ clang_parseTranslationUnit_Impl(CXIndex CIdx, const char *source_filename,
   if (isASTReadError(Unit ? Unit.get() : ErrUnit.get()))
     return CXError_ASTReadError;
 
-  *out_TU = MakeCXTranslationUnit(CXXIdx, std::move(Unit));
+  *out_TU = MakeCXTranslationUnit(CXXIdx, Unit.release());
   return *out_TU ? CXError_Success : CXError_Failure;
 }
 
index ca68bc1cd28ee5f2e0317cf311cdc6a88807c2a0..12895c4a9b7a97c47a6c0154146d6825d01bee61 100644 (file)
@@ -279,12 +279,13 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
   SmallVector<const llvm::MemoryBuffer *, 1> TemporaryBuffers;
   
   /// \brief Allocator used to store globally cached code-completion results.
-  std::shared_ptr<clang::GlobalCodeCompletionAllocator>
-      CachedCompletionAllocator;
-
+  IntrusiveRefCntPtr<clang::GlobalCodeCompletionAllocator>
+    CachedCompletionAllocator;
+  
   /// \brief Allocator used to store code completion results.
-  std::shared_ptr<clang::GlobalCodeCompletionAllocator> CodeCompletionAllocator;
-
+  IntrusiveRefCntPtr<clang::GlobalCodeCompletionAllocator>
+    CodeCompletionAllocator;
+  
   /// \brief Context under which completion occurred.
   enum clang::CodeCompletionContext::Kind ContextKind;
   
@@ -314,15 +315,15 @@ struct AllocatedCXCodeCompleteResults : public CXCodeCompleteResults {
 ///
 /// Used for debugging purposes only.
 static std::atomic<unsigned> CodeCompletionResultObjects;
-
+  
 AllocatedCXCodeCompleteResults::AllocatedCXCodeCompleteResults(
     IntrusiveRefCntPtr<FileManager> FileMgr)
-    : CXCodeCompleteResults(), DiagOpts(new DiagnosticOptions),
+    : CXCodeCompleteResults(),
+      DiagOpts(new DiagnosticOptions),
       Diag(new DiagnosticsEngine(
           IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts)),
       FileMgr(FileMgr), SourceMgr(new SourceManager(*Diag, *FileMgr)),
-      CodeCompletionAllocator(
-          std::make_shared<clang::GlobalCodeCompletionAllocator>()),
+      CodeCompletionAllocator(new clang::GlobalCodeCompletionAllocator),
       Contexts(CXCompletionContext_Unknown),
       ContainerKind(CXCursor_InvalidCode), ContainerIsIncomplete(1) {
   if (getenv("LIBCLANG_OBJTRACKING"))
index 67c31d2dba4fa5101c7b30005a921f07e924ae0b..6022c9dab1b5c1270bb88c60307fc5f56ceb0642 100644 (file)
@@ -38,8 +38,7 @@ struct CXTranslationUnitImpl {
 namespace clang {
 namespace cxtu {
 
-CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx,
-                                             std::unique_ptr<ASTUnit> AU);
+CXTranslationUnitImpl *MakeCXTranslationUnit(CIndexer *CIdx, ASTUnit *AU);
 
 static inline ASTUnit *getASTUnit(CXTranslationUnit TU) {
   if (!TU)
index 905e764accd5b543ed479a5c0593316394e5950f..5422dd3dc62595abe6893a7e828af20d47c79796 100644 (file)
@@ -476,19 +476,17 @@ static CXErrorCode clang_indexSourceFile_Impl(
   // present it will be unused.
   if (source_filename)
     Args->push_back(source_filename);
-
-  std::shared_ptr<CompilerInvocation> CInvok =
-      createInvocationFromCommandLine(*Args, Diags);
+  
+  IntrusiveRefCntPtr<CompilerInvocation>
+    CInvok(createInvocationFromCommandLine(*Args, Diags));
 
   if (!CInvok)
     return CXError_Failure;
 
   // Recover resources if we crash before exiting this function.
-  llvm::CrashRecoveryContextCleanupRegistrar<
-      std::shared_ptr<CompilerInvocation>,
-      llvm::CrashRecoveryContextDeleteCleanup<
-          std::shared_ptr<CompilerInvocation>>>
-      CInvokCleanup(&CInvok);
+  llvm::CrashRecoveryContextCleanupRegistrar<CompilerInvocation,
+    llvm::CrashRecoveryContextReleaseRefCleanup<CompilerInvocation> >
+    CInvokCleanup(CInvok.get());
 
   if (CInvok->getFrontendOpts().Inputs.empty())
     return CXError_Failure;
@@ -520,14 +518,13 @@ static CXErrorCode clang_indexSourceFile_Impl(
   CInvok->getHeaderSearchOpts().ModuleFormat =
     CXXIdx->getPCHContainerOperations()->getRawReader().getFormat();
 
-  auto Unit = ASTUnit::create(CInvok, Diags, CaptureDiagnostics,
-                              /*UserFilesAreVolatile=*/true);
+  ASTUnit *Unit = ASTUnit::create(CInvok.get(), Diags, CaptureDiagnostics,
+                                  /*UserFilesAreVolatile=*/true);
   if (!Unit)
     return CXError_InvalidArguments;
 
-  auto *UPtr = Unit.get();
   std::unique_ptr<CXTUOwner> CXTU(
-      new CXTUOwner(MakeCXTranslationUnit(CXXIdx, std::move(Unit))));
+      new CXTUOwner(MakeCXTranslationUnit(CXXIdx, Unit)));
 
   // Recover resources if we crash before exiting this method.
   llvm::CrashRecoveryContextCleanupRegistrar<CXTUOwner>
@@ -586,16 +583,16 @@ static CXErrorCode clang_indexSourceFile_Impl(
       !PrecompilePreamble ? 0 : 2 - CreatePreambleOnFirstParse;
   DiagnosticErrorTrap DiagTrap(*Diags);
   bool Success = ASTUnit::LoadFromCompilerInvocationAction(
-      std::move(CInvok), CXXIdx->getPCHContainerOperations(), Diags,
-      IndexAction.get(), UPtr, Persistent, CXXIdx->getClangResourcesPath(),
+      CInvok.get(), CXXIdx->getPCHContainerOperations(), Diags,
+      IndexAction.get(), Unit, Persistent, CXXIdx->getClangResourcesPath(),
       OnlyLocalDecls, CaptureDiagnostics, PrecompilePreambleAfterNParses,
       CacheCodeCompletionResults,
       /*IncludeBriefCommentsInCodeCompletion=*/false,
       /*UserFilesAreVolatile=*/true);
   if (DiagTrap.hasErrorOccurred() && CXXIdx->getDisplayDiagnostics())
-    printDiagsToStderr(UPtr);
+    printDiagsToStderr(Unit);
 
-  if (isASTReadError(UPtr))
+  if (isASTReadError(Unit))
     return CXError_ASTReadError;
 
   if (!Success)
index 513ff5b99fadfa51625d9bbdf2a5ef735d935baa..4b3bb3e2b69b3869903e6d0ab4a66791e4e5acf1 100644 (file)
@@ -49,14 +49,14 @@ bool testExternalASTSource(ExternalASTSource *Source,
   CompilerInstance Compiler;
   Compiler.createDiagnostics();
 
-  auto Invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *Invocation = new CompilerInvocation;
   Invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc", MemoryBuffer::getMemBuffer(FileContents).release());
   const char *Args[] = { "test.cc" };
   CompilerInvocation::CreateFromArgs(*Invocation, Args,
                                      Args + array_lengthof(Args),
                                      Compiler.getDiagnostics());
-  Compiler.setInvocation(std::move(Invocation));
+  Compiler.setInvocation(Invocation);
 
   TestFrontendAction Action(Source);
   return Compiler.ExecuteAction(Action);
index 1d2a50c8bc208933cd0c98ee2c810400c5fa5966..356b5130fcbe9c17bd4be2b4e7cda8db911e206e 100644 (file)
@@ -41,7 +41,7 @@ public:
 
 
 TEST(CodeGenTest, TestNullCodeGen) {
-  auto Invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *Invocation = new CompilerInvocation;
   Invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc",
       MemoryBuffer::getMemBuffer("").release());
@@ -50,7 +50,7 @@ TEST(CodeGenTest, TestNullCodeGen) {
   Invocation->getFrontendOpts().ProgramAction = EmitLLVM;
   Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance Compiler;
-  Compiler.setInvocation(std::move(Invocation));
+  Compiler.setInvocation(Invocation);
   Compiler.createDiagnostics();
   EXPECT_TRUE(Compiler.hasDiagnostics());
 
index dd6be5fd4b983a152a86401c9d8b12fdac7a53cb..c3e6adb6324d543541dd08dca5097021391ce790 100644 (file)
@@ -79,7 +79,7 @@ private:
 };
 
 TEST(ASTFrontendAction, Sanity) {
-  auto invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *invocation = new CompilerInvocation;
   invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc",
       MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -88,7 +88,7 @@ TEST(ASTFrontendAction, Sanity) {
   invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance compiler;
-  compiler.setInvocation(std::move(invocation));
+  compiler.setInvocation(invocation);
   compiler.createDiagnostics();
 
   TestASTFrontendAction test_action;
@@ -99,7 +99,7 @@ TEST(ASTFrontendAction, Sanity) {
 }
 
 TEST(ASTFrontendAction, IncrementalParsing) {
-  auto invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *invocation = new CompilerInvocation;
   invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc",
       MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -108,7 +108,7 @@ TEST(ASTFrontendAction, IncrementalParsing) {
   invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance compiler;
-  compiler.setInvocation(std::move(invocation));
+  compiler.setInvocation(invocation);
   compiler.createDiagnostics();
 
   TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true);
@@ -119,7 +119,7 @@ TEST(ASTFrontendAction, IncrementalParsing) {
 }
 
 TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
-  auto invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *invocation = new CompilerInvocation;
   invocation->getLangOpts()->CPlusPlus = true;
   invocation->getLangOpts()->DelayedTemplateParsing = true;
   invocation->getPreprocessorOpts().addRemappedFile(
@@ -135,7 +135,7 @@ TEST(ASTFrontendAction, LateTemplateIncrementalParsing) {
   invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance compiler;
-  compiler.setInvocation(std::move(invocation));
+  compiler.setInvocation(invocation);
   compiler.createDiagnostics();
 
   TestASTFrontendAction test_action(/*enableIncrementalProcessing=*/true,
@@ -172,7 +172,7 @@ public:
 };
 
 TEST(PreprocessorFrontendAction, EndSourceFile) {
-  auto Invocation = std::make_shared<CompilerInvocation>();
+  CompilerInvocation *Invocation = new CompilerInvocation;
   Invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc",
       MemoryBuffer::getMemBuffer("int main() { float x; }").release());
@@ -181,7 +181,7 @@ TEST(PreprocessorFrontendAction, EndSourceFile) {
   Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance Compiler;
-  Compiler.setInvocation(std::move(Invocation));
+  Compiler.setInvocation(Invocation);
   Compiler.createDiagnostics();
 
   TestPPCallbacks *Callbacks = new TestPPCallbacks;
@@ -231,7 +231,7 @@ struct TypoDiagnosticConsumer : public DiagnosticConsumer {
 };
 
 TEST(ASTFrontendAction, ExternalSemaSource) {
-  auto Invocation = std::make_shared<CompilerInvocation>();
+  auto *Invocation = new CompilerInvocation;
   Invocation->getLangOpts()->CPlusPlus = true;
   Invocation->getPreprocessorOpts().addRemappedFile(
       "test.cc", MemoryBuffer::getMemBuffer("void fooo();\n"
@@ -242,7 +242,7 @@ TEST(ASTFrontendAction, ExternalSemaSource) {
   Invocation->getFrontendOpts().ProgramAction = frontend::ParseSyntaxOnly;
   Invocation->getTargetOpts().Triple = "i386-unknown-linux-gnu";
   CompilerInstance Compiler;
-  Compiler.setInvocation(std::move(Invocation));
+  Compiler.setInvocation(Invocation);
   auto *TDC = new TypoDiagnosticConsumer;
   Compiler.createDiagnostics(TDC, /*ShouldOwnClient=*/true);
   Compiler.setExternalSemaSource(new TypoExternalSemaSource(Compiler));