clang  14.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 
14 namespace llvm {
15 namespace opt {
16  class ArgList;
17 }
18 }
19 
20 namespace clang {
21 namespace driver {
22 
23  class Compilation;
24  class InputInfo;
25  class Job;
26  class JobAction;
27  class ToolChain;
28 
30 
31 /// Tool - Information on a specific compilation tool.
32 class 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 
42 public:
43  Tool(const char *Name, const char *ShortName, const ToolChain &TC);
44 
45 public:
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 canEmitIR() const { return false; }
56  virtual bool hasIntegratedCPP() const = 0;
57  virtual bool isLinkJob() const { return false; }
58  virtual bool isDsymutilJob() const { return false; }
59 
60  /// Does this tool have "good" standardized diagnostics, or should the
61  /// driver add an additional "command failed" diagnostic on failures.
62  virtual bool hasGoodDiagnostics() const { return false; }
63 
64  /// ConstructJob - Construct jobs to perform the action \p JA,
65  /// writing to \p Output and with \p Inputs, and add the jobs to
66  /// \p C.
67  ///
68  /// \param TCArgs - The argument list for this toolchain, with any
69  /// tool chain specific translations applied.
70  /// \param LinkingOutput - If this output will eventually feed the
71  /// linker, then this is the final output name of the linked image.
72  virtual void ConstructJob(Compilation &C, const JobAction &JA,
73  const InputInfo &Output,
74  const InputInfoList &Inputs,
75  const llvm::opt::ArgList &TCArgs,
76  const char *LinkingOutput) const = 0;
77  /// Construct jobs to perform the action \p JA, writing to the \p Outputs and
78  /// with \p Inputs, and add the jobs to \p C. The default implementation
79  /// assumes a single output and is expected to be overloaded for the tools
80  /// that support multiple inputs.
81  ///
82  /// \param TCArgs The argument list for this toolchain, with any
83  /// tool chain specific translations applied.
84  /// \param LinkingOutput If this output will eventually feed the
85  /// linker, then this is the final output name of the linked image.
86  virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
87  const InputInfoList &Outputs,
88  const InputInfoList &Inputs,
89  const llvm::opt::ArgList &TCArgs,
90  const char *LinkingOutput) const;
91 };
92 
93 } // end namespace driver
94 } // end namespace clang
95 
96 #endif
llvm
Definition: Dominators.h:30
llvm::SmallVector
Definition: LLVM.h:38
clang::driver::Tool::ConstructJobMultipleOutputs
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
clang::driver::Tool::~Tool
virtual ~Tool()
Definition: Tool.cpp:17
clang::driver::InputInfoList
SmallVector< InputInfo, 4 > InputInfoList
Definition: Tool.h:27
clang::driver::Tool::isLinkJob
virtual bool isLinkJob() const
Definition: Tool.h:57
clang::driver::Tool::ConstructJob
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,...
clang::driver::Tool::isDsymutilJob
virtual bool isDsymutilJob() const
Definition: Tool.h:58
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::Tool::canEmitIR
virtual bool canEmitIR() const
Definition: Tool.h:55
clang::driver::Tool::hasIntegratedCPP
virtual bool hasIntegratedCPP() const =0
clang::driver::Tool::getShortName
const char * getShortName() const
Definition: Tool.h:50
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::Tool::Tool
Tool(const char *Name, const char *ShortName, const ToolChain &TC)
Definition: Tool.cpp:14
LLVM.h
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:45
clang::driver::Tool::hasIntegratedAssembler
virtual bool hasIntegratedAssembler() const
Definition: Tool.h:54
clang::driver::Tool::getToolChain
const ToolChain & getToolChain() const
Definition: Tool.h:52
clang
Definition: CalledOnceCheck.h:17
clang::driver::Tool::getName
const char * getName() const
Definition: Tool.h:48
clang::driver::Tool::hasGoodDiagnostics
virtual bool hasGoodDiagnostics() const
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Tool.h:62
clang::driver::JobAction
Definition: Action.h:380