clang 8.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"
14 #include "clang/Basic/DebugInfoOptions.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 /// 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 RenderTargetOptions(const llvm::Triple &EffectiveTriple,
46 const llvm::opt::ArgList &Args, bool KernelOrKext,
47 llvm::opt::ArgStringList &CmdArgs) const;
48
49 void AddAArch64TargetArgs(const llvm::opt::ArgList &Args,
50 llvm::opt::ArgStringList &CmdArgs) const;
51 void AddARMTargetArgs(const llvm::Triple &Triple,
52 const llvm::opt::ArgList &Args,
53 llvm::opt::ArgStringList &CmdArgs,
54 bool KernelOrKext) const;
55 void AddARM64TargetArgs(const llvm::opt::ArgList &Args,
56 llvm::opt::ArgStringList &CmdArgs) const;
57 void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
58 llvm::opt::ArgStringList &CmdArgs) const;
59 void AddPPCTargetArgs(const llvm::opt::ArgList &Args,
60 llvm::opt::ArgStringList &CmdArgs) const;
61 void AddR600TargetArgs(const llvm::opt::ArgList &Args,
62 llvm::opt::ArgStringList &CmdArgs) const;
63 void AddRISCVTargetArgs(const llvm::opt::ArgList &Args,
64 llvm::opt::ArgStringList &CmdArgs) const;
65 void AddSparcTargetArgs(const llvm::opt::ArgList &Args,
66 llvm::opt::ArgStringList &CmdArgs) const;
67 void AddSystemZTargetArgs(const llvm::opt::ArgList &Args,
68 llvm::opt::ArgStringList &CmdArgs) const;
69 void AddX86TargetArgs(const llvm::opt::ArgList &Args,
70 llvm::opt::ArgStringList &CmdArgs) const;
71 void AddHexagonTargetArgs(const llvm::opt::ArgList &Args,
72 llvm::opt::ArgStringList &CmdArgs) const;
73 void AddLanaiTargetArgs(const llvm::opt::ArgList &Args,
74 llvm::opt::ArgStringList &CmdArgs) const;
75 void AddWebAssemblyTargetArgs(const llvm::opt::ArgList &Args,
76 llvm::opt::ArgStringList &CmdArgs) const;
77
78 enum RewriteKind { RK_None, RK_Fragile, RK_NonFragile };
79
80 ObjCRuntime AddObjCRuntimeArgs(const llvm::opt::ArgList &args,
81 llvm::opt::ArgStringList &cmdArgs,
82 RewriteKind rewrite) const;
83
84 void AddClangCLArgs(const llvm::opt::ArgList &Args, types::ID InputType,
85 llvm::opt::ArgStringList &CmdArgs,
86 codegenoptions::DebugInfoKind *DebugInfoKind,
87 bool *EmitCodeView) const;
88
89 visualstudio::Compiler *getCLFallback() const;
90
91 mutable std::unique_ptr<visualstudio::Compiler> CLFallback;
92
93 mutable std::unique_ptr<llvm::raw_fd_ostream> CompilationDatabase = nullptr;
94 void DumpCompilationDatabase(Compilation &C, StringRef Filename,
95 StringRef Target,
96 const InputInfo &Output, const InputInfo &Input,
97 const llvm::opt::ArgList &Args) const;
98
99 public:
100 Clang(const ToolChain &TC);
101 ~Clang() override;
102
103 bool hasGoodDiagnostics() const override { return true; }
104 bool hasIntegratedAssembler() const override { return true; }
105 bool hasIntegratedCPP() const override { return true; }
106 bool canEmitIR() const override { return true; }
107
108 void ConstructJob(Compilation &C, const JobAction &JA,
109 const InputInfo &Output, const InputInfoList &Inputs,
110 const llvm::opt::ArgList &TCArgs,
111 const char *LinkingOutput) const override;
112 };
113
114 /// Clang integrated assembler tool.
115 class LLVM_LIBRARY_VISIBILITY ClangAs : public Tool {
116 public:
117 ClangAs(const ToolChain &TC)
118 : Tool("clang::as", "clang integrated assembler", TC, RF_Full) {}
119 void AddMIPSTargetArgs(const llvm::opt::ArgList &Args,
120 llvm::opt::ArgStringList &CmdArgs) const;
121 void AddX86TargetArgs(const llvm::opt::ArgList &Args,
122 llvm::opt::ArgStringList &CmdArgs) const;
123 bool hasGoodDiagnostics() const override { return true; }
124 bool hasIntegratedAssembler() const override { return false; }
125 bool hasIntegratedCPP() const override { return false; }
126
127 void ConstructJob(Compilation &C, const JobAction &JA,
128 const InputInfo &Output, const InputInfoList &Inputs,
129 const llvm::opt::ArgList &TCArgs,
130 const char *LinkingOutput) const override;
131 };
132
133 /// Offload bundler tool.
134 class LLVM_LIBRARY_VISIBILITY OffloadBundler final : public Tool {
135 public:
136 OffloadBundler(const ToolChain &TC)
137 : Tool("offload bundler", "clang-offload-bundler", TC) {}
138
139 bool hasIntegratedCPP() const override { return false; }
140 void ConstructJob(Compilation &C, const JobAction &JA,
141 const InputInfo &Output, const InputInfoList &Inputs,
142 const llvm::opt::ArgList &TCArgs,
143 const char *LinkingOutput) const override;
144 void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
145 const InputInfoList &Outputs,
146 const InputInfoList &Inputs,
147 const llvm::opt::ArgList &TCArgs,
148 const char *LinkingOutput) const override;
149 };
150 } // end namespace tools
151
152 } // end namespace driver
153 } // end namespace clang
154
155 #endif // LLVM_CLANG_LIB_DRIVER_TOOLCHAINS_CLANG_H
clang::codegenoptions::DebugInfoKind
DebugInfoKind
Definition: DebugInfoOptions.h:21
Types.h
Tool.h
clang::driver::types::ID
ID
Definition: Types.h:22
clang::driver::tools::ClangAs
Clang integrated assembler tool.
Definition: Clang.h:115
clang::MultiVersionKind::Target
clang::driver::tools::visualstudio::Compiler
Definition: MSVC.h:40
clang::driver::JobAction
Definition: Action.h:374
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:23
clang::driver::tools::Clang::hasGoodDiagnostics
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Clang.h:103
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:58
clang::driver::tools::ClangAs::ClangAs
ClangAs(const ToolChain &TC)
Definition: Clang.h:117
clang::driver::tools::Clang::hasIntegratedAssembler
bool hasIntegratedAssembler() const override
Definition: Clang.h:104
Driver.h
Filename
StringRef Filename
Definition: Format.cpp:1629
clang::driver::tools::ClangAs::hasIntegratedAssembler
bool hasIntegratedAssembler() const override
Definition: Clang.h:124
clang::driver::tools::OffloadBundler::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: Clang.h:139
clang::driver::tools::OffloadBundler::OffloadBundler
OffloadBundler(const ToolChain &TC)
Definition: Clang.h:136
clang::driver::tools::OffloadBundler
Offload bundler tool.
Definition: Clang.h:134
clang::driver::tools::Clang::canEmitIR
bool canEmitIR() const override
Definition: Clang.h:106
clang::driver::tools::Clang::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: Clang.h:105
llvm::SmallVector
Definition: LLVM.h:36
clang
Dataflow Directional Tag Classes.
Definition: CFGReachabilityAnalysis.h:22
clang::driver::tools::Clang
Clang compiler tool.
Definition: Clang.h:29
DebugInfoOptions.h
clang::ObjCRuntime
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:34
clang::driver::Compilation
Compilation - A set of tasks to perform for a single driver invocation.
Definition: Compilation.h:46
MSVC.h
clang::driver::tools::ClangAs::hasGoodDiagnostics
bool hasGoodDiagnostics() const override
Does this tool have "good" standardized diagnostics, or should the driver add an additional "command ...
Definition: Clang.h:123
clang::driver::tools::ClangAs::hasIntegratedCPP
bool hasIntegratedCPP() const override
Definition: Clang.h:125
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:89