[PATCH] Replace OwningPtr with std::unique_ptr.

David Blaikie dblaikie at gmail.com
Fri Mar 7 09:21:50 PST 2014


  Some optional/unrelated commentary, but otherwise looks good!


================
Comment at: include/clang/Basic/VirtualFileSystem.h:87
@@ -86,5 +86,3 @@
   /// \brief Get the contents of the file as a \p MemoryBuffer.
-  virtual llvm::error_code getBuffer(const Twine &Name,
-                                     OwningPtr<llvm::MemoryBuffer> &Result,
-                                     int64_t FileSize = -1,
-                                     bool RequiresNullTerminator = true) = 0;
+  virtual llvm::error_code
+  getBuffer(const Twine &Name, std::unique_ptr<llvm::MemoryBuffer> &Result,
----------------
Interesting choice of formatting from clang-format, but I guess it makes sense... just don't often see the lone return type in declarations (let alone with virtual up there too)

================
Comment at: include/clang/Frontend/ASTUnit.h:757
@@ -756,14 +756,3 @@
   ///
-  static ASTUnit *LoadFromCompilerInvocationAction(CompilerInvocation *CI,
-                              IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
-                                             ASTFrontendAction *Action = 0,
-                                             ASTUnit *Unit = 0,
-                                             bool Persistent = true,
-                                      StringRef ResourceFilesPath = StringRef(),
-                                             bool OnlyLocalDecls = false,
-                                             bool CaptureDiagnostics = false,
-                                             bool PrecompilePreamble = false,
-                                       bool CacheCodeCompletionResults = false,
-                              bool IncludeBriefCommentsInCodeCompletion = false,
-                                       bool UserFilesAreVolatile = false,
-                                       OwningPtr<ASTUnit> *ErrAST = 0);
+  static ASTUnit *LoadFromCompilerInvocationAction(
+      CompilerInvocation *CI, IntrusiveRefCntPtr<DiagnosticsEngine> Diags,
----------------
Well that's a fun one - was quite a mess before. (again, optional to submit a reformatting prior to the actual change - I wonder if we could get clang-format to judge when a reformat would be similar with/without the code change (but still necessary to format the code change well?) and create a preceeding patch rather than a proceeding one... meh, probably doesn't make sense)

================
Comment at: lib/CodeGen/ModuleBuilder.cpp:39
@@ -39,1 +38,3 @@
+    std::unique_ptr<CodeGen::CodeGenModule> Builder;
+
   public:
----------------
Again, clang-format touching unrelated lines (I guess it was removing some trailing whitespace)

================
Comment at: lib/Frontend/MultiplexConsumer.cpp:188
@@ +187,3 @@
+MultiplexConsumer::MultiplexConsumer(ArrayRef<ASTConsumer *> C)
+    : Consumers(C.begin(), C.end()), MutationListener(),
+      DeserializationListener() {
----------------
I assume these changes would be compatible with OwningPtr? (& could be made ahead of time)

================
Comment at: lib/Frontend/FrontendActions.cpp:349
@@ +348,3 @@
+      new ASTReader(CI.getPreprocessor(), CI.getASTContext(),
+                    Sysroot.empty() ? "" : Sysroot.c_str(),
+                    /*DisableValidation*/ false,
----------------
Unrelated: this seems weird... I wonder why we wouldn't just always call Sysroot.c_str()?

================
Comment at: lib/Frontend/FrontendActions.cpp:347
@@ -346,8 +346,3 @@
   const std::string &Sysroot = CI.getHeaderSearchOpts().Sysroot;
-  OwningPtr<ASTReader> Reader(new ASTReader(
-    CI.getPreprocessor(), CI.getASTContext(),
-    Sysroot.empty() ? "" : Sysroot.c_str(),
-    /*DisableValidation*/false,
-    /*AllowPCHWithCompilerErrors*/false,
-    /*AllowConfigurationMismatch*/true,
-    /*ValidateSystemInputs*/true));
+  std::unique_ptr<ASTReader> Reader(
+      new ASTReader(CI.getPreprocessor(), CI.getASTContext(),
----------------
Hmm, do we have a faux-standard make_unique (like our faux-standard type traits we had in C++98)? Be nice to use that here:

auto Reader = make_unique<ASTReader>(...) so we only have to mention the type once.

(but that'd be a separate/follow-on cleanup)


http://llvm-reviews.chandlerc.com/D3003



More information about the cfe-commits mailing list