[PATCH] D14560: [Clang] Fix Clang-tidy modernize-use-auto in some files in lib/AST; other minor cleanups.

Aaron Ballman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 11 08:12:07 PST 2015


aaron.ballman added inline comments.

================
Comment at: lib/AST/ASTContext.cpp:3857
@@ -3856,4 +3856,3 @@
   void *Mem = Allocate(sizeof(ObjCObjectPointerType), TypeAlignment);
-  ObjCObjectPointerType *QType =
-    new (Mem) ObjCObjectPointerType(Canonical, ObjectT);
+  auto *QType = new (Mem) ObjCObjectPointerType(Canonical, ObjectT);
 
----------------
This one may be an improvement.

================
Comment at: lib/AST/ASTContext.cpp:4366
@@ -4366,4 +4365,3 @@
       
-      TemplateArgument *CanonArgs
-        = new (*this) TemplateArgument[Arg.pack_size()];
+      auto *CanonArgs = new (*this) TemplateArgument[Arg.pack_size()];
       unsigned Idx = 0;
----------------
Same with this one.

================
Comment at: lib/AST/ASTContext.cpp:7930
@@ -7931,3 +7929,3 @@
 
-ASTMutationListener::~ASTMutationListener() { }
+ASTMutationListener::~ASTMutationListener() = default;
 
----------------
This is... interesting. Explicitly defaulting an out-of-line function definition is not something I've ever encountered before. What benefit does this provide?

================
Comment at: lib/AST/ASTContext.cpp:8519
@@ -8520,3 +8518,3 @@
 
-CXXABI::~CXXABI() {}
+CXXABI::~CXXABI() = default;
 
----------------
Same question applies here.

================
Comment at: lib/AST/ASTImporter.cpp:5326
@@ -5324,4 +5325,3 @@
 
-  Expr **ToArgs_Copied = new (Importer.getToContext()) 
-    Expr*[NumArgs];
+  auto **ToArgs_Copied = new (Importer.getToContext()) Expr*[NumArgs];
 
----------------
This may be an improvement.

================
Comment at: lib/AST/ASTImporter.cpp:5348
@@ -5347,3 +5347,3 @@
 
-ASTImporter::~ASTImporter() { }
+ASTImporter::~ASTImporter() = default;
 
----------------
Similar out-of-line question here.

================
Comment at: lib/AST/CommentSema.cpp:268
@@ -268,5 +267,3 @@
   typedef BlockCommandComment::Argument Argument;
-  Argument *A = new (Allocator) Argument(SourceRange(ArgLocBegin,
-                                                     ArgLocEnd),
-                                         Arg);
+  auto *A = new (Allocator) Argument(SourceRange(ArgLocBegin, ArgLocEnd), Arg);
   Command->setArgs(llvm::makeArrayRef(A, 1));
----------------
This is an improvement.

================
Comment at: lib/AST/CommentSema.cpp:304
@@ -306,5 +303,3 @@
   typedef BlockCommandComment::Argument Argument;
-  Argument *A = new (Allocator) Argument(SourceRange(ArgLocBegin,
-                                                     ArgLocEnd),
-                                         Arg);
+  auto *A = new (Allocator) Argument(SourceRange(ArgLocBegin, ArgLocEnd), Arg);
   Command->setArgs(llvm::makeArrayRef(A, 1));
----------------
As is this one.

================
Comment at: lib/AST/CommentSema.cpp:357
@@ -356,3 +351,1 @@
-
-  return;
 }
----------------
Good catch on removing this one!


Repository:
  rL LLVM

http://reviews.llvm.org/D14560





More information about the cfe-commits mailing list