blob: 3ba2c441d8324b3c5df8309a00e57da094d46962 [file] [log] [blame]
Marcel Hlopko45b60ef2021-08-13 13:37:43 +00001// 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 Gribenkoe4e77d02022-03-17 14:09:39 +00005#ifndef CRUBIT_RS_BINDINGS_FROM_CC_FRONTEND_ACTION_H_
6#define CRUBIT_RS_BINDINGS_FROM_CC_FRONTEND_ACTION_H_
Marcel Hlopko45b60ef2021-08-13 13:37:43 +00007
8#include <memory>
9
Michael Forster974bf152022-05-12 00:40:59 -070010#include "rs_bindings_from_cc/decl_importer.h"
Lukasz Anforowiczcec7a8a2022-04-27 10:24:51 -070011#include "clang/AST/ASTConsumer.h"
12#include "clang/Frontend/CompilerInstance.h"
13#include "clang/Frontend/FrontendAction.h"
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000014
Marcel Hlopkof15e8ce2022-04-08 08:46:09 -070015namespace crubit {
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000016
17// Creates an `ASTConsumer` that generates the intermediate representation
Michael Forstera49d2e62022-01-28 07:26:40 +000018// (`IR`) into the invocation object.
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000019class FrontendAction : public clang::ASTFrontendAction {
20 public:
Michael Forster64217b42022-04-22 05:48:54 -070021 explicit FrontendAction(Invocation& invocation) : invocation_(invocation) {}
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000022
23 std::unique_ptr<clang::ASTConsumer> CreateASTConsumer(
Devin Jeanpierre31e104b2021-10-20 07:27:25 +000024 clang::CompilerInstance& instance, llvm::StringRef) override;
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000025
26 private:
Michael Forster64217b42022-04-22 05:48:54 -070027 Invocation& invocation_;
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000028};
29
Marcel Hlopkof15e8ce2022-04-08 08:46:09 -070030} // namespace crubit
Marcel Hlopko45b60ef2021-08-13 13:37:43 +000031
Dmitri Gribenkoe4e77d02022-03-17 14:09:39 +000032#endif // CRUBIT_RS_BINDINGS_FROM_CC_FRONTEND_ACTION_H_