-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[clang-tidy] Enable modernize-return-braced-init-list
's tests in C++11
#158196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@llvm/pr-subscribers-clang-tidy Author: Victor Chernyakin (localspook) ChangesThe check supports C++11: llvm-project/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.h Lines 25 to 27 in d5aa5e3
but isn't tested in it. Full diff: https://github.com/llvm/llvm-project/pull/158196.diff 1 Files Affected:
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
index 02e95e15499dc..1450a6d1e60ce 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-return-braced-init-list %t
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t
namespace std {
typedef decltype(sizeof(int)) size_t;
@@ -80,10 +80,12 @@ Foo f2() {
return {b2};
}
+#if __cplusplus >= 201402L
auto f3() {
Bar b3;
return Foo(b3);
}
+#endif
#define A(b) Foo(b)
|
@llvm/pr-subscribers-clang-tools-extra Author: Victor Chernyakin (localspook) ChangesThe check supports C++11: llvm-project/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.h Lines 25 to 27 in d5aa5e3
but isn't tested in it. Full diff: https://github.com/llvm/llvm-project/pull/158196.diff 1 Files Affected:
diff --git a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
index 02e95e15499dc..1450a6d1e60ce 100644
--- a/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
+++ b/clang-tools-extra/test/clang-tidy/checkers/modernize/return-braced-init-list.cpp
@@ -1,4 +1,4 @@
-// RUN: %check_clang_tidy -std=c++14-or-later %s modernize-return-braced-init-list %t
+// RUN: %check_clang_tidy %s modernize-return-braced-init-list %t
namespace std {
typedef decltype(sizeof(int)) size_t;
@@ -80,10 +80,12 @@ Foo f2() {
return {b2};
}
+#if __cplusplus >= 201402L
auto f3() {
Bar b3;
return Foo(b3);
}
+#endif
#define A(b) Foo(b)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The change will make it test only in C++17, won't it? Don't we want c++11-or-later instead?
It will be c++11-or-later by default: llvm-project/clang-tools-extra/test/clang-tidy/check_clang_tidy.py Lines 392 to 394 in 111de45
|
That's sounds very fragile, if the standard is important, the test should be explicit about it. Otherwise anyone can bump that standard in run-clang-tidy.py in the future to something else and suddenly this test no longer tests C++11. CI won't catch that. |
Maybe then we could fail test if |
This could be a problem for downstream users, but not a very significant one. To preserve current behavior, we could make a flag |
Some statistics: if we decide to force specifying |
Nah I don't think we should make it mandatory. There are checks that don't require any specific standard, there it would make sense to keep whatever the default is. I would say it makes sense to specify it in the test when the check also specifies it as requirement. |
This could also backfire for users that use "old" c++11. Imagine if the default standard is increased in |
Yes. I think we should think carefully about what the default standard means and should be, and when it should be bumped. If a check promises to work with "any" C++ standard (as is often the case), then it should in theory test all the standards it promises. Testing only C++11 or later risks the check not working for C++98 and C++03 for example. In other words I think the default standard in |
Since we bumped version of many checks to c++11 as intended, maybe it's time to downgrade check_clang_tidy default version to c++98 and see what breaks.:) |
Added |
…+11 (llvm#158196) The check supports C++11, but isn't tested in it.
The check supports C++11:
llvm-project/clang-tools-extra/clang-tidy/modernize/ReturnBracedInitListCheck.h
Lines 25 to 27 in d5aa5e3
but isn't tested in it.