18#ifndef FORTRAN_FRONTEND_FRONTENDACTION_H
19#define FORTRAN_FRONTEND_FRONTENDACTION_H
21#include "flang/Frontend/FrontendOptions.h"
22#include "llvm/Support/Error.h"
24namespace Fortran::frontend {
25class CompilerInstance;
56 virtual ~FrontendAction() =
default;
61 CompilerInstance &getInstance()
const {
62 assert(instance &&
"Compiler instance not registered!");
66 void setInstance(CompilerInstance *value) { instance = value; }
72 const FrontendInputFile &getCurrentInput()
const {
return currentInput; }
74 llvm::StringRef getCurrentFile()
const {
75 assert(!currentInput.isEmpty() &&
"No current file!");
76 return currentInput.getFile();
79 llvm::StringRef getCurrentFileOrBufferName()
const {
80 assert(!currentInput.isEmpty() &&
"No current file!");
81 return currentInput.isFile()
82 ? currentInput.getFile()
83 : currentInput.getBuffer()->getBufferIdentifier();
85 void setCurrentInput(
const FrontendInputFile ¤tIntput);
99 bool beginSourceFile(CompilerInstance &ci,
const FrontendInputFile &input);
115 bool runParse(
bool emitMessages);
118 bool runSemanticChecks();
122 bool generateRtTypeTables();
125 bool reportFatalSemanticErrors();
128 inline bool reportFatalScanningErrors() {
129 return reportFatalErrors(
"Could not scan %0");
133 inline bool reportFatalParsingErrors() {
134 return reportFatalErrors(
"Could not parse %0");
138 template <
unsigned N>
139 bool reportFatalErrors(
const char (&message)[N]);
Definition: CompilerInstance.h:44
Abstract base class for actions which can be performed by the frontend.
Definition: FrontendAction.h:28
virtual bool shouldEraseOutputFiles()
Definition: FrontendAction.cpp:116
virtual void executeAction()=0
virtual bool beginSourceFileAction()
Definition: FrontendAction.h:50
bool beginSourceFile(CompilerInstance &ci, const FrontendInputFile &input)
Definition: FrontendAction.cpp:38
void endSourceFile()
Definition: FrontendAction.cpp:126
llvm::Error execute()
Run the action.
Definition: FrontendAction.cpp:120