[PATCH] Replace OwningPtr with std::unique_ptr.

Ahmed Charles acharles at outlook.com
Fri Mar 7 11:09:06 PST 2014



================
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,
----------------
David Blaikie wrote:
> 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)
That sounds like something a human should do. :)

================
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(),
----------------
David Blaikie wrote:
> 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)
I'm probably going to make one, since it's pretty trivial, and the working paper already did it for me.

Unfortunately, we'll have to decide on what infinity is for us... I'll go with 10, probably.

I'm also going to try to cleanup most of the ownership transfer stuff so it's explicit to the interface.

================
Comment at: lib/Frontend/MultiplexConsumer.cpp:188
@@ +187,3 @@
+MultiplexConsumer::MultiplexConsumer(ArrayRef<ASTConsumer *> C)
+    : Consumers(C.begin(), C.end()), MutationListener(),
+      DeserializationListener() {
----------------
David Blaikie wrote:
> I assume these changes would be compatible with OwningPtr? (& could be made ahead of time)
Yes, removing the 0's could've been done ahead of time, except that OwningPtr doesn't have an ambiguity there, so it's harder to find them. I'm not sure why they are explicitly 0 now, but anyways. :)


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



More information about the cfe-commits mailing list