aboutsummaryrefslogtreecommitdiffstats
path: root/contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h
diff options
context:
space:
mode:
authorvitalyisaev <vitalyisaev@yandex-team.com>2023-06-29 10:00:50 +0300
committervitalyisaev <vitalyisaev@yandex-team.com>2023-06-29 10:00:50 +0300
commit6ffe9e53658409f212834330e13564e4952558f6 (patch)
tree85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h
parent726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff)
downloadydb-6ffe9e53658409f212834330e13564e4952558f6.tar.gz
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h')
-rw-r--r--contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h68
1 files changed, 68 insertions, 0 deletions
diff --git a/contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h b/contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h
new file mode 100644
index 0000000000..0b11b0d1e6
--- /dev/null
+++ b/contrib/libs/clang14/tools/extra/clang-tidy/readability/SimplifyBooleanExprMatchers.h
@@ -0,0 +1,68 @@
+//===-- SimplifyBooleanExprMatchers.h - clang-tidy ------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "clang/ASTMatchers/ASTMatchersInternal.h"
+#include "clang/ASTMatchers/ASTMatchersMacros.h"
+
+namespace clang {
+namespace ast_matchers {
+
+/// Matches the substatement associated with a case, default or label statement.
+///
+/// Given
+/// \code
+/// switch (1) { case 1: break; case 2: return; break; default: return; break;
+/// }
+/// foo: return;
+/// bar: break;
+/// \endcode
+///
+/// caseStmt(hasSubstatement(returnStmt()))
+/// matches "case 2: return;"
+/// defaultStmt(hasSubstatement(returnStmt()))
+/// matches "default: return;"
+/// labelStmt(hasSubstatement(breakStmt()))
+/// matches "bar: break;"
+AST_POLYMORPHIC_MATCHER_P(hasSubstatement,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CaseStmt, DefaultStmt,
+ LabelStmt),
+ internal::Matcher<Stmt>, InnerMatcher) {
+ return InnerMatcher.matches(*Node.getSubStmt(), Finder, Builder);
+}
+
+/// Matches two consecutive statements within a compound statement.
+///
+/// Given
+/// \code
+/// { if (x > 0) return true; return false; }
+/// \endcode
+/// compoundStmt(hasSubstatementSequence(ifStmt(), returnStmt()))
+/// matches '{ if (x > 0) return true; return false; }'
+AST_POLYMORPHIC_MATCHER_P2(hasSubstatementSequence,
+ AST_POLYMORPHIC_SUPPORTED_TYPES(CompoundStmt,
+ StmtExpr),
+ internal::Matcher<Stmt>, InnerMatcher1,
+ internal::Matcher<Stmt>, InnerMatcher2) {
+ if (const CompoundStmt *CS = CompoundStmtMatcher<NodeType>::get(Node)) {
+ auto It = matchesFirstInPointerRange(InnerMatcher1, CS->body_begin(),
+ CS->body_end(), Finder, Builder);
+ while (It != CS->body_end()) {
+ ++It;
+ if (It == CS->body_end())
+ return false;
+ if (InnerMatcher2.matches(**It, Finder, Builder))
+ return true;
+ It = matchesFirstInPointerRange(InnerMatcher1, It, CS->body_end(), Finder,
+ Builder);
+ }
+ }
+ return false;
+}
+
+} // namespace ast_matchers
+} // namespace clang