[clang-tools-extra] r310096 - [clang-tidy] Added clang-tidy test cases related to rL310095
Florian Gross via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 4 12:01:56 PDT 2017
Author: fgross
Date: Fri Aug 4 12:01:56 2017
New Revision: 310096
URL: http://llvm.org/viewvc/llvm-project?rev=310096&view=rev
Log:
[clang-tidy] Added clang-tidy test cases related to rL310095
Differential Revision: https://reviews.llvm.org/D36308
Modified:
clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp
Modified: clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp?rev=310096&r1=310095&r2=310096&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/misc-use-after-move.cpp Fri Aug 4 12:01:56 2017
@@ -723,6 +723,11 @@ void standardContainerClearIsReinit() {
std::move(container);
container.clear();
container.empty();
+
+ auto container2 = container;
+ std::move(container2);
+ container2.clear();
+ container2.empty();
}
{
std::deque<int> container;
Modified: clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp?rev=310096&r1=310095&r2=310096&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/performance-inefficient-string-concatenation.cpp Fri Aug 4 12:01:56 2017
@@ -19,6 +19,8 @@ std::string g(std::string) {}
int main() {
std::string mystr1, mystr2;
std::wstring mywstr1, mywstr2;
+ auto myautostr1 = mystr1;
+ auto myautostr2 = mystr2;
for (int i = 0; i < 10; ++i) {
f(mystr1 + mystr2 + mystr1);
@@ -33,6 +35,8 @@ int main() {
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
mywstr1 = mywstr2 + mywstr2 + mywstr2;
// CHECK-MESSAGES: :[[@LINE-1]]:33: warning: string concatenation
+ myautostr1 = myautostr1 + myautostr2;
+ // CHECK-MESSAGES: :[[@LINE-1]]:5: warning: string concatenation
mywstr1 = mywstr2 + mywstr2;
mystr1 = mystr2 + mystr2;
Modified: clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp?rev=310096&r1=310095&r2=310096&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-redundant-smartptr-get.cpp Fri Aug 4 12:01:56 2017
@@ -97,6 +97,12 @@ void Positive() {
// CHECK-MESSAGES: int i = *ip.get();
// CHECK-FIXES: int i = *ip;
+ auto ip2 = ip;
+ i = *ip2.get();
+ // CHECK-MESSAGES: :[[@LINE-1]]:8: warning: redundant get() call
+ // CHECK-MESSAGES: i = *ip2.get();
+ // CHECK-FIXES: i = *ip2;
+
std::unique_ptr<int> uu;
std::shared_ptr<double> *ss;
bool bb = uu.get() == nullptr;
Modified: clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp?rev=310096&r1=310095&r2=310096&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/readability-uniqueptr-delete-release.cpp Fri Aug 4 12:01:56 2017
@@ -24,6 +24,11 @@ void Positives() {
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
// CHECK-FIXES: {{^}} P = nullptr;
+ auto P2 = P;
+ delete P2.release();
+ // CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete x.release()' to reset unique_ptr<> objects [readability-uniqueptr-delete-release]
+ // CHECK-FIXES: {{^}} P2 = nullptr;
+
std::unique_ptr<int> Array[20];
delete Array[4].release();
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: prefer '= nullptr' to 'delete
More information about the cfe-commits
mailing list