[clang] [clang][ASTMatcher] Add matchers for CXXFoldExpr (PR #71245)
via cfe-commits
cfe-commits at lists.llvm.org
Fri Nov 3 18:26:34 PDT 2023
github-actions[bot] wrote:
<!--LLVM CODE FORMAT COMMENT: {clang-format}-->
:warning: C/C++ code formatter, clang-format found issues in your code. :warning:
<details>
<summary>
You can test this locally with the following command:
</summary>
``````````bash
git-clang-format --diff 9b2246d9fad9fe62be26d22e184f241304779551 bd26678cd8a444aac6c7362df7eadedbb614b7fe -- clang/include/clang/ASTMatchers/ASTMatchers.h clang/lib/ASTMatchers/ASTMatchersInternal.cpp clang/lib/ASTMatchers/Dynamic/Registry.cpp clang/unittests/AST/ASTImporterTest.cpp clang/unittests/ASTMatchers/ASTMatchersNarrowingTest.cpp clang/unittests/ASTMatchers/ASTMatchersNodeTest.cpp clang/unittests/ASTMatchers/ASTMatchersTraversalTest.cpp
``````````
</details>
<details>
<summary>
View the diff from clang-format here.
</summary>
``````````diff
diff --git a/clang/include/clang/ASTMatchers/ASTMatchers.h b/clang/include/clang/ASTMatchers/ASTMatchers.h
index 4e67faa155f0..2cd50dbf3a55 100644
--- a/clang/include/clang/ASTMatchers/ASTMatchers.h
+++ b/clang/include/clang/ASTMatchers/ASTMatchers.h
@@ -4704,7 +4704,7 @@ AST_MATCHER_P(CXXFoldExpr, hasOperator, BinaryOperatorKind, Op) {
/// int x{y}.
/// \endcode
AST_MATCHER_P2(InitListExpr, hasInit, unsigned, N,
- ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
+ ast_matchers::internal::Matcher<Expr>, InnerMatcher) {
return N < Node.getNumInits() &&
InnerMatcher.matches(*Node.getInit(N), Finder, Builder);
}
diff --git a/clang/unittests/AST/ASTImporterTest.cpp b/clang/unittests/AST/ASTImporterTest.cpp
index a312ffa7070d..b150ba665fa4 100644
--- a/clang/unittests/AST/ASTImporterTest.cpp
+++ b/clang/unittests/AST/ASTImporterTest.cpp
@@ -804,11 +804,12 @@ TEST_P(ImportExpr, ImportSizeOfPackExpr) {
}
TEST_P(ImportExpr, ImportCXXFoldExpr) {
- auto Match1 =
- cxxFoldExpr(hasOperator(BO_Add), isLeftFold(), unless(hasFoldInit(expr())));
- auto Match2 = cxxFoldExpr(hasOperator(BO_Sub), isLeftFold(), hasFoldInit(expr()));
- auto Match3 =
- cxxFoldExpr(hasOperator(BO_Mul), isRightFold(), unless(hasFoldInit(expr())));
+ auto Match1 = cxxFoldExpr(hasOperator(BO_Add), isLeftFold(),
+ unless(hasFoldInit(expr())));
+ auto Match2 =
+ cxxFoldExpr(hasOperator(BO_Sub), isLeftFold(), hasFoldInit(expr()));
+ auto Match3 = cxxFoldExpr(hasOperator(BO_Mul), isRightFold(),
+ unless(hasFoldInit(expr())));
auto Match4 =
cxxFoldExpr(hasOperator(BO_Div), isRightFold(), hasFoldInit(expr()));
``````````
</details>
https://github.com/llvm/llvm-project/pull/71245
More information about the cfe-commits
mailing list