angelgarcia created this revision. angelgarcia added a reviewer: klimek. angelgarcia added subscribers: cfe-commits, alexfh.
Take into account the current LangOptions the check has to add back the template argument. http://reviews.llvm.org/D13983 Files: clang-tidy/modernize/MakeUniqueCheck.cpp test/clang-tidy/modernize-make-unique.cpp Index: test/clang-tidy/modernize-make-unique.cpp =================================================================== --- test/clang-tidy/modernize-make-unique.cpp +++ test/clang-tidy/modernize-make-unique.cpp @@ -163,6 +163,18 @@ // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead // CHECK-FIXES: IntPtr Typedef = std::make_unique<int>(); + // We use 'bool' instead of '_Bool'. + typedef std::unique_ptr<bool> BoolPtr; + BoolPtr BoolType = BoolPtr(new bool); + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead + // CHECK-FIXES: BoolPtr BoolType = std::make_unique<bool>(); + + // We use 'Base' instead of 'struct Base'. + typedef std::unique_ptr<Base> BasePtr; + BasePtr StructType = BasePtr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead + // CHECK-FIXES: BasePtr StructType = std::make_unique<Base>(); + #define PTR unique_ptr<int> std::unique_ptr<int> Macro = std::PTR(new int); // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead Index: clang-tidy/modernize/MakeUniqueCheck.cpp =================================================================== --- clang-tidy/modernize/MakeUniqueCheck.cpp +++ clang-tidy/modernize/MakeUniqueCheck.cpp @@ -79,8 +79,8 @@ // 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, - "<" + Type->getAsString() + ">"); + Diag << FixItHint::CreateInsertion( + ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">"); } else { ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle); }
Index: test/clang-tidy/modernize-make-unique.cpp =================================================================== --- test/clang-tidy/modernize-make-unique.cpp +++ test/clang-tidy/modernize-make-unique.cpp @@ -163,6 +163,18 @@ // CHECK-MESSAGES: :[[@LINE-1]]:20: warning: use std::make_unique instead // CHECK-FIXES: IntPtr Typedef = std::make_unique<int>(); + // We use 'bool' instead of '_Bool'. + typedef std::unique_ptr<bool> BoolPtr; + BoolPtr BoolType = BoolPtr(new bool); + // CHECK-MESSAGES: :[[@LINE-1]]:22: warning: use std::make_unique instead + // CHECK-FIXES: BoolPtr BoolType = std::make_unique<bool>(); + + // We use 'Base' instead of 'struct Base'. + typedef std::unique_ptr<Base> BasePtr; + BasePtr StructType = BasePtr(new Base); + // CHECK-MESSAGES: :[[@LINE-1]]:24: warning: use std::make_unique instead + // CHECK-FIXES: BasePtr StructType = std::make_unique<Base>(); + #define PTR unique_ptr<int> std::unique_ptr<int> Macro = std::PTR(new int); // CHECK-MESSAGES: :[[@LINE-1]]:32: warning: use std::make_unique instead Index: clang-tidy/modernize/MakeUniqueCheck.cpp =================================================================== --- clang-tidy/modernize/MakeUniqueCheck.cpp +++ clang-tidy/modernize/MakeUniqueCheck.cpp @@ -79,8 +79,8 @@ // 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, - "<" + Type->getAsString() + ">"); + Diag << FixItHint::CreateInsertion( + ConstructCallEnd, "<" + Type->getAsString(getLangOpts()) + ">"); } else { ConstructCallEnd = ConstructCallStart.getLocWithOffset(LAngle); }
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits