[clang] [lld] [llvm] [Support] Add ToolSession for in-process tool invocation (PR #221996)
Anutosh Bhat via llvm-commits
llvm-commits at lists.llvm.org
Wed Sep 16 11:45:55 PDT 2026
================
@@ -20,6 +47,48 @@ struct ToolContext {
// point to the llvm-driver executable, where PrependArg will be needed to
// invoke the correct tool.
bool NeedsPrependArg;
+
+ ToolContext(const char *Path, const char *PrependArg, bool NeedsPrependArg)
+ : Path(Path), PrependArg(PrependArg), NeedsPrependArg(NeedsPrependArg) {}
+
+ /// Finds a tool registered with the session that owns this context.
+ LLVM_ABI ErrorOr<CallableTool> getCallableTool(StringRef Name) const;
+
+ /// Invokes another tool registered with the same host session.
+ LLVM_ABI ErrorOr<int> callTool(ArrayRef<const char *> Args) const;
+};
+
+/// Owns LLVM process initialization and an in-process tool registry.
+///
+/// A long-lived host constructs one session and uses it for every embedded
+/// tool invocation. The individual tools borrow a ToolContext and therefore do
+/// not initialize or shut down LLVM themselves.
+///
+/// LLVM tools may use process-global state. Tool invocations must be externally
+/// serialized; concurrent calls are not supported.
+class LLVM_ABI LLVMToolSession {
----------------
anutosh491 wrote:
We can also do the renaming in a subsequent PR if anyone think the last commit disturbs the main purpose of this PR. Just saying !
https://github.com/llvm/llvm-project/pull/221996
More information about the llvm-commits
mailing list