File tree Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Expand file tree Collapse file tree 3 files changed +9
-14
lines changed Original file line number Diff line number Diff line change @@ -23,21 +23,14 @@ void ReturnBracedInitListCheck::registerMatchers(MatchFinder *Finder) {
23
23
auto ConstructExpr =
24
24
cxxConstructExpr (
25
25
unless (anyOf (hasDeclaration (cxxConstructorDecl (isExplicit ())),
26
- isListInitialization (), hasDescendant (initListExpr ()),
27
- isInTemplateInstantiation ())))
26
+ isListInitialization (), hasDescendant (initListExpr ()))))
28
27
.bind (" ctor" );
29
28
30
- auto CtorAsArgument = materializeTemporaryExpr (anyOf (
31
- has (ConstructExpr), has (cxxFunctionalCastExpr (has (ConstructExpr)))));
32
-
33
29
Finder->addMatcher (
34
- traverse (TK_AsIs,
35
- functionDecl (
36
- isDefinition (), // Declarations don't have return statements.
37
- returns (unless (anyOf (builtinType (), autoType ()))),
38
- hasDescendant (returnStmt (hasReturnValue (
39
- has (cxxConstructExpr (has (CtorAsArgument)))))))
40
- .bind (" fn" )),
30
+ returnStmt (hasReturnValue (ConstructExpr),
31
+ forFunction (functionDecl (returns (unless (anyOf (builtinType (),
32
+ autoType ()))))
33
+ .bind (" fn" ))),
41
34
this );
42
35
}
43
36
Original file line number Diff line number Diff line change @@ -29,6 +29,9 @@ class ReturnBracedInitListCheck : public ClangTidyCheck {
29
29
}
30
30
void registerMatchers (ast_matchers::MatchFinder *Finder) override ;
31
31
void check (const ast_matchers::MatchFinder::MatchResult &Result) override ;
32
+ llvm::Optional<TraversalKind> getCheckTraversalKind () const override {
33
+ return TK_IgnoreUnlessSpelledInSource;
34
+ }
32
35
};
33
36
34
37
} // namespace modernize
Original file line number Diff line number Diff line change 1
- // RUN: %check_clang_tidy -std=c++14 %s modernize-return-braced-init-list %t
2
- // FIXME: Fix the checker to work in C++17 mode.
1
+ // RUN: %check_clang_tidy -std=c++14-or-later %s modernize-return-braced-init-list %t
3
2
4
3
namespace std {
5
4
typedef decltype (sizeof (int )) size_t;
You can’t perform that action at this time.
0 commit comments