[PATCH] D62958: [clang-tidy] Fix descriptions for modernize-make-unique/shared checks.

2019-06-07 Thread Haojian Wu via Phabricator via cfe-commits
hokein abandoned this revision.
hokein added a comment.

As discussed offline, we don't need a separate fix description for this check, 
as the check warning message clearly implies what the fix will do.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D62958/new/

https://reviews.llvm.org/D62958



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D62958: [clang-tidy] Fix descriptions for modernize-make-unique/shared checks.

2019-06-06 Thread Haojian Wu via Phabricator via cfe-commits
hokein created this revision.
hokein added a reviewer: gribozavr.
Herald added a subscriber: xazax.hun.
Herald added a project: clang.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D62958

Files:
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
  clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
  clang-tools-extra/test/clang-tidy/modernize-make-shared.cpp
  clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp

Index: clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-make-unique.cpp
@@ -80,6 +80,7 @@
 std::unique_ptr getPointer() {
   return std::unique_ptr(new Base);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_unique instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: note: change to std::make_unique
   // CHECK-FIXES: return std::make_unique();
 }
 
@@ -153,6 +154,7 @@
   // OK to replace for reset and assign
   Pderived.reset(new Derived());
   // CHECK-MESSAGES: :[[@LINE-1]]:12: warning: use std::make_unique instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:12: note: change to std::make_unique
   // CHECK-FIXES: Pderived = std::make_unique();
 
   Pderived = std::unique_ptr(new Derived());
@@ -301,6 +303,7 @@
   // Initialization with the initializer-list constructor.
   std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:28: warning: use std::make_unique instead
+  // CHECK-MESSAGES-NOT: :[[@LINE-2]]:28: note: change to std::make_unique
   // CHECK-FIXES: std::unique_ptr PE2 = std::unique_ptr(new E{1, 2});
   PE2.reset(new E{1, 2});
   // CHECK-MESSAGES: :[[@LINE-1]]:7: warning: use std::make_unique instead
Index: clang-tools-extra/test/clang-tidy/modernize-make-shared.cpp
===
--- clang-tools-extra/test/clang-tidy/modernize-make-shared.cpp
+++ clang-tools-extra/test/clang-tidy/modernize-make-shared.cpp
@@ -35,6 +35,7 @@
 std::shared_ptr getPointer() {
   return std::shared_ptr(new Base);
   // CHECK-MESSAGES: :[[@LINE-1]]:10: warning: use std::make_shared instead
+  // CHECK-MESSAGES: :[[@LINE-2]]:10: note: change to std::make_shared
   // CHECK-FIXES: return std::make_shared();
 }
 
@@ -45,6 +46,7 @@
 
   P1.reset(new int());
   // CHECK-MESSAGES: :[[@LINE-1]]:6: warning: use std::make_shared instead [modernize-make-shared]
+  // CHECK-MESSAGES: :[[@LINE-2]]:6: note: change to std::make_shared
   // CHECK-FIXES: P1 = std::make_shared();
 
   P1 = std::shared_ptr(new int());
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.h
@@ -59,8 +59,8 @@
   const CXXMemberCallExpr *Member, const CXXNewExpr *New);
 
   /// Returns true when the fixes for replacing CXXNewExpr are generated.
-  bool replaceNew(DiagnosticBuilder , const CXXNewExpr *New,
-  SourceManager , ASTContext *Ctx);
+  bool replaceNew(const CXXNewExpr *New, SourceManager , ASTContext *Ctx,
+  std::vector );
   void insertHeader(DiagnosticBuilder , FileID FD);
 };
 
Index: clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
===
--- clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
+++ clang-tools-extra/clang-tidy/modernize/MakeSmartPtrCheck.cpp
@@ -159,17 +159,22 @@
   if (Invalid)
 return;
 
-  auto Diag = diag(ConstructCallStart, "use %0 instead")
-  << MakeSmartPtrFunctionName;
+  diag(ConstructCallStart, "use %0 instead") << MakeSmartPtrFunctionName;
 
   // Disable the fix in macros.
   if (InMacro) {
 return;
   }
 
-  if (!replaceNew(Diag, New, SM, Ctx)) {
+  std::vector Fixes;
+  if (!replaceNew(New, SM, Ctx, Fixes)) {
 return;
   }
+  auto FixDiag = diag(ConstructCallStart, "change to %0", DiagnosticIDs::Note)
+ << MakeSmartPtrFunctionName;
+
+  for (const auto  : Fixes)
+FixDiag << Fix;
 
   // Find the location of the template's left angle.
   size_t LAngle = ExprStr.find("<");
@@ -178,14 +183,13 @@
 // If the template argument is missing (because it is part of the alias)
 // we have to add it back.
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(ExprStr.size());
-Diag << FixItHint::CreateInsertion(
-ConstructCallEnd,
-"<" + GetNewExprName(New, SM, getLangOpts()) + ">");
+FixDiag << FixItHint::CreateInsertion(
+ConstructCallEnd, "<" + GetNewExprName(New, SM, getLangOpts()) + ">");
   } else {
 ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle);
   }
 
-  Diag << FixItHint::CreateReplacement(
+  FixDiag << FixItHint::CreateReplacement(