| // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| // Exceptions. See /LICENSE for license information. |
| // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| |
| #ifndef CRUBIT_MIGRATOR_RS_FROM_CC_CONVERTER_H_ |
| #define CRUBIT_MIGRATOR_RS_FROM_CC_CONVERTER_H_ |
| |
| #include <memory> |
| #include <optional> |
| #include <set> |
| #include <string> |
| #include <utility> |
| #include <variant> |
| #include <vector> |
| |
| #include "absl/container/flat_hash_map.h" |
| #include "absl/container/flat_hash_set.h" |
| #include "absl/status/statusor.h" |
| #include "absl/types/span.h" |
| #include "lifetime_annotations/lifetime_annotations.h" |
| #include "clang/AST/ASTContext.h" |
| #include "clang/AST/Decl.h" |
| #include "clang/AST/Mangle.h" |
| #include "clang/AST/RawCommentList.h" |
| #include "clang/AST/Type.h" |
| #include "clang/Basic/SourceLocation.h" |
| #include "clang/Basic/Specifiers.h" |
| #include "clang/Sema/Sema.h" |
| |
| namespace crubit_rs_from_cc { |
| |
| // Visits the C++ AST and generates the corresponding Rust code in the |
| // Invocation object. |
| class Converter { |
| public: |
| // Top-level parameters as well as return value of a migrator invocation. |
| class Invocation { |
| public: |
| std::string rs_code_; |
| }; |
| |
| explicit Converter(Invocation& invocation, clang::ASTContext& ctx) |
| : result_(invocation.rs_code_), ctx_(ctx) {} |
| |
| void Convert(const clang::TranslationUnitDecl* translation_unit); |
| |
| private: |
| void Convert(const clang::Decl* decl); |
| |
| void ConvertUnhandled(const clang::Decl* decl); |
| |
| // The main output of the conversion process (Rust code). |
| std::string& result_; |
| |
| clang::ASTContext& ctx_; |
| }; // class Converter |
| |
| } // namespace crubit_rs_from_cc |
| |
| #endif // CRUBIT_MIGRATOR_RS_FROM_CC_CONVERTER_H_ |