summaryrefslogtreecommitdiff
path: root/include/clang/Frontend/FrontendAction.h
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
committerDimitry Andric <dim@FreeBSD.org>2019-01-19 10:04:05 +0000
commit676fbe8105eeb6ff4bb2ed261cb212fcfdbe7b63 (patch)
tree02a1ac369cb734d0abfa5000dd86e5b7797e6a74 /include/clang/Frontend/FrontendAction.h
parentc7e70c433efc6953dc3888b9fbf9f3512d7da2b0 (diff)
Diffstat (limited to 'include/clang/Frontend/FrontendAction.h')
-rw-r--r--include/clang/Frontend/FrontendAction.h20
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,