clang 20.0.0git
Tool.h
Go to the documentation of this file.
1//===--- Tool.h - Compilation Tools -----------------------------*- C++ -*-===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#ifndef LLVM_CLANG_DRIVER_TOOL_H
10#define LLVM_CLANG_DRIVER_TOOL_H
11
12#include "clang/Basic/LLVM.h"
13
14namespace llvm {
15namespace opt {
16 class ArgList;
17}
18}
19
20namespace clang {
21namespace driver {
22
23 class Compilation;
24 class InputInfo;
25 class Job;
26 class JobAction;
27 class ToolChain;
28
29 typedef SmallVector<InputInfo, 4> InputInfoList;
30
31/// Tool - Information on a specific compilation tool.
32class Tool {
33 /// The tool name (for debugging).
34 const char *Name;
35
36 /// The human readable name for the tool, for use in diagnostics.
37 const char *ShortName;
38
39 /// The tool chain this tool is a part of.
40 const ToolChain &TheToolChain;
41
42public:
43 Tool(const char *Name, const char *ShortName, const ToolChain &TC);
44
45public:
46 virtual ~Tool();
47
48 const char *getName() const { return Name; }
49
50 const char *getShortName() const { return ShortName; }
51
52 const ToolChain &getToolChain() const { return TheToolChain; }
53
54 virtual bool hasIntegratedAssembler() const { return false; }
55 virtual bool hasIntegratedBackend() const { return true; }
56 virtual bool canEmitIR() const { return false; }
57 virtual bool hasIntegratedCPP() const = 0;
58 virtual bool isLinkJob() const { return false; }
59 virtual bool isDsymutilJob() const { return false; }
60
61 /// Does this tool have "good" standardized diagnostics, or should the
62 /// driver add an additional "command failed" diagnostic on failures.
63 virtual bool hasGoodDiagnostics() const { return false; }
64
65 /// ConstructJob - Construct jobs to perform the action \p JA,
66 /// writing to \p Output and with \p Inputs, and add the jobs to
67 /// \p C.
68 ///
69 /// \param TCArgs - The argument list for this toolchain, with any
70 /// tool chain specific translations applied.
71 /// \param LinkingOutput - If this output will eventually feed the
72 /// linker, then this is the final output name of the linked image.
73 virtual void ConstructJob(Compilation &C, const JobAction &JA,
74 const InputInfo &Output,
75 const InputInfoList &Inputs,
76 const llvm::opt::ArgList &TCArgs,
77 const char *LinkingOutput) const = 0;
78 /// Construct jobs to perform the action \p JA, writing to the \p Outputs and
79 /// with \p Inputs, and add the jobs to \p C. The default implementation
80 /// assumes a single output and is expected to be overloaded for the tools
81 /// that support multiple inputs.
82 ///
83 /// \param TCArgs The argument list for this toolchain, with any
84 /// tool chain specific translations applied.
85 /// \param LinkingOutput If this output will eventually feed the
86 /// linker, then this is the final output name of the linked image.
87 virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
88 const InputInfoList &Outputs,
89 const InputInfoList &Inputs,
90 const llvm::opt::ArgList &TCArgs,
91 const char *LinkingOutput) const;
92};
93
94} // end namespace driver
95} // end namespace clang
96
97#endif
Forward-declares and imports various common LLVM datatypes that clang wants to use unqualified.
int32_t ShortName
Definition: SemaARM.cpp:1146
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:92
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
virtual bool hasIntegratedAssembler() const
Definition: Tool.h:54
virtual bool isDsymutilJob() const
Definition: Tool.h:59
const ToolChain & getToolChain() const
Definition: Tool.h:52
virtual bool canEmitIR() const
Definition: Tool.h:56
virtual ~Tool()
Definition: Tool.cpp:17
virtual bool hasGoodDiagnostics() const
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Tool.h:63
const char * getName() const
Definition: Tool.h:48
virtual bool hasIntegratedBackend() const
Definition: Tool.h:55
virtual bool isLinkJob() const
Definition: Tool.h:58
virtual bool hasIntegratedCPP() const =0
virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA, const InputInfoList &Outputs, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const
Construct jobs to perform the action JA, writing to the Outputs and with Inputs, and add the jobs to ...
Definition: Tool.cpp:20
virtual void ConstructJob(Compilation &C, const JobAction &JA, const InputInfo &Output, const InputInfoList &Inputs, const llvm::opt::ArgList &TCArgs, const char *LinkingOutput) const =0
ConstructJob - Construct jobs to perform the action JA, writing to Output and with Inputs,...
const char * getShortName() const
Definition: Tool.h:50
SmallVector< InputInfo, 4 > InputInfoList
Definition: Driver.h:50
The JSON file list parser is used to communicate input to InstallAPI.
Diagnostic wrappers for TextAPI types for error reporting.
Definition: Dominators.h:30