|
14 | 14 | using namespace clang::ast_matchers;
|
15 | 15 |
|
16 | 16 | 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"; |
31 | 17 |
|
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"; |
40 | 31 |
|
41 | 32 | /// Try to match exactly two VarDecl inside two DeclStmts, and set binding for
|
42 | 33 | /// 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) { |
48 | 40 | SmallVector<std::pair<const VarDecl *, const DeclStmt *>, 2> Vars;
|
49 | 41 | auto CollectVarsInDeclStmt = [&Vars](const DeclStmt *DS) -> bool {
|
50 | 42 | if (!DS)
|
@@ -82,6 +74,16 @@ bool matchTwoVarDecl(const DeclStmt *DS1, const DeclStmt *DS2,
|
82 | 74 | return false;
|
83 | 75 | }
|
84 | 76 |
|
| 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 | + |
85 | 87 | /// Matches a Stmt whose parent is a CompoundStmt, and which is directly
|
86 | 88 | /// following two VarDecls matching the inner matcher, at the same time set
|
87 | 89 | /// binding for the CompoundStmt.
|
|
0 commit comments