[clang-tools-extra] r251013 - Correctly print the type in modernize-make-unique.
Angel Garcia Gomez via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 22 06:20:49 PDT 2015
Author: angelgarcia
Date: Thu Oct 22 08:20:49 2015
New Revision: 251013
URL: http://llvm.org/viewvc/llvm-project?rev=251013&view=rev
Log:
Correctly print the type in modernize-make-unique.
Summary: Take into account the current LangOptions the check has to add back the template argument.
Reviewers: klimek
Subscribers: alexfh, cfe-commits
Differential Revision: http://reviews.llvm.org/D13983
Modified:
clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
Modified: clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp?rev=251013&r1=251012&r2=251013&view=diff
==============================================================================
--- clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp (original)
+++ clang-tools-extra/trunk/clang-tidy/modernize/MakeUniqueCheck.cpp Thu Oct 22 08:20:49 2015
@@ -79,8 +79,8 @@ void MakeUniqueCheck::check(const MatchF
// 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);
}
Modified: clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp?rev=251013&r1=251012&r2=251013&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/modernize-make-unique.cpp Thu Oct 22 08:20:49 2015
@@ -163,6 +163,18 @@ void aliases() {
// 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
More information about the cfe-commits
mailing list