clang  5.0.0
Clang.h
Go to the documentation of this file.
1 //===--- Clang.h - Clang Tool and ToolChain Implementations ====-*- C++ -*-===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 #ifndef LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Clang_H
11 #define LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_Clang_H
12 
13 #include "MSVC.h"
15 #include "clang/Driver/Driver.h"
16 #include "clang/Driver/Tool.h"
17 #include "clang/Driver/Types.h"
18 #include "llvm/ADT/Triple.h"
19 #include "llvm/Option/Option.h"
20 #include "llvm/Support/raw_ostream.h"
21 
22 namespace clang {
23 class ObjCRuntime;
24 namespace driver {
25 
26 namespace tools {
27 
28 /// \brief Clang compiler tool.
29 class LLVM_LIBRARY_VISIBILITY Clang : public Tool {
30 public:
31  static const char *getBaseInputName(const llvm::opt::ArgList &Args,
32  const InputInfo &Input);
33  static const char *getBaseInputStem(const llvm::opt::ArgList &Args,
34  const InputInfoList &Inputs);
35  static const char *getDependencyFileName(const llvm::opt::ArgList &Args,
36  const InputInfoList &Inputs);
37 
38 private:
39  void AddPreprocessingOptions(Compilation &C, const JobAction &JA,
40  const Driver &D, const llvm::opt::ArgList &Args,
41  llvm::opt::ArgStringList &CmdArgs,
42  const InputInfo &Output,
43  const InputInfoList &Inputs) const;
44 
45  void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
46  llvm::opt::ArgStringList &CmdArgs) const;
47  void AddARMTargetArgs(const llvm::Triple &Triple,
48  const llvm::opt::ArgList &Args,
49  llvm::opt::ArgStringList &CmdArgs,
50  bool KernelOrKext) const;
51  void AddARM64TargetArgs(const llvm::opt::ArgList &Args,
52  llvm::opt::ArgStringList &CmdArgs) const;
53  void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
54  llvm::opt::ArgStringList &CmdArgs) const;
55  void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
56  llvm::opt::ArgStringList &CmdArgs) const;
57  void AddR600TargetArgs(const llvm::opt::ArgList &Args,
58  llvm::opt::ArgStringList &CmdArgs) const;
59  void AddSparcTargetArgs(const llvm::opt::ArgList &Args,
60  llvm::opt::ArgStringList &CmdArgs) const;
61  void AddSystemZTargetArgs(const llvm::opt::ArgList &Args,
62  llvm::opt::ArgStringList &CmdArgs) const;
63  void AddX86TargetArgs(const llvm::opt::ArgList &Args,
64  llvm::opt::ArgStringList &CmdArgs) const;
65  void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
66  llvm::opt::ArgStringList &CmdArgs) const;
67  void AddLanaiTargetArgs(const llvm::opt::ArgList &Args,
68  llvm::opt::ArgStringList &CmdArgs) const;
69  void AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args,
70  llvm::opt::ArgStringList &CmdArgs) const;
71 
72  enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
73 
74  ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args,
75  llvm::opt::ArgStringList &cmdArgs,
76  RewriteKind rewrite) const;
77 
78  void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType,
79  llvm::opt::ArgStringList &CmdArgs,
81  bool *EmitCodeView) const;
82 
83  visualstudio::Compiler *getCLFallback() const;
84 
85  mutable std::unique_ptr<visualstudio::Compiler> CLFallback;
86 
87  mutable std::unique_ptr<llvm::raw_fd_ostream> CompilationDatabase = nullptr;
88  void DumpCompilationDatabase(Compilation &C, StringRef Filename,
89  StringRef Target,
90  const InputInfo &Output, const InputInfo &Input,
91  const llvm::opt::ArgList &Args) const;
92 
93 public:
94  Clang(const ToolChain &TC);
95  ~Clang() override;
96 
97  bool hasGoodDiagnostics() const override { return true; }
98  bool hasIntegratedAssembler() const override { return true; }
99  bool hasIntegratedCPP() const override { return true; }
100  bool canEmitIR() const override { return true; }
101 
102  void ConstructJob(Compilation &C, const JobAction &JA,
103  const InputInfo &Output, const InputInfoList &Inputs,
104  const llvm::opt::ArgList &TCArgs,
105  const char *LinkingOutput) const override;
106 };
107 
108 /// \brief Clang integrated assembler tool.
109 class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
110 public:
111  ClangAs(const ToolChain &TC)
112  : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {}
113  void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
114  llvm::opt::ArgStringList &CmdArgs) const;
115  void AddX86TargetArgs(const llvm::opt::ArgList &Args,
116  llvm::opt::ArgStringList &CmdArgs) const;
117  bool hasGoodDiagnostics() const override { return true; }
118  bool hasIntegratedAssembler() const override { return false; }
119  bool hasIntegratedCPP() const override { return false; }
120 
121  void ConstructJob(Compilation &C, const JobAction &JA,
122  const InputInfo &Output, const InputInfoList &Inputs,
123  const llvm::opt::ArgList &TCArgs,
124  const char *LinkingOutput) const override;
125 };
126 
127 /// Offload bundler tool.
128 class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool {
129 public:
131  : Tool("offload bundler", "clang-offload-bundler", TC) {}
132 
133  bool hasIntegratedCPP() const override { return false; }
134  void ConstructJob(Compilation &C, const JobAction &JA,
135  const InputInfo &Output, const InputInfoList &Inputs,
136  const llvm::opt::ArgList &TCArgs,
137  const char *LinkingOutput) const override;
138  void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
139  const InputInfoList &Outputs,
140  const InputInfoList &Inputs,
141  const llvm::opt::ArgList &TCArgs,
142  const char *LinkingOutput) const override;
143 };
144 } // end namespace tools
145 
146 } // end namespace driver
147 } // end namespace clang
148 
149 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_CLANG_H
Clang integrated assembler tool.
Definition: Clang.h:109
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Clang.h:97
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:65
ClangAs(const ToolChain &TC)
Definition: Clang.h:111
bool hasIntegratedAssembler() const override
Definition: Clang.h:98
StringRef Filename
Definition: Format.cpp:1301
bool hasIntegratedAssembler() const override
Definition: Clang.h:118
bool hasIntegratedCPP() const override
Definition: Clang.h:133
OffloadBundler(const ToolChain &TC)
Definition: Clang.h:130
Offload bundler tool.
Definition: Clang.h:128
bool canEmitIR() const override
Definition: Clang.h:100
bool hasIntegratedCPP() const override
Definition: Clang.h:99
Clang compiler tool.
Definition: Clang.h:29
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:25
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:34
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Clang.h:117
const StringRef Input
bool hasIntegratedCPP() const override
Definition: Clang.h:119
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:50