diff options
Diffstat (limited to 'include/clang/Frontend/FrontendAction.h')
-rw-r--r-- | include/clang/Frontend/FrontendAction.h | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/include/clang/Frontend/FrontendAction.h b/include/clang/Frontend/FrontendAction.h index 2a4077d34391e..22314386e0600 100644 --- a/include/clang/Frontend/FrontendAction.h +++ b/include/clang/Frontend/FrontendAction.h @@ -48,6 +48,12 @@ protected: /// @name Implementation Action Interface /// @{ + /// Prepare to execute the action on the given CompilerInstance. + /// + /// This is called before executing the action on any inputs, and can modify + /// the configuration as needed (including adjusting the input list). + virtual bool PrepareToExecuteAction(CompilerInstance &CI) { return true; } + /// Create the AST consumer object for this action, if supported. /// /// This routine is called as part of BeginSourceFile(), which will @@ -130,11 +136,18 @@ public: return CurrentInput; } - const StringRef getCurrentFile() const { + StringRef getCurrentFile() const { assert(!CurrentInput.isEmpty() && "No current file!"); return CurrentInput.getFile(); } + StringRef getCurrentFileOrBufferName() const { + assert(!CurrentInput.isEmpty() && "No current file!"); + return CurrentInput.isFile() + ? CurrentInput.getFile() + : CurrentInput.getBuffer()->getBufferIdentifier(); + } + InputKind getCurrentFileKind() const { assert(!CurrentInput.isEmpty() && "No current file!"); return CurrentInput.getKind(); @@ -190,6 +203,11 @@ public: /// @name Public Action Interface /// @{ + /// Prepare the action to execute on the given compiler instance. + bool PrepareToExecute(CompilerInstance &CI) { + return PrepareToExecuteAction(CI); + } + /// Prepare the action for processing the input file \p Input. /// /// This is run after the options and frontend have been initialized, |