diff options
author | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
---|---|---|
committer | vitalyisaev <vitalyisaev@yandex-team.com> | 2023-06-29 10:00:50 +0300 |
commit | 6ffe9e53658409f212834330e13564e4952558f6 (patch) | |
tree | 85b1e00183517648b228aafa7c8fb07f5276f419 /contrib/libs/clang16/include/clang/AST/StmtIterator.h | |
parent | 726057070f9c5a91fc10fde0d5024913d10f1ab9 (diff) | |
download | ydb-6ffe9e53658409f212834330e13564e4952558f6.tar.gz |
YQ Connector: support managed ClickHouse
Со стороны dqrun можно обратиться к инстансу коннектора, который работает на streaming стенде, и извлечь данные из облачного CH.
Diffstat (limited to 'contrib/libs/clang16/include/clang/AST/StmtIterator.h')
-rw-r--r-- | contrib/libs/clang16/include/clang/AST/StmtIterator.h | 172 |
1 files changed, 172 insertions, 0 deletions
diff --git a/contrib/libs/clang16/include/clang/AST/StmtIterator.h b/contrib/libs/clang16/include/clang/AST/StmtIterator.h new file mode 100644 index 0000000000..d4a6e3d0e0 --- /dev/null +++ b/contrib/libs/clang16/include/clang/AST/StmtIterator.h @@ -0,0 +1,172 @@ +#pragma once + +#ifdef __GNUC__ +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wunused-parameter" +#endif + +//===- StmtIterator.h - Iterators for Statements ----------------*- C++ -*-===// +// +// 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 +// +//===----------------------------------------------------------------------===// +// +// This file defines the StmtIterator and ConstStmtIterator classes. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_CLANG_AST_STMTITERATOR_H +#define LLVM_CLANG_AST_STMTITERATOR_H + +#include <cassert> +#include <cstddef> +#include <cstdint> +#include <iterator> + +namespace clang { + +class Decl; +class Stmt; +class VariableArrayType; + +class StmtIteratorBase { +protected: + enum { + StmtMode = 0x0, + SizeOfTypeVAMode = 0x1, + DeclGroupMode = 0x2, + Flags = 0x3 + }; + + union { + Stmt **stmt; + Decl **DGI; + }; + uintptr_t RawVAPtr = 0; + Decl **DGE; + + StmtIteratorBase(Stmt **s) : stmt(s) {} + StmtIteratorBase(const VariableArrayType *t); + StmtIteratorBase(Decl **dgi, Decl **dge); + StmtIteratorBase() : stmt(nullptr) {} + + bool inDeclGroup() const { + return (RawVAPtr & Flags) == DeclGroupMode; + } + + bool inSizeOfTypeVA() const { + return (RawVAPtr & Flags) == SizeOfTypeVAMode; + } + + bool inStmt() const { + return (RawVAPtr & Flags) == StmtMode; + } + + const VariableArrayType *getVAPtr() const { + return reinterpret_cast<const VariableArrayType*>(RawVAPtr & ~Flags); + } + + void setVAPtr(const VariableArrayType *P) { + assert(inDeclGroup() || inSizeOfTypeVA()); + RawVAPtr = reinterpret_cast<uintptr_t>(P) | (RawVAPtr & Flags); + } + + void NextDecl(bool ImmediateAdvance = true); + bool HandleDecl(Decl* D); + void NextVA(); + + Stmt*& GetDeclExpr() const; +}; + +template <typename DERIVED, typename REFERENCE> +class StmtIteratorImpl : public StmtIteratorBase { +protected: + StmtIteratorImpl(const StmtIteratorBase& RHS) : StmtIteratorBase(RHS) {} + +public: + using iterator_category = std::forward_iterator_tag; + using value_type = REFERENCE; + using difference_type = std::ptrdiff_t; + using pointer = REFERENCE; + using reference = REFERENCE; + + StmtIteratorImpl() = default; + StmtIteratorImpl(Stmt **s) : StmtIteratorBase(s) {} + StmtIteratorImpl(Decl **dgi, Decl **dge) : StmtIteratorBase(dgi, dge) {} + StmtIteratorImpl(const VariableArrayType *t) : StmtIteratorBase(t) {} + + DERIVED& operator++() { + if (inStmt()) + ++stmt; + else if (getVAPtr()) + NextVA(); + else + NextDecl(); + + return static_cast<DERIVED&>(*this); + } + + DERIVED operator++(int) { + DERIVED tmp = static_cast<DERIVED&>(*this); + operator++(); + return tmp; + } + + friend bool operator==(const DERIVED &LHS, const DERIVED &RHS) { + return LHS.stmt == RHS.stmt && LHS.DGI == RHS.DGI && + LHS.RawVAPtr == RHS.RawVAPtr; + } + + friend bool operator!=(const DERIVED &LHS, const DERIVED &RHS) { + return !(LHS == RHS); + } + + REFERENCE operator*() const { + return inStmt() ? *stmt : GetDeclExpr(); + } + + REFERENCE operator->() const { return operator*(); } +}; + +struct ConstStmtIterator; + +struct StmtIterator : public StmtIteratorImpl<StmtIterator, Stmt*&> { + explicit StmtIterator() = default; + StmtIterator(Stmt** S) : StmtIteratorImpl<StmtIterator, Stmt*&>(S) {} + StmtIterator(Decl** dgi, Decl** dge) + : StmtIteratorImpl<StmtIterator, Stmt*&>(dgi, dge) {} + StmtIterator(const VariableArrayType *t) + : StmtIteratorImpl<StmtIterator, Stmt*&>(t) {} + +private: + StmtIterator(const StmtIteratorBase &RHS) + : StmtIteratorImpl<StmtIterator, Stmt *&>(RHS) {} + + inline friend StmtIterator + cast_away_const(const ConstStmtIterator &RHS); +}; + +struct ConstStmtIterator : public StmtIteratorImpl<ConstStmtIterator, + const Stmt*> { + explicit ConstStmtIterator() = default; + ConstStmtIterator(const StmtIterator& RHS) + : StmtIteratorImpl<ConstStmtIterator, const Stmt*>(RHS) {} + + ConstStmtIterator(Stmt * const *S) + : StmtIteratorImpl<ConstStmtIterator, const Stmt *>( + const_cast<Stmt **>(S)) {} +}; + +inline StmtIterator cast_away_const(const ConstStmtIterator &RHS) { + return RHS; +} + +} // namespace clang + +#endif // LLVM_CLANG_AST_STMTITERATOR_H + +#ifdef __GNUC__ +#pragma GCC diagnostic pop +#endif |