Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [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 | |
Dmitri Gribenko | e4e77d0 | 2022-03-17 14:09:39 +0000 | [diff] [blame] | 5 | #ifndef CRUBIT_RS_BINDINGS_FROM_CC_AST_CONSUMER_H_ |
| 6 | #define CRUBIT_RS_BINDINGS_FROM_CC_AST_CONSUMER_H_ |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 7 | |
Michael Forster | 974bf15 | 2022-05-12 00:40:59 -0700 | [diff] [blame] | 8 | #include "rs_bindings_from_cc/decl_importer.h" |
Lukasz Anforowicz | cec7a8a | 2022-04-27 10:24:51 -0700 | [diff] [blame] | 9 | #include "clang/AST/ASTConsumer.h" |
| 10 | #include "clang/AST/ASTContext.h" |
| 11 | #include "clang/Frontend/CompilerInstance.h" |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 12 | |
Marcel Hlopko | f15e8ce | 2022-04-08 08:46:09 -0700 | [diff] [blame] | 13 | namespace crubit { |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 14 | |
Michael Forster | a49d2e6 | 2022-01-28 07:26:40 +0000 | [diff] [blame] | 15 | // Consumes the Clang AST created from the invocation's entry header and |
| 16 | // generates the intermediate representation (`IR`) in the invocation object. |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 17 | class AstConsumer : public clang::ASTConsumer { |
| 18 | public: |
Michael Forster | a49d2e6 | 2022-01-28 07:26:40 +0000 | [diff] [blame] | 19 | explicit AstConsumer(clang::CompilerInstance& instance, |
Michael Forster | 64217b4 | 2022-04-22 05:48:54 -0700 | [diff] [blame] | 20 | Invocation& invocation) |
Michael Forster | a49d2e6 | 2022-01-28 07:26:40 +0000 | [diff] [blame] | 21 | : instance_(instance), invocation_(invocation) {} |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 22 | |
Marcel Hlopko | e936aac | 2021-08-24 20:52:27 +0000 | [diff] [blame] | 23 | void HandleTranslationUnit(clang::ASTContext& context) override; |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 24 | |
| 25 | private: |
Devin Jeanpierre | 31e104b | 2021-10-20 07:27:25 +0000 | [diff] [blame] | 26 | clang::CompilerInstance& instance_; |
Michael Forster | 64217b4 | 2022-04-22 05:48:54 -0700 | [diff] [blame] | 27 | Invocation& invocation_; |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 28 | }; // class AstConsumer |
| 29 | |
Marcel Hlopko | f15e8ce | 2022-04-08 08:46:09 -0700 | [diff] [blame] | 30 | } // namespace crubit |
Marcel Hlopko | e8f1c4e | 2021-07-28 18:12:49 +0000 | [diff] [blame] | 31 | |
Dmitri Gribenko | e4e77d0 | 2022-03-17 14:09:39 +0000 | [diff] [blame] | 32 | #endif // CRUBIT_RS_BINDINGS_FROM_CC_AST_CONSUMER_H_ |