xref: /freebsd/contrib/llvm-project/clang/include/clang/Driver/Tool.h (revision 0eae32dcef82f6f06de6419a0d623d7def0cc8f6)
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 
29   typedef SmallVector<InputInfo, 4> InputInfoList;
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 
getName()48   const char *getName() const { return Name; }
49 
getShortName()50   const char *getShortName() const { return ShortName; }
51 
getToolChain()52   const ToolChain &getToolChain() const { return TheToolChain; }
53 
hasIntegratedAssembler()54   virtual bool hasIntegratedAssembler() const { return false; }
hasIntegratedBackend()55   virtual bool hasIntegratedBackend() const { return true; }
canEmitIR()56   virtual bool canEmitIR() const { return false; }
57   virtual bool hasIntegratedCPP() const = 0;
isLinkJob()58   virtual bool isLinkJob() const { return false; }
isDsymutilJob()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.
hasGoodDiagnostics()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
98