Marco Poletti | b5239c9 | 2022-05-11 09:46:05 -0700 | [diff] [blame] | 1 | // Part of the Crubit project, under the Apache License v2.0 with LLVM |
| 2 | // Exceptions. See /LICENSE for license information. |
| 3 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception |
| 4 | |
| 5 | #ifndef CRUBIT_MIGRATOR_RS_FROM_CC_AST_CONSUMER_H_ |
| 6 | #define CRUBIT_MIGRATOR_RS_FROM_CC_AST_CONSUMER_H_ |
| 7 | |
| 8 | #include "migrator/rs_from_cc/converter.h" |
| 9 | #include "clang/AST/ASTConsumer.h" |
| 10 | #include "clang/AST/ASTContext.h" |
| 11 | #include "clang/Frontend/CompilerInstance.h" |
| 12 | |
| 13 | namespace crubit_rs_from_cc { |
| 14 | |
| 15 | // Consumes the Clang AST created from the invocation's entry header and |
| 16 | // generates the intermediate representation (`IR`) in the invocation object. |
| 17 | class AstConsumer : public clang::ASTConsumer { |
| 18 | public: |
| 19 | explicit AstConsumer(clang::CompilerInstance& instance, |
| 20 | Converter::Invocation& invocation) |
| 21 | : instance_(instance), invocation_(invocation) {} |
| 22 | |
| 23 | void HandleTranslationUnit(clang::ASTContext& context) override; |
| 24 | |
| 25 | private: |
| 26 | clang::CompilerInstance& instance_; |
| 27 | Converter::Invocation& invocation_; |
| 28 | }; // class AstConsumer |
| 29 | |
| 30 | } // namespace crubit_rs_from_cc |
| 31 | |
| 32 | #endif // CRUBIT_MIGRATOR_RS_FROM_CC_AST_CONSUMER_H_ |