aboutsummaryrefslogtreecommitdiff
path: root/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/llvm-project/clang/include/clang/Tooling/Tooling.h')
-rw-r--r--contrib/llvm-project/clang/include/clang/Tooling/Tooling.h39
1 files changed, 28 insertions, 11 deletions
diff --git a/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h b/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h
index 8b3b2e5ad002..070706e8fa6d 100644
--- a/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h
+++ b/contrib/llvm-project/clang/include/clang/Tooling/Tooling.h
@@ -54,7 +54,6 @@ class CompilerInstance;
class CompilerInvocation;
class DiagnosticConsumer;
class DiagnosticsEngine;
-class SourceManager;
namespace driver {
@@ -66,6 +65,14 @@ namespace tooling {
class CompilationDatabase;
+/// Retrieves the flags of the `-cc1` job in `Compilation` that has only source
+/// files as its inputs.
+/// Returns nullptr if there are no such jobs or multiple of them. Note that
+/// offloading jobs are ignored.
+const llvm::opt::ArgStringList *
+getCC1Arguments(DiagnosticsEngine *Diagnostics,
+ driver::Compilation *Compilation);
+
/// Interface to process a clang::CompilerInvocation.
///
/// If your tool is based on FrontendAction, you should be deriving from
@@ -107,7 +114,7 @@ public:
/// T must derive from clang::FrontendAction.
///
/// Example:
-/// FrontendActionFactory *Factory =
+/// std::unique_ptr<FrontendActionFactory> Factory =
/// newFrontendActionFactory<clang::SyntaxOnlyAction>();
template <typename T>
std::unique_ptr<FrontendActionFactory> newFrontendActionFactory();
@@ -137,7 +144,7 @@ public:
///
/// Example:
/// struct ProvidesASTConsumers {
-/// clang::ASTConsumer *newASTConsumer();
+/// std::unique_ptr<clang::ASTConsumer> newASTConsumer();
/// } Factory;
/// std::unique_ptr<FrontendActionFactory> FactoryAdapter(
/// newFrontendActionFactory(&Factory));
@@ -260,11 +267,20 @@ public:
~ToolInvocation();
- /// Set a \c DiagnosticConsumer to use during parsing.
+ ToolInvocation(const ToolInvocation &) = delete;
+ ToolInvocation &operator=(const ToolInvocation &) = delete;
+
+ /// Set a \c DiagnosticConsumer to use during driver command-line parsing and
+ /// the action invocation itself.
void setDiagnosticConsumer(DiagnosticConsumer *DiagConsumer) {
this->DiagConsumer = DiagConsumer;
}
+ /// Set a \c DiagnosticOptions to use during driver command-line parsing.
+ void setDiagnosticOptions(DiagnosticOptions *DiagOpts) {
+ this->DiagOpts = DiagOpts;
+ }
+
/// Run the clang invocation.
///
/// \returns True if there were no errors during execution.
@@ -282,6 +298,7 @@ public:
FileManager *Files;
std::shared_ptr<PCHContainerOperations> PCHContainerOps;
DiagnosticConsumer *DiagConsumer = nullptr;
+ DiagnosticOptions *DiagOpts = nullptr;
};
/// Utility to run a FrontendAction over a set of files.
@@ -347,11 +364,6 @@ public:
/// append them to ASTs.
int buildASTs(std::vector<std::unique_ptr<ASTUnit>> &ASTs);
- /// Sets whether working directory should be restored after calling run(). By
- /// default, working directory is restored. However, it could be useful to
- /// turn this off when running on multiple threads to avoid the raciness.
- void setRestoreWorkingDir(bool RestoreCWD);
-
/// Sets whether an error message should be printed out if an action fails. By
/// default, if an action fails, a message is printed out to stderr.
void setPrintErrorMessage(bool PrintErrorMessage);
@@ -381,7 +393,6 @@ private:
DiagnosticConsumer *DiagConsumer = nullptr;
- bool RestoreCWD = true;
bool PrintErrorMessage = true;
};
@@ -492,9 +503,15 @@ llvm::Expected<std::string> getAbsolutePath(llvm::vfs::FileSystem &FS,
void addTargetAndModeForProgramName(std::vector<std::string> &CommandLine,
StringRef InvokedAs);
+/// Helper function that expands response files in command line.
+void addExpandedResponseFiles(std::vector<std::string> &CommandLine,
+ llvm::StringRef WorkingDir,
+ llvm::cl::TokenizerCallback Tokenizer,
+ llvm::vfs::FileSystem &FS);
+
/// Creates a \c CompilerInvocation.
CompilerInvocation *newInvocation(DiagnosticsEngine *Diagnostics,
- const llvm::opt::ArgStringList &CC1Args,
+ ArrayRef<const char *> CC1Args,
const char *const BinaryName);
} // namespace tooling