Skip to content

Commit d92f768

Browse files
committed
[NFC] prefer static function
1 parent c5c673b commit d92f768

File tree

1 file changed

+29
-27
lines changed

1 file changed

+29
-27
lines changed

clang-tools-extra/clang-tidy/modernize/UseStructuredBindingCheck.cpp

Lines changed: 29 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -14,37 +14,29 @@
1414
using namespace clang::ast_matchers;
1515

1616
namespace clang::tidy::modernize {
17-
namespace {
18-
constexpr const char *DefaultPairTypes = "std::pair";
19-
constexpr llvm::StringLiteral PairDeclName = "PairVarD";
20-
constexpr llvm::StringLiteral PairVarTypeName = "PairVarType";
21-
constexpr llvm::StringLiteral FirstVarDeclName = "FirstVarDecl";
22-
constexpr llvm::StringLiteral SecondVarDeclName = "SecondVarDecl";
23-
constexpr llvm::StringLiteral FirstDeclStmtName = "FirstDeclStmt";
24-
constexpr llvm::StringLiteral SecondDeclStmtName = "SecondDeclStmt";
25-
constexpr llvm::StringLiteral FirstTypeName = "FirstType";
26-
constexpr llvm::StringLiteral SecondTypeName = "SecondType";
27-
constexpr llvm::StringLiteral ScopeBlockName = "ScopeBlock";
28-
constexpr llvm::StringLiteral StdTieAssignStmtName = "StdTieAssign";
29-
constexpr llvm::StringLiteral StdTieExprName = "StdTieExpr";
30-
constexpr llvm::StringLiteral ForRangeStmtName = "ForRangeStmt";
3117

32-
/// What qualifiers and specifiers are used to create structured binding
33-
/// declaration, it only supports the following four cases now.
34-
enum TransferType : uint8_t {
35-
TT_ByVal,
36-
TT_ByConstVal,
37-
TT_ByRef,
38-
TT_ByConstRef
39-
};
18+
static constexpr const char *DefaultPairTypes = "std::pair";
19+
static constexpr llvm::StringLiteral PairDeclName = "PairVarD";
20+
static constexpr llvm::StringLiteral PairVarTypeName = "PairVarType";
21+
static constexpr llvm::StringLiteral FirstVarDeclName = "FirstVarDecl";
22+
static constexpr llvm::StringLiteral SecondVarDeclName = "SecondVarDecl";
23+
static constexpr llvm::StringLiteral FirstDeclStmtName = "FirstDeclStmt";
24+
static constexpr llvm::StringLiteral SecondDeclStmtName = "SecondDeclStmt";
25+
static constexpr llvm::StringLiteral FirstTypeName = "FirstType";
26+
static constexpr llvm::StringLiteral SecondTypeName = "SecondType";
27+
static constexpr llvm::StringLiteral ScopeBlockName = "ScopeBlock";
28+
static constexpr llvm::StringLiteral StdTieAssignStmtName = "StdTieAssign";
29+
static constexpr llvm::StringLiteral StdTieExprName = "StdTieExpr";
30+
static constexpr llvm::StringLiteral ForRangeStmtName = "ForRangeStmt";
4031

4132
/// Try to match exactly two VarDecl inside two DeclStmts, and set binding for
4233
/// the used DeclStmts.
43-
bool matchTwoVarDecl(const DeclStmt *DS1, const DeclStmt *DS2,
44-
ast_matchers::internal::Matcher<VarDecl> InnerMatcher1,
45-
ast_matchers::internal::Matcher<VarDecl> InnerMatcher2,
46-
internal::ASTMatchFinder *Finder,
47-
internal::BoundNodesTreeBuilder *Builder) {
34+
static bool
35+
matchTwoVarDecl(const DeclStmt *DS1, const DeclStmt *DS2,
36+
ast_matchers::internal::Matcher<VarDecl> InnerMatcher1,
37+
ast_matchers::internal::Matcher<VarDecl> InnerMatcher2,
38+
internal::ASTMatchFinder *Finder,
39+
internal::BoundNodesTreeBuilder *Builder) {
4840
SmallVector<std::pair<const VarDecl *, const DeclStmt *>, 2> Vars;
4941
auto CollectVarsInDeclStmt = [&Vars](const DeclStmt *DS) -> bool {
5042
if (!DS)
@@ -82,6 +74,16 @@ bool matchTwoVarDecl(const DeclStmt *DS1, const DeclStmt *DS2,
8274
return false;
8375
}
8476

77+
namespace {
78+
/// What qualifiers and specifiers are used to create structured binding
79+
/// declaration, it only supports the following four cases now.
80+
enum TransferType : uint8_t {
81+
TT_ByVal,
82+
TT_ByConstVal,
83+
TT_ByRef,
84+
TT_ByConstRef
85+
};
86+
8587
/// Matches a Stmt whose parent is a CompoundStmt, and which is directly
8688
/// following two VarDecls matching the inner matcher, at the same time set
8789
/// binding for the CompoundStmt.

0 commit comments

Comments
 (0)