[PATCH] D13983: Correctly print the type in modernize-make-unique.
Angel Garcia via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 22 06:12:18 PDT 2015
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);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D13983.38121.patch
Type: text/x-patch
Size: 1813 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20151022/7739a284/attachment.bin>
More information about the cfe-commits
mailing list