File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -28,9 +28,6 @@ class UseDesignatedInitializersCheck : public ClangTidyCheck {
28
28
std::optional<TraversalKind> getCheckTraversalKind () const override {
29
29
return TK_IgnoreUnlessSpelledInSource;
30
30
}
31
- bool isLanguageVersionSupported (const LangOptions &LangOpts) const override {
32
- return LangOpts.CPlusPlus20 ;
33
- }
34
31
void storeOptions (ClangTidyOptions::OptionMap &Opts) override ;
35
32
36
33
private:
Original file line number Diff line number Diff line change @@ -12,7 +12,11 @@ arise when changing the order of fields.
12
12
13
13
C++ 20 supports the designated initializer syntax for aggregate types.
14
14
By applying it, we can always be sure that aggregates are constructed correctly,
15
- because the every variable being initialized is referenced by name.
15
+ because every variable being initialized is referenced by name.
16
+
17
+ Even when compiling in a language version older than C++ 20, depending on you compiler,
18
+ designated initializers are potentially supported. Therefore, the check is not restricted
19
+ to C++ 20 and older.
16
20
17
21
Example:
18
22
Original file line number Diff line number Diff line change 1
- // RUN: %check_clang_tidy -std=c++20 %s modernize-use-designated-initializers %t
2
- // RUN: %check_clang_tidy -check-suffixes=,SINGLE-ELEMENT -std=c++20 %s modernize-use-designated-initializers %t \
1
+ // RUN: %check_clang_tidy -std=c++17 %s modernize-use-designated-initializers %t
2
+ // RUN: %check_clang_tidy -check-suffixes=,SINGLE-ELEMENT -std=c++17 %s modernize-use-designated-initializers %t \
3
3
// RUN: -- -config="{CheckOptions: [{key: modernize-use-designated-initializers.IgnoreSingleElementAggregates, value: false}]}" \
4
4
// RUN: --
5
5
You can’t perform that action at this time.
0 commit comments