[clang-tools-extra] r342468 - [clang-tidy] use CHECK-NOTES in bugprone-unused-return-value
Jonas Toth via cfe-commits
cfe-commits at lists.llvm.org
Tue Sep 18 04:49:20 PDT 2018
Author: jonastoth
Date: Tue Sep 18 04:49:20 2018
New Revision: 342468
URL: http://llvm.org/viewvc/llvm-project?rev=342468&view=rev
Log:
[clang-tidy] use CHECK-NOTES in bugprone-unused-return-value
Reviewers: aaron.ballman, alexfh, hokein
Reviewed By: alexfh
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D52187
Modified:
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp
clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp
Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp?rev=342468&r1=342467&r2=342468&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value-custom.cpp Tue Sep 18 04:49:20 2018
@@ -47,32 +47,40 @@ void fun(int);
void warning() {
fun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
(fun());
- // CHECK-MESSAGES: [[@LINE-1]]:4: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:4: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:4: note: cast {{.*}} this warning
ns::Outer::Inner ObjA1;
ObjA1.memFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
ns::AliasName::Inner ObjA2;
ObjA2.memFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
ns::Derived ObjA3;
ObjA3.memFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
ns::Type::staticFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
ns::ClassTemplate<int> ObjA4;
ObjA4.memFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
ns::ClassTemplate<int>::staticFun();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
}
void noWarning() {
Modified: clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp
URL: http://llvm.org/viewvc/llvm-project/clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp?rev=342468&r1=342467&r2=342468&view=diff
==============================================================================
--- clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp (original)
+++ clang-tools-extra/trunk/test/clang-tidy/bugprone-unused-return-value.cpp Tue Sep 18 04:49:20 2018
@@ -74,93 +74,116 @@ void useFuture(const std::future &fut);
void warning() {
std::async(increment, 42);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value returned by this function should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast the expression to void to silence this warning
std::async(std::launch::async, increment, 42);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
Foo F;
std::launder(&F);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::remove_if(nullptr, nullptr, nullptr);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::unique(nullptr, nullptr);
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::unique_ptr<Foo> UPtr;
UPtr.release();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::string Str;
Str.empty();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
std::vector<Foo> Vec;
Vec.empty();
- // CHECK-MESSAGES: [[@LINE-1]]:3: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:3: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:3: note: cast {{.*}} this warning
// test discarding return values inside different kinds of statements
auto Lambda = [] { std::remove(nullptr, nullptr, 1); };
- // CHECK-MESSAGES: [[@LINE-1]]:22: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:22: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:22: note: cast {{.*}} this warning
if (true)
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
else if (true)
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
else
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
while (true)
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
do
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
while (true);
for (;;)
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
for (std::remove(nullptr, nullptr, 1);;)
- // CHECK-MESSAGES: [[@LINE-1]]:8: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:8: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:8: note: cast {{.*}} this warning
;
for (;; std::remove(nullptr, nullptr, 1))
- // CHECK-MESSAGES: [[@LINE-1]]:11: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:11: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:11: note: cast {{.*}} this warning
;
for (auto C : "foo")
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
switch (1) {
case 1:
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
break;
default:
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
break;
}
try {
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
} catch (...) {
std::remove(nullptr, nullptr, 1);
- // CHECK-MESSAGES: [[@LINE-1]]:5: warning: the value returned by this function should be used [bugprone-unused-return-value]
+ // CHECK-NOTES: [[@LINE-1]]:5: warning: the value {{.*}} should be used
+ // CHECK-NOTES: [[@LINE-2]]:5: note: cast {{.*}} this warning
}
}
More information about the cfe-commits
mailing list