@@ -24,31 +24,31 @@ using namespace clang::ast_matchers;
24
24
25
25
namespace clang ::tidy::readability {
26
26
27
- AST_POLYMORPHIC_MATCHER (isInlineSpecified, AST_POLYMORPHIC_SUPPORTED_TYPES(
28
- FunctionDecl,
29
- VarDecl)) {
27
+ AST_POLYMORPHIC_MATCHER (isInlineSpecified,
28
+ AST_POLYMORPHIC_SUPPORTED_TYPES ( FunctionDecl,
29
+ VarDecl)) {
30
30
if (const auto *FD = dyn_cast<FunctionDecl>(&Node))
31
31
return FD->isInlineSpecified ();
32
32
if (const auto *VD = dyn_cast<VarDecl>(&Node))
33
33
return VD->isInlineSpecified ();
34
34
llvm_unreachable (" Not a valid polymorphic type" );
35
35
}
36
36
37
-
38
37
static std::optional<SourceLocation>
39
38
getInlineTokenLocation (SourceRange RangeLocation, const SourceManager &Sources,
40
39
const LangOptions &LangOpts) {
41
40
Token FirstToken;
42
41
Lexer::getRawToken (RangeLocation.getBegin (), FirstToken, Sources, LangOpts,
43
- true );
42
+ true );
44
43
std::optional<Token> CurrentToken = FirstToken;
45
44
while (CurrentToken && CurrentToken->getLocation () < RangeLocation.getEnd () &&
46
45
CurrentToken->isNot (tok::eof)) {
47
46
if (CurrentToken->is (tok::raw_identifier) &&
48
47
CurrentToken->getRawIdentifier () == " inline" )
49
48
return CurrentToken->getLocation ();
50
49
51
- CurrentToken = Lexer::findNextToken (CurrentToken->getLocation (), Sources, LangOpts);
50
+ CurrentToken =
51
+ Lexer::findNextToken (CurrentToken->getLocation (), Sources, LangOpts);
52
52
}
53
53
return std::nullopt;
54
54
}
@@ -58,8 +58,7 @@ void RedundantInlineSpecifierCheck::registerMatchers(MatchFinder *Finder) {
58
58
functionDecl (unless (isExpansionInSystemHeader ()),
59
59
unless (hasAncestor (lambdaExpr ())), isInlineSpecified (),
60
60
anyOf (isConstexpr (), isDeleted (),
61
- allOf (isDefinition (), hasAncestor (recordDecl ()),
62
- unless (hasAncestor (cxxConstructorDecl ())))))
61
+ allOf (isDefinition (), hasAncestor (recordDecl ()))))
63
62
.bind (" fun_decl" ),
64
63
this );
65
64
@@ -71,16 +70,18 @@ void RedundantInlineSpecifierCheck::registerMatchers(MatchFinder *Finder) {
71
70
this );
72
71
73
72
Finder->addMatcher (
74
- functionTemplateDecl (has (functionDecl (isInlineSpecified ()))).bind (" templ_decl" ),
73
+ functionTemplateDecl (has (functionDecl (isInlineSpecified ())))
74
+ .bind (" templ_decl" ),
75
75
this );
76
76
}
77
77
78
78
template <typename T>
79
79
void RedundantInlineSpecifierCheck::handleMatchedDecl (
80
80
const T *MatchedDecl, const SourceManager &Sources,
81
81
const MatchFinder::MatchResult &Result, StringRef Message) {
82
- if (std::optional<SourceLocation> Loc = getInlineTokenLocation (MatchedDecl->getSourceRange (), Sources,
83
- Result.Context ->getLangOpts ()))
82
+ if (std::optional<SourceLocation> Loc =
83
+ getInlineTokenLocation (MatchedDecl->getSourceRange (), Sources,
84
+ Result.Context ->getLangOpts ()))
84
85
diag (*Loc, Message) << MatchedDecl << FixItHint::CreateRemoval (*Loc);
85
86
}
86
87
0 commit comments