aboutsummaryrefslogtreecommitdiff
path: root/clang-tools-extra/test/clang-tidy/checkers/readability
diff options
context:
space:
mode:
authorPiotr Zegar <me@piotrzegar.pl>2024-05-02 04:43:35 +0200
committerGitHub <noreply@github.com>2024-05-02 04:43:35 +0200
commit1f1a417925624a67cb6cb2bbbdd901e0e90ee237 (patch)
tree1e2025c217a88625a137e3753efdf0dcd445d545 /clang-tools-extra/test/clang-tidy/checkers/readability
parent889e60db2daf93c0bb3f7ae0db0a60bfefb86d89 (diff)
downloadllvm-1f1a417925624a67cb6cb2bbbdd901e0e90ee237.zip
llvm-1f1a417925624a67cb6cb2bbbdd901e0e90ee237.tar.gz
llvm-1f1a417925624a67cb6cb2bbbdd901e0e90ee237.tar.bz2
[clang-tidy] Relax readability-const-return-type (#90560)
From now readability-const-return-type won't provide warnings for returning const types, where const is not on top level. In such case const there is a performance issue, but not a readability. Closes #73270
Diffstat (limited to 'clang-tools-extra/test/clang-tidy/checkers/readability')
-rw-r--r--clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
index 10b2858..76a3555 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/readability/const-return-type.cpp
@@ -215,11 +215,9 @@ CREATE_FUNCTION();
using ty = const int;
ty p21() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'ty' (aka 'const int') is
typedef const int ty2;
ty2 p22() {}
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'ty2' (aka 'const int') i
// Declaration uses a macro, while definition doesn't. In this case, we won't
// fix the declaration, and will instead issue a warning.
@@ -249,7 +247,6 @@ auto p27() -> int const { return 3; }
// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'const int' is 'const'-qu
std::add_const<int>::type p28() { return 3; }
-// CHECK-MESSAGES: [[@LINE-1]]:1: warning: return type 'std::add_const<int>::typ
// p29, p30 are based on
// llvm/projects/test-suite/SingleSource/Benchmarks/Misc-C++-EH/spirit.cpp:
@@ -355,3 +352,20 @@ struct p41 {
// CHECK-FIXES: T foo() const { return 2; }
};
template struct p41<int>;
+
+namespace PR73270 {
+ template<typename K, typename V>
+ struct Pair {
+ using first_type = const K;
+ using second_type = V;
+ };
+
+ template<typename PairType>
+ typename PairType::first_type getFirst() {
+ return {};
+ }
+
+ void test() {
+ getFirst<Pair<int, int>>();
+ }
+}