Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +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_FRONTEND_ACTION_H_ |
| 6 | #define CRUBIT_RS_BINDINGS_FROM_CC_FRONTEND_ACTION_H_ |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 7 | |
| 8 | #include <memory> |
| 9 | |
Michael Forster | 974bf15 | 2022-05-12 00:40:59 -0700 | [diff] [blame] | 10 | #include "rs_bindings_from_cc/decl_importer.h" |
Lukasz Anforowicz | cec7a8a | 2022-04-27 10:24:51 -0700 | [diff] [blame] | 11 | #include "clang/AST/ASTConsumer.h" |
| 12 | #include "clang/Frontend/CompilerInstance.h" |
| 13 | #include "clang/Frontend/FrontendAction.h" |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 14 | |
Marcel Hlopko | f15e8ce | 2022-04-08 08:46:09 -0700 | [diff] [blame] | 15 | namespace crubit { |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 16 | |
| 17 | // Creates an `ASTConsumer` that generates the intermediate representation |
Michael Forster | a49d2e6 | 2022-01-28 07:26:40 +0000 | [diff] [blame] | 18 | // (`IR`) into the invocation object. |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 19 | class FrontendAction : public clang::ASTFrontendAction { |
| 20 | public: |
Michael Forster | 64217b4 | 2022-04-22 05:48:54 -0700 | [diff] [blame] | 21 | explicit FrontendAction(Invocation& invocation) : invocation_(invocation) {} |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 22 | |
| 23 | std::unique_ptr<clang::ASTConsumer> CreateASTConsumer( |
Devin Jeanpierre | 31e104b | 2021-10-20 07:27:25 +0000 | [diff] [blame] | 24 | clang::CompilerInstance& instance, llvm::StringRef) override; |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 25 | |
| 26 | private: |
Michael Forster | 64217b4 | 2022-04-22 05:48:54 -0700 | [diff] [blame] | 27 | Invocation& invocation_; |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 28 | }; |
| 29 | |
Marcel Hlopko | f15e8ce | 2022-04-08 08:46:09 -0700 | [diff] [blame] | 30 | } // namespace crubit |
Marcel Hlopko | 45b60ef | 2021-08-13 13:37:43 +0000 | [diff] [blame] | 31 | |
Dmitri Gribenko | e4e77d0 | 2022-03-17 14:09:39 +0000 | [diff] [blame] | 32 | #endif // CRUBIT_RS_BINDINGS_FROM_CC_FRONTEND_ACTION_H_ |