clang  16.0.0git
ToolChain.cpp
Go to the documentation of this file.
1 //===- ToolChain.cpp - Collections of tools for one platform --------------===//
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 
10 #include "ToolChains/Arch/ARM.h"
11 #include "ToolChains/Clang.h"
12 #include "ToolChains/Flang.h"
15 #include "clang/Basic/Sanitizers.h"
16 #include "clang/Config/config.h"
17 #include "clang/Driver/Action.h"
18 #include "clang/Driver/Driver.h"
20 #include "clang/Driver/InputInfo.h"
21 #include "clang/Driver/Job.h"
22 #include "clang/Driver/Options.h"
24 #include "clang/Driver/XRayArgs.h"
25 #include "llvm/ADT/STLExtras.h"
26 #include "llvm/ADT/SmallString.h"
27 #include "llvm/ADT/StringRef.h"
28 #include "llvm/ADT/Triple.h"
29 #include "llvm/ADT/Twine.h"
30 #include "llvm/Config/llvm-config.h"
31 #include "llvm/MC/MCTargetOptions.h"
32 #include "llvm/MC/TargetRegistry.h"
33 #include "llvm/Option/Arg.h"
34 #include "llvm/Option/ArgList.h"
35 #include "llvm/Option/OptTable.h"
36 #include "llvm/Option/Option.h"
37 #include "llvm/Support/ErrorHandling.h"
38 #include "llvm/Support/FileSystem.h"
39 #include "llvm/Support/Path.h"
40 #include "llvm/Support/TargetParser.h"
41 #include "llvm/Support/VersionTuple.h"
42 #include "llvm/Support/VirtualFileSystem.h"
43 #include <cassert>
44 #include <cstddef>
45 #include <cstring>
46 #include <string>
47 
48 using namespace clang;
49 using namespace driver;
50 using namespace tools;
51 using namespace llvm;
52 using namespace llvm::opt;
53 
54 static llvm::opt::Arg *GetRTTIArgument(const ArgList &Args) {
55  return Args.getLastArg(options::OPT_mkernel, options::OPT_fapple_kext,
56  options::OPT_fno_rtti, options::OPT_frtti);
57 }
58 
59 static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args,
60  const llvm::Triple &Triple,
61  const Arg *CachedRTTIArg) {
62  // Explicit rtti/no-rtti args
63  if (CachedRTTIArg) {
64  if (CachedRTTIArg->getOption().matches(options::OPT_frtti))
65  return ToolChain::RM_Enabled;
66  else
68  }
69 
70  // -frtti is default, except for the PS4/PS5 and DriverKit.
71  bool NoRTTI = Triple.isPS() || Triple.isDriverKit();
73 }
74 
75 ToolChain::ToolChain(const Driver &D, const llvm::Triple &T,
76  const ArgList &Args)
77  : D(D), Triple(T), Args(Args), CachedRTTIArg(GetRTTIArgument(Args)),
78  CachedRTTIMode(CalculateRTTIMode(Args, Triple, CachedRTTIArg)) {
79  auto addIfExists = [this](path_list &List, const std::string &Path) {
80  if (getVFS().exists(Path))
81  List.push_back(Path);
82  };
83 
84  for (const auto &Path : getRuntimePaths())
85  addIfExists(getLibraryPaths(), Path);
86  for (const auto &Path : getStdlibPaths())
87  addIfExists(getFilePaths(), Path);
88  addIfExists(getFilePaths(), getArchSpecificLibPath());
89 }
90 
91 void ToolChain::setTripleEnvironment(llvm::Triple::EnvironmentType Env) {
92  Triple.setEnvironment(Env);
93  if (EffectiveTriple != llvm::Triple())
94  EffectiveTriple.setEnvironment(Env);
95 }
96 
97 ToolChain::~ToolChain() = default;
98 
99 llvm::vfs::FileSystem &ToolChain::getVFS() const {
100  return getDriver().getVFS();
101 }
102 
104  return Args.hasFlag(options::OPT_fintegrated_as,
105  options::OPT_fno_integrated_as,
107 }
108 
110  assert(
113  "(Non-)integrated backend set incorrectly!");
114 
115  bool IBackend = Args.hasFlag(options::OPT_fintegrated_objemitter,
116  options::OPT_fno_integrated_objemitter,
118 
119  // Diagnose when integrated-objemitter options are not supported by this
120  // toolchain.
121  unsigned DiagID;
122  if ((IBackend && !IsIntegratedBackendSupported()) ||
123  (!IBackend && !IsNonIntegratedBackendSupported()))
124  DiagID = clang::diag::err_drv_unsupported_opt_for_target;
125  else
126  DiagID = clang::diag::warn_drv_unsupported_opt_for_target;
127  Arg *A = Args.getLastArg(options::OPT_fno_integrated_objemitter);
129  D.Diag(DiagID) << A->getAsString(Args) << Triple.getTriple();
130  A = Args.getLastArg(options::OPT_fintegrated_objemitter);
131  if (A && !IsIntegratedBackendSupported())
132  D.Diag(DiagID) << A->getAsString(Args) << Triple.getTriple();
133 
134  return IBackend;
135 }
136 
138  return ENABLE_X86_RELAX_RELOCATIONS;
139 }
140 
142  return PPC_LINUX_DEFAULT_IEEELONGDOUBLE && getTriple().isOSLinux();
143 }
144 
146 ToolChain::getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const {
147  SanitizerArgs SanArgs(*this, JobArgs, !SanitizerArgsChecked);
148  SanitizerArgsChecked = true;
149  return SanArgs;
150 }
151 
153  if (!XRayArguments.get())
154  XRayArguments.reset(new XRayArgs(*this, Args));
155  return *XRayArguments.get();
156 }
157 
158 namespace {
159 
160 struct DriverSuffix {
161  const char *Suffix;
162  const char *ModeFlag;
163 };
164 
165 } // namespace
166 
167 static const DriverSuffix *FindDriverSuffix(StringRef ProgName, size_t &Pos) {
168  // A list of known driver suffixes. Suffixes are compared against the
169  // program name in order. If there is a match, the frontend type is updated as
170  // necessary by applying the ModeFlag.
171  static const DriverSuffix DriverSuffixes[] = {
172  {"clang", nullptr},
173  {"clang++", "--driver-mode=g++"},
174  {"clang-c++", "--driver-mode=g++"},
175  {"clang-cc", nullptr},
176  {"clang-cpp", "--driver-mode=cpp"},
177  {"clang-g++", "--driver-mode=g++"},
178  {"clang-gcc", nullptr},
179  {"clang-cl", "--driver-mode=cl"},
180  {"cc", nullptr},
181  {"cpp", "--driver-mode=cpp"},
182  {"cl", "--driver-mode=cl"},
183  {"++", "--driver-mode=g++"},
184  {"flang", "--driver-mode=flang"},
185  {"clang-dxc", "--driver-mode=dxc"},
186  };
187 
188  for (const auto &DS : DriverSuffixes) {
189  StringRef Suffix(DS.Suffix);
190  if (ProgName.endswith(Suffix)) {
191  Pos = ProgName.size() - Suffix.size();
192  return &DS;
193  }
194  }
195  return nullptr;
196 }
197 
198 /// Normalize the program name from argv[0] by stripping the file extension if
199 /// present and lower-casing the string on Windows.
200 static std::string normalizeProgramName(llvm::StringRef Argv0) {
201  std::string ProgName = std::string(llvm::sys::path::filename(Argv0));
202  if (is_style_windows(llvm::sys::path::Style::native)) {
203  // Transform to lowercase for case insensitive file systems.
204  std::transform(ProgName.begin(), ProgName.end(), ProgName.begin(),
205  ::tolower);
206  }
207  return ProgName;
208 }
209 
210 static const DriverSuffix *parseDriverSuffix(StringRef ProgName, size_t &Pos) {
211  // Try to infer frontend type and default target from the program name by
212  // comparing it against DriverSuffixes in order.
213 
214  // If there is a match, the function tries to identify a target as prefix.
215  // E.g. "x86_64-linux-clang" as interpreted as suffix "clang" with target
216  // prefix "x86_64-linux". If such a target prefix is found, it may be
217  // added via -target as implicit first argument.
218  const DriverSuffix *DS = FindDriverSuffix(ProgName, Pos);
219 
220  if (!DS && ProgName.endswith(".exe")) {
221  // Try again after stripping the executable suffix:
222  // clang++.exe -> clang++
223  ProgName = ProgName.drop_back(StringRef(".exe").size());
224  DS = FindDriverSuffix(ProgName, Pos);
225  }
226 
227  if (!DS) {
228  // Try again after stripping any trailing version number:
229  // clang++3.5 -> clang++
230  ProgName = ProgName.rtrim("0123456789.");
231  DS = FindDriverSuffix(ProgName, Pos);
232  }
233 
234  if (!DS) {
235  // Try again after stripping trailing -component.
236  // clang++-tot -> clang++
237  ProgName = ProgName.slice(0, ProgName.rfind('-'));
238  DS = FindDriverSuffix(ProgName, Pos);
239  }
240  return DS;
241 }
242 
245  std::string ProgName = normalizeProgramName(PN);
246  size_t SuffixPos;
247  const DriverSuffix *DS = parseDriverSuffix(ProgName, SuffixPos);
248  if (!DS)
249  return {};
250  size_t SuffixEnd = SuffixPos + strlen(DS->Suffix);
251 
252  size_t LastComponent = ProgName.rfind('-', SuffixPos);
253  if (LastComponent == std::string::npos)
254  return ParsedClangName(ProgName.substr(0, SuffixEnd), DS->ModeFlag);
255  std::string ModeSuffix = ProgName.substr(LastComponent + 1,
256  SuffixEnd - LastComponent - 1);
257 
258  // Infer target from the prefix.
259  StringRef Prefix(ProgName);
260  Prefix = Prefix.slice(0, LastComponent);
261  std::string IgnoredError;
262  bool IsRegistered =
263  llvm::TargetRegistry::lookupTarget(std::string(Prefix), IgnoredError);
264  return ParsedClangName{std::string(Prefix), ModeSuffix, DS->ModeFlag,
265  IsRegistered};
266 }
267 
269  // In universal driver terms, the arch name accepted by -arch isn't exactly
270  // the same as the ones that appear in the triple. Roughly speaking, this is
271  // an inverse of the darwin::getArchTypeForDarwinArchName() function.
272  switch (Triple.getArch()) {
273  case llvm::Triple::aarch64: {
274  if (getTriple().isArm64e())
275  return "arm64e";
276  return "arm64";
277  }
278  case llvm::Triple::aarch64_32:
279  return "arm64_32";
280  case llvm::Triple::ppc:
281  return "ppc";
282  case llvm::Triple::ppcle:
283  return "ppcle";
284  case llvm::Triple::ppc64:
285  return "ppc64";
286  case llvm::Triple::ppc64le:
287  return "ppc64le";
288  default:
289  return Triple.getArchName();
290  }
291 }
292 
294  return Input.getFilename();
295 }
296 
298 ToolChain::getDefaultUnwindTableLevel(const ArgList &Args) const {
299  return UnwindTableLevel::None;
300 }
301 
302 Tool *ToolChain::getClang() const {
303  if (!Clang)
304  Clang.reset(new tools::Clang(*this, useIntegratedBackend()));
305  return Clang.get();
306 }
307 
308 Tool *ToolChain::getFlang() const {
309  if (!Flang)
310  Flang.reset(new tools::Flang(*this));
311  return Flang.get();
312 }
313 
315  return new tools::ClangAs(*this);
316 }
317 
319  llvm_unreachable("Linking is not supported by this toolchain");
320 }
321 
323  llvm_unreachable("Creating static lib is not supported by this toolchain");
324 }
325 
326 Tool *ToolChain::getAssemble() const {
327  if (!Assemble)
328  Assemble.reset(buildAssembler());
329  return Assemble.get();
330 }
331 
332 Tool *ToolChain::getClangAs() const {
333  if (!Assemble)
334  Assemble.reset(new tools::ClangAs(*this));
335  return Assemble.get();
336 }
337 
338 Tool *ToolChain::getLink() const {
339  if (!Link)
340  Link.reset(buildLinker());
341  return Link.get();
342 }
343 
344 Tool *ToolChain::getStaticLibTool() const {
345  if (!StaticLibTool)
346  StaticLibTool.reset(buildStaticLibTool());
347  return StaticLibTool.get();
348 }
349 
350 Tool *ToolChain::getIfsMerge() const {
351  if (!IfsMerge)
352  IfsMerge.reset(new tools::ifstool::Merger(*this));
353  return IfsMerge.get();
354 }
355 
356 Tool *ToolChain::getOffloadBundler() const {
357  if (!OffloadBundler)
358  OffloadBundler.reset(new tools::OffloadBundler(*this));
359  return OffloadBundler.get();
360 }
361 
362 Tool *ToolChain::getOffloadPackager() const {
363  if (!OffloadPackager)
364  OffloadPackager.reset(new tools::OffloadPackager(*this));
365  return OffloadPackager.get();
366 }
367 
368 Tool *ToolChain::getLinkerWrapper() const {
369  if (!LinkerWrapper)
370  LinkerWrapper.reset(new tools::LinkerWrapper(*this, getLink()));
371  return LinkerWrapper.get();
372 }
373 
375  switch (AC) {
377  return getAssemble();
378 
380  return getIfsMerge();
381 
383  return getLink();
384 
386  return getStaticLibTool();
387 
388  case Action::InputClass:
394  llvm_unreachable("Invalid tool kind.");
395 
404  return getClang();
405 
408  return getOffloadBundler();
409 
411  return getOffloadPackager();
413  return getLinkerWrapper();
414  }
415 
416  llvm_unreachable("Invalid tool kind.");
417 }
418 
419 static StringRef getArchNameForCompilerRTLib(const ToolChain &TC,
420  const ArgList &Args) {
421  const llvm::Triple &Triple = TC.getTriple();
422  bool IsWindows = Triple.isOSWindows();
423 
424  if (TC.isBareMetal())
425  return Triple.getArchName();
426 
427  if (TC.getArch() == llvm::Triple::arm || TC.getArch() == llvm::Triple::armeb)
428  return (arm::getARMFloatABI(TC, Args) == arm::FloatABI::Hard && !IsWindows)
429  ? "armhf"
430  : "arm";
431 
432  // For historic reasons, Android library is using i686 instead of i386.
433  if (TC.getArch() == llvm::Triple::x86 && Triple.isAndroid())
434  return "i686";
435 
436  if (TC.getArch() == llvm::Triple::x86_64 && Triple.isX32())
437  return "x32";
438 
439  return llvm::Triple::getArchTypeName(TC.getArch());
440 }
441 
442 StringRef ToolChain::getOSLibName() const {
443  if (Triple.isOSDarwin())
444  return "darwin";
445 
446  switch (Triple.getOS()) {
447  case llvm::Triple::FreeBSD:
448  return "freebsd";
449  case llvm::Triple::NetBSD:
450  return "netbsd";
451  case llvm::Triple::OpenBSD:
452  return "openbsd";
453  case llvm::Triple::Solaris:
454  return "sunos";
455  case llvm::Triple::AIX:
456  return "aix";
457  default:
458  return getOS();
459  }
460 }
461 
463  SmallString<128> Path(getDriver().ResourceDir);
464  if (isBareMetal()) {
465  llvm::sys::path::append(Path, "lib", getOSLibName());
466  Path += SelectedMultilib.gccSuffix();
467  } else if (Triple.isOSUnknown()) {
468  llvm::sys::path::append(Path, "lib");
469  } else {
470  llvm::sys::path::append(Path, "lib", getOSLibName());
471  }
472  return std::string(Path.str());
473 }
474 
476  StringRef Component,
477  FileType Type) const {
478  std::string CRTAbsolutePath = getCompilerRT(Args, Component, Type);
479  return llvm::sys::path::filename(CRTAbsolutePath).str();
480 }
481 
482 std::string ToolChain::buildCompilerRTBasename(const llvm::opt::ArgList &Args,
483  StringRef Component,
484  FileType Type,
485  bool AddArch) const {
486  const llvm::Triple &TT = getTriple();
487  bool IsITANMSVCWindows =
488  TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment();
489 
490  const char *Prefix =
491  IsITANMSVCWindows || Type == ToolChain::FT_Object ? "" : "lib";
492  const char *Suffix;
493  switch (Type) {
495  Suffix = IsITANMSVCWindows ? ".obj" : ".o";
496  break;
498  Suffix = IsITANMSVCWindows ? ".lib" : ".a";
499  break;
501  Suffix = TT.isOSWindows()
502  ? (TT.isWindowsGNUEnvironment() ? ".dll.a" : ".lib")
503  : ".so";
504  break;
505  }
506 
507  std::string ArchAndEnv;
508  if (AddArch) {
509  StringRef Arch = getArchNameForCompilerRTLib(*this, Args);
510  const char *Env = TT.isAndroid() ? "-android" : "";
511  ArchAndEnv = ("-" + Arch + Env).str();
512  }
513  return (Prefix + Twine("clang_rt.") + Component + ArchAndEnv + Suffix).str();
514 }
515 
516 std::string ToolChain::getCompilerRT(const ArgList &Args, StringRef Component,
517  FileType Type) const {
518  // Check for runtime files in the new layout without the architecture first.
519  std::string CRTBasename =
520  buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/false);
521  for (const auto &LibPath : getLibraryPaths()) {
522  SmallString<128> P(LibPath);
523  llvm::sys::path::append(P, CRTBasename);
524  if (getVFS().exists(P))
525  return std::string(P.str());
526  }
527 
528  // Fall back to the old expected compiler-rt name if the new one does not
529  // exist.
530  CRTBasename =
531  buildCompilerRTBasename(Args, Component, Type, /*AddArch=*/true);
533  llvm::sys::path::append(Path, CRTBasename);
534  return std::string(Path.str());
535 }
536 
537 const char *ToolChain::getCompilerRTArgString(const llvm::opt::ArgList &Args,
538  StringRef Component,
539  FileType Type) const {
540  return Args.MakeArgString(getCompilerRT(Args, Component, Type));
541 }
542 
544  path_list Paths;
545  auto addPathForTriple = [this, &Paths](const llvm::Triple &Triple) {
547  llvm::sys::path::append(P, "lib", Triple.str());
548  Paths.push_back(std::string(P.str()));
549  };
550 
551  addPathForTriple(getTriple());
552 
553  // Android targets may include an API level at the end. We still want to fall
554  // back on a path without the API level.
555  if (getTriple().isAndroid() &&
556  getTriple().getEnvironmentName() != "android") {
557  llvm::Triple TripleWithoutLevel = getTriple();
558  TripleWithoutLevel.setEnvironmentName("android");
559  addPathForTriple(TripleWithoutLevel);
560  }
561 
562  return Paths;
563 }
564 
566  path_list Paths;
568  llvm::sys::path::append(P, "..", "lib", getTripleString());
569  Paths.push_back(std::string(P.str()));
570 
571  return Paths;
572 }
573 
575  SmallString<128> Path(getDriver().ResourceDir);
576  llvm::sys::path::append(Path, "lib", getOSLibName(),
577  llvm::Triple::getArchTypeName(getArch()));
578  return std::string(Path.str());
579 }
580 
581 bool ToolChain::needsProfileRT(const ArgList &Args) {
582  if (Args.hasArg(options::OPT_noprofilelib))
583  return false;
584 
585  return Args.hasArg(options::OPT_fprofile_generate) ||
586  Args.hasArg(options::OPT_fprofile_generate_EQ) ||
587  Args.hasArg(options::OPT_fcs_profile_generate) ||
588  Args.hasArg(options::OPT_fcs_profile_generate_EQ) ||
589  Args.hasArg(options::OPT_fprofile_instr_generate) ||
590  Args.hasArg(options::OPT_fprofile_instr_generate_EQ) ||
591  Args.hasArg(options::OPT_fcreate_profile) ||
592  Args.hasArg(options::OPT_forder_file_instrumentation);
593 }
594 
595 bool ToolChain::needsGCovInstrumentation(const llvm::opt::ArgList &Args) {
596  return Args.hasArg(options::OPT_coverage) ||
597  Args.hasFlag(options::OPT_fprofile_arcs, options::OPT_fno_profile_arcs,
598  false);
599 }
600 
602  if (D.IsFlangMode() && getDriver().ShouldUseFlangCompiler(JA)) return getFlang();
603  if (getDriver().ShouldUseClangCompiler(JA)) return getClang();
604  Action::ActionClass AC = JA.getKind();
606  return getClangAs();
607  return getTool(AC);
608 }
609 
610 std::string ToolChain::GetFilePath(const char *Name) const {
611  return D.GetFilePath(Name, *this);
612 }
613 
614 std::string ToolChain::GetProgramPath(const char *Name) const {
615  return D.GetProgramPath(Name, *this);
616 }
617 
618 std::string ToolChain::GetLinkerPath(bool *LinkerIsLLD) const {
619  if (LinkerIsLLD)
620  *LinkerIsLLD = false;
621 
622  // Get -fuse-ld= first to prevent -Wunused-command-line-argument. -fuse-ld= is
623  // considered as the linker flavor, e.g. "bfd", "gold", or "lld".
624  const Arg* A = Args.getLastArg(options::OPT_fuse_ld_EQ);
625  StringRef UseLinker = A ? A->getValue() : CLANG_DEFAULT_LINKER;
626 
627  // --ld-path= takes precedence over -fuse-ld= and specifies the executable
628  // name. -B, COMPILER_PATH and PATH and consulted if the value does not
629  // contain a path component separator.
630  // -fuse-ld=lld can be used with --ld-path= to inform clang that the binary
631  // that --ld-path= points to is lld.
632  if (const Arg *A = Args.getLastArg(options::OPT_ld_path_EQ)) {
633  std::string Path(A->getValue());
634  if (!Path.empty()) {
635  if (llvm::sys::path::parent_path(Path).empty())
636  Path = GetProgramPath(A->getValue());
637  if (llvm::sys::fs::can_execute(Path)) {
638  if (LinkerIsLLD)
639  *LinkerIsLLD = UseLinker == "lld";
640  return std::string(Path);
641  }
642  }
643  getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
645  }
646  // If we're passed -fuse-ld= with no argument, or with the argument ld,
647  // then use whatever the default system linker is.
648  if (UseLinker.empty() || UseLinker == "ld") {
649  const char *DefaultLinker = getDefaultLinker();
650  if (llvm::sys::path::is_absolute(DefaultLinker))
651  return std::string(DefaultLinker);
652  else
653  return GetProgramPath(DefaultLinker);
654  }
655 
656  // Extending -fuse-ld= to an absolute or relative path is unexpected. Checking
657  // for the linker flavor is brittle. In addition, prepending "ld." or "ld64."
658  // to a relative path is surprising. This is more complex due to priorities
659  // among -B, COMPILER_PATH and PATH. --ld-path= should be used instead.
660  if (UseLinker.contains('/'))
661  getDriver().Diag(diag::warn_drv_fuse_ld_path);
662 
663  if (llvm::sys::path::is_absolute(UseLinker)) {
664  // If we're passed what looks like an absolute path, don't attempt to
665  // second-guess that.
666  if (llvm::sys::fs::can_execute(UseLinker))
667  return std::string(UseLinker);
668  } else {
669  llvm::SmallString<8> LinkerName;
670  if (Triple.isOSDarwin())
671  LinkerName.append("ld64.");
672  else
673  LinkerName.append("ld.");
674  LinkerName.append(UseLinker);
675 
676  std::string LinkerPath(GetProgramPath(LinkerName.c_str()));
677  if (llvm::sys::fs::can_execute(LinkerPath)) {
678  if (LinkerIsLLD)
679  *LinkerIsLLD = UseLinker == "lld";
680  return LinkerPath;
681  }
682  }
683 
684  if (A)
685  getDriver().Diag(diag::err_drv_invalid_linker_name) << A->getAsString(Args);
686 
688 }
689 
691  // TODO: Add support for static lib archiving on Windows
692  if (Triple.isOSDarwin())
693  return GetProgramPath("libtool");
694  return GetProgramPath("llvm-ar");
695 }
696 
699 
700  // Flang always runs the preprocessor and has no notion of "preprocessed
701  // fortran". Here, TY_PP_Fortran is coerced to TY_Fortran to avoid treating
702  // them differently.
703  if (D.IsFlangMode() && id == types::TY_PP_Fortran)
704  id = types::TY_Fortran;
705 
706  return id;
707 }
708 
710  return false;
711 }
712 
714  llvm::Triple HostTriple(LLVM_HOST_TRIPLE);
715  switch (HostTriple.getArch()) {
716  // The A32/T32/T16 instruction sets are not separate architectures in this
717  // context.
718  case llvm::Triple::arm:
719  case llvm::Triple::armeb:
720  case llvm::Triple::thumb:
721  case llvm::Triple::thumbeb:
722  return getArch() != llvm::Triple::arm && getArch() != llvm::Triple::thumb &&
723  getArch() != llvm::Triple::armeb && getArch() != llvm::Triple::thumbeb;
724  default:
725  return HostTriple.getArch() != getArch();
726  }
727 }
728 
730  return ObjCRuntime(isNonFragile ? ObjCRuntime::GNUstep : ObjCRuntime::GCC,
731  VersionTuple());
732 }
733 
734 llvm::ExceptionHandling
735 ToolChain::GetExceptionModel(const llvm::opt::ArgList &Args) const {
737 }
738 
739 bool ToolChain::isThreadModelSupported(const StringRef Model) const {
740  if (Model == "single") {
741  // FIXME: 'single' is only supported on ARM and WebAssembly so far.
742  return Triple.getArch() == llvm::Triple::arm ||
743  Triple.getArch() == llvm::Triple::armeb ||
744  Triple.getArch() == llvm::Triple::thumb ||
745  Triple.getArch() == llvm::Triple::thumbeb || Triple.isWasm();
746  } else if (Model == "posix")
747  return true;
748 
749  return false;
750 }
751 
753  types::ID InputType) const {
754  switch (getTriple().getArch()) {
755  default:
756  return getTripleString();
757 
758  case llvm::Triple::x86_64: {
759  llvm::Triple Triple = getTriple();
760  if (!Triple.isOSBinFormatMachO())
761  return getTripleString();
762 
763  if (Arg *A = Args.getLastArg(options::OPT_march_EQ)) {
764  // x86_64h goes in the triple. Other -march options just use the
765  // vanilla triple we already have.
766  StringRef MArch = A->getValue();
767  if (MArch == "x86_64h")
768  Triple.setArchName(MArch);
769  }
770  return Triple.getTriple();
771  }
772  case llvm::Triple::aarch64: {
773  llvm::Triple Triple = getTriple();
774  if (!Triple.isOSBinFormatMachO())
775  return getTripleString();
776 
777  if (Triple.isArm64e())
778  return getTripleString();
779 
780  // FIXME: older versions of ld64 expect the "arm64" component in the actual
781  // triple string and query it to determine whether an LTO file can be
782  // handled. Remove this when we don't care any more.
783  Triple.setArchName("arm64");
784  return Triple.getTriple();
785  }
786  case llvm::Triple::aarch64_32:
787  return getTripleString();
788  case llvm::Triple::arm:
789  case llvm::Triple::armeb:
790  case llvm::Triple::thumb:
791  case llvm::Triple::thumbeb: {
792  llvm::Triple Triple = getTriple();
793  tools::arm::setArchNameInTriple(getDriver(), Args, InputType, Triple);
795  return Triple.getTriple();
796  }
797  }
798 }
799 
801  types::ID InputType) const {
802  return ComputeLLVMTriple(Args, InputType);
803 }
804 
806  return D.SysRoot;
807 }
808 
809 void ToolChain::AddClangSystemIncludeArgs(const ArgList &DriverArgs,
810  ArgStringList &CC1Args) const {
811  // Each toolchain should provide the appropriate include flags.
812 }
813 
815  const ArgList &DriverArgs, ArgStringList &CC1Args,
816  Action::OffloadKind DeviceOffloadKind) const {}
817 
818 void ToolChain::addClangCC1ASTargetOptions(const ArgList &Args,
819  ArgStringList &CC1ASArgs) const {}
820 
821 void ToolChain::addClangWarningOptions(ArgStringList &CC1Args) const {}
822 
823 void ToolChain::addProfileRTLibs(const llvm::opt::ArgList &Args,
824  llvm::opt::ArgStringList &CmdArgs) const {
825  if (!needsProfileRT(Args) && !needsGCovInstrumentation(Args))
826  return;
827 
828  CmdArgs.push_back(getCompilerRTArgString(Args, "profile"));
829 }
830 
832  const ArgList &Args) const {
833  if (runtimeLibType)
834  return *runtimeLibType;
835 
836  const Arg* A = Args.getLastArg(options::OPT_rtlib_EQ);
837  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_RTLIB;
838 
839  // Only use "platform" in tests to override CLANG_DEFAULT_RTLIB!
840  if (LibName == "compiler-rt")
841  runtimeLibType = ToolChain::RLT_CompilerRT;
842  else if (LibName == "libgcc")
843  runtimeLibType = ToolChain::RLT_Libgcc;
844  else if (LibName == "platform")
845  runtimeLibType = GetDefaultRuntimeLibType();
846  else {
847  if (A)
848  getDriver().Diag(diag::err_drv_invalid_rtlib_name)
849  << A->getAsString(Args);
850 
851  runtimeLibType = GetDefaultRuntimeLibType();
852  }
853 
854  return *runtimeLibType;
855 }
856 
858  const ArgList &Args) const {
859  if (unwindLibType)
860  return *unwindLibType;
861 
862  const Arg *A = Args.getLastArg(options::OPT_unwindlib_EQ);
863  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_UNWINDLIB;
864 
865  if (LibName == "none")
866  unwindLibType = ToolChain::UNW_None;
867  else if (LibName == "platform" || LibName == "") {
869  if (RtLibType == ToolChain::RLT_CompilerRT) {
870  if (getTriple().isAndroid() || getTriple().isOSAIX())
871  unwindLibType = ToolChain::UNW_CompilerRT;
872  else
873  unwindLibType = ToolChain::UNW_None;
874  } else if (RtLibType == ToolChain::RLT_Libgcc)
875  unwindLibType = ToolChain::UNW_Libgcc;
876  } else if (LibName == "libunwind") {
877  if (GetRuntimeLibType(Args) == RLT_Libgcc)
878  getDriver().Diag(diag::err_drv_incompatible_unwindlib);
879  unwindLibType = ToolChain::UNW_CompilerRT;
880  } else if (LibName == "libgcc")
881  unwindLibType = ToolChain::UNW_Libgcc;
882  else {
883  if (A)
884  getDriver().Diag(diag::err_drv_invalid_unwindlib_name)
885  << A->getAsString(Args);
886 
887  unwindLibType = GetDefaultUnwindLibType();
888  }
889 
890  return *unwindLibType;
891 }
892 
894  if (cxxStdlibType)
895  return *cxxStdlibType;
896 
897  const Arg *A = Args.getLastArg(options::OPT_stdlib_EQ);
898  StringRef LibName = A ? A->getValue() : CLANG_DEFAULT_CXX_STDLIB;
899 
900  // Only use "platform" in tests to override CLANG_DEFAULT_CXX_STDLIB!
901  if (LibName == "libc++")
902  cxxStdlibType = ToolChain::CST_Libcxx;
903  else if (LibName == "libstdc++")
904  cxxStdlibType = ToolChain::CST_Libstdcxx;
905  else if (LibName == "platform")
906  cxxStdlibType = GetDefaultCXXStdlibType();
907  else {
908  if (A)
909  getDriver().Diag(diag::err_drv_invalid_stdlib_name)
910  << A->getAsString(Args);
911 
912  cxxStdlibType = GetDefaultCXXStdlibType();
913  }
914 
915  return *cxxStdlibType;
916 }
917 
918 /// Utility function to add a system include directory to CC1 arguments.
919 /*static*/ void ToolChain::addSystemInclude(const ArgList &DriverArgs,
920  ArgStringList &CC1Args,
921  const Twine &Path) {
922  CC1Args.push_back("-internal-isystem");
923  CC1Args.push_back(DriverArgs.MakeArgString(Path));
924 }
925 
926 /// Utility function to add a system include directory with extern "C"
927 /// semantics to CC1 arguments.
928 ///
929 /// Note that this should be used rarely, and only for directories that
930 /// historically and for legacy reasons are treated as having implicit extern
931 /// "C" semantics. These semantics are *ignored* by and large today, but its
932 /// important to preserve the preprocessor changes resulting from the
933 /// classification.
934 /*static*/ void ToolChain::addExternCSystemInclude(const ArgList &DriverArgs,
935  ArgStringList &CC1Args,
936  const Twine &Path) {
937  CC1Args.push_back("-internal-externc-isystem");
938  CC1Args.push_back(DriverArgs.MakeArgString(Path));
939 }
940 
941 void ToolChain::addExternCSystemIncludeIfExists(const ArgList &DriverArgs,
942  ArgStringList &CC1Args,
943  const Twine &Path) {
944  if (llvm::sys::fs::exists(Path))
945  addExternCSystemInclude(DriverArgs, CC1Args, Path);
946 }
947 
948 /// Utility function to add a list of system include directories to CC1.
949 /*static*/ void ToolChain::addSystemIncludes(const ArgList &DriverArgs,
950  ArgStringList &CC1Args,
951  ArrayRef<StringRef> Paths) {
952  for (const auto &Path : Paths) {
953  CC1Args.push_back("-internal-isystem");
954  CC1Args.push_back(DriverArgs.MakeArgString(Path));
955  }
956 }
957 
958 /*static*/ std::string ToolChain::concat(StringRef Path, const Twine &A,
959  const Twine &B, const Twine &C,
960  const Twine &D) {
961  SmallString<128> Result(Path);
962  llvm::sys::path::append(Result, llvm::sys::path::Style::posix, A, B, C, D);
963  return std::string(Result);
964 }
965 
966 std::string ToolChain::detectLibcxxVersion(StringRef IncludePath) const {
967  std::error_code EC;
968  int MaxVersion = 0;
969  std::string MaxVersionString;
970  SmallString<128> Path(IncludePath);
971  llvm::sys::path::append(Path, "c++");
972  for (llvm::vfs::directory_iterator LI = getVFS().dir_begin(Path, EC), LE;
973  !EC && LI != LE; LI = LI.increment(EC)) {
974  StringRef VersionText = llvm::sys::path::filename(LI->path());
975  int Version;
976  if (VersionText[0] == 'v' &&
977  !VersionText.slice(1, StringRef::npos).getAsInteger(10, Version)) {
978  if (Version > MaxVersion) {
979  MaxVersion = Version;
980  MaxVersionString = std::string(VersionText);
981  }
982  }
983  }
984  if (!MaxVersion)
985  return "";
986  return MaxVersionString;
987 }
988 
989 void ToolChain::AddClangCXXStdlibIncludeArgs(const ArgList &DriverArgs,
990  ArgStringList &CC1Args) const {
991  // Header search paths should be handled by each of the subclasses.
992  // Historically, they have not been, and instead have been handled inside of
993  // the CC1-layer frontend. As the logic is hoisted out, this generic function
994  // will slowly stop being called.
995  //
996  // While it is being called, replicate a bit of a hack to propagate the
997  // '-stdlib=' flag down to CC1 so that it can in turn customize the C++
998  // header search paths with it. Once all systems are overriding this
999  // function, the CC1 flag and this line can be removed.
1000  DriverArgs.AddAllArgs(CC1Args, options::OPT_stdlib_EQ);
1001 }
1002 
1004  const llvm::opt::ArgList &DriverArgs,
1005  llvm::opt::ArgStringList &CC1Args) const {
1006  DriverArgs.ClaimAllArgs(options::OPT_stdlibxx_isystem);
1007  // This intentionally only looks at -nostdinc++, and not -nostdinc or
1008  // -nostdlibinc. The purpose of -stdlib++-isystem is to support toolchain
1009  // setups with non-standard search logic for the C++ headers, while still
1010  // allowing users of the toolchain to bring their own C++ headers. Such a
1011  // toolchain likely also has non-standard search logic for the C headers and
1012  // uses -nostdinc to suppress the default logic, but -stdlib++-isystem should
1013  // still work in that case and only be suppressed by an explicit -nostdinc++
1014  // in a project using the toolchain.
1015  if (!DriverArgs.hasArg(options::OPT_nostdincxx))
1016  for (const auto &P :
1017  DriverArgs.getAllArgValues(options::OPT_stdlibxx_isystem))
1018  addSystemInclude(DriverArgs, CC1Args, P);
1019 }
1020 
1021 bool ToolChain::ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const {
1022  return getDriver().CCCIsCXX() &&
1023  !Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs,
1024  options::OPT_nostdlibxx);
1025 }
1026 
1027 void ToolChain::AddCXXStdlibLibArgs(const ArgList &Args,
1028  ArgStringList &CmdArgs) const {
1029  assert(!Args.hasArg(options::OPT_nostdlibxx) &&
1030  "should not have called this");
1032 
1033  switch (Type) {
1034  case ToolChain::CST_Libcxx:
1035  CmdArgs.push_back("-lc++");
1036  if (Args.hasArg(options::OPT_fexperimental_library))
1037  CmdArgs.push_back("-lc++experimental");
1038  break;
1039 
1041  CmdArgs.push_back("-lstdc++");
1042  break;
1043  }
1044 }
1045 
1046 void ToolChain::AddFilePathLibArgs(const ArgList &Args,
1047  ArgStringList &CmdArgs) const {
1048  for (const auto &LibPath : getFilePaths())
1049  if(LibPath.length() > 0)
1050  CmdArgs.push_back(Args.MakeArgString(StringRef("-L") + LibPath));
1051 }
1052 
1053 void ToolChain::AddCCKextLibArgs(const ArgList &Args,
1054  ArgStringList &CmdArgs) const {
1055  CmdArgs.push_back("-lcc_kext");
1056 }
1057 
1058 bool ToolChain::isFastMathRuntimeAvailable(const ArgList &Args,
1059  std::string &Path) const {
1060  // Do not check for -fno-fast-math or -fno-unsafe-math when -Ofast passed
1061  // (to keep the linker options consistent with gcc and clang itself).
1062  if (!isOptimizationLevelFast(Args)) {
1063  // Check if -ffast-math or -funsafe-math.
1064  Arg *A =
1065  Args.getLastArg(options::OPT_ffast_math, options::OPT_fno_fast_math,
1066  options::OPT_funsafe_math_optimizations,
1067  options::OPT_fno_unsafe_math_optimizations);
1068 
1069  if (!A || A->getOption().getID() == options::OPT_fno_fast_math ||
1070  A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations)
1071  return false;
1072  }
1073  // If crtfastmath.o exists add it to the arguments.
1074  Path = GetFilePath("crtfastmath.o");
1075  return (Path != "crtfastmath.o"); // Not found.
1076 }
1077 
1079  ArgStringList &CmdArgs) const {
1080  std::string Path;
1081  if (isFastMathRuntimeAvailable(Args, Path)) {
1082  CmdArgs.push_back(Args.MakeArgString(Path));
1083  return true;
1084  }
1085 
1086  return false;
1087 }
1088 
1090  // Return sanitizers which don't require runtime support and are not
1091  // platform dependent.
1092 
1093  SanitizerMask Res =
1094  (SanitizerKind::Undefined & ~SanitizerKind::Vptr &
1095  ~SanitizerKind::Function) |
1096  (SanitizerKind::CFI & ~SanitizerKind::CFIICall) |
1097  SanitizerKind::CFICastStrict | SanitizerKind::FloatDivideByZero |
1098  SanitizerKind::KCFI | SanitizerKind::UnsignedIntegerOverflow |
1099  SanitizerKind::UnsignedShiftBase | SanitizerKind::ImplicitConversion |
1100  SanitizerKind::Nullability | SanitizerKind::LocalBounds;
1101  if (getTriple().getArch() == llvm::Triple::x86 ||
1102  getTriple().getArch() == llvm::Triple::x86_64 ||
1103  getTriple().getArch() == llvm::Triple::arm || getTriple().isWasm() ||
1104  getTriple().isAArch64() || getTriple().isRISCV())
1105  Res |= SanitizerKind::CFIICall;
1106  if (getTriple().getArch() == llvm::Triple::x86_64 ||
1107  getTriple().isAArch64(64) || getTriple().isRISCV())
1108  Res |= SanitizerKind::ShadowCallStack;
1109  if (getTriple().isAArch64(64))
1110  Res |= SanitizerKind::MemTag;
1111  return Res;
1112 }
1113 
1114 void ToolChain::AddCudaIncludeArgs(const ArgList &DriverArgs,
1115  ArgStringList &CC1Args) const {}
1116 
1117 void ToolChain::AddHIPIncludeArgs(const ArgList &DriverArgs,
1118  ArgStringList &CC1Args) const {}
1119 
1121 ToolChain::getDeviceLibs(const ArgList &DriverArgs) const {
1122  return {};
1123 }
1124 
1125 void ToolChain::AddIAMCUIncludeArgs(const ArgList &DriverArgs,
1126  ArgStringList &CC1Args) const {}
1127 
1128 static VersionTuple separateMSVCFullVersion(unsigned Version) {
1129  if (Version < 100)
1130  return VersionTuple(Version);
1131 
1132  if (Version < 10000)
1133  return VersionTuple(Version / 100, Version % 100);
1134 
1135  unsigned Build = 0, Factor = 1;
1136  for (; Version > 10000; Version = Version / 10, Factor = Factor * 10)
1137  Build = Build + (Version % 10) * Factor;
1138  return VersionTuple(Version / 100, Version % 100, Build);
1139 }
1140 
1141 VersionTuple
1143  const llvm::opt::ArgList &Args) const {
1144  const Arg *MSCVersion = Args.getLastArg(options::OPT_fmsc_version);
1145  const Arg *MSCompatibilityVersion =
1146  Args.getLastArg(options::OPT_fms_compatibility_version);
1147 
1148  if (MSCVersion && MSCompatibilityVersion) {
1149  if (D)
1150  D->Diag(diag::err_drv_argument_not_allowed_with)
1151  << MSCVersion->getAsString(Args)
1152  << MSCompatibilityVersion->getAsString(Args);
1153  return VersionTuple();
1154  }
1155 
1156  if (MSCompatibilityVersion) {
1157  VersionTuple MSVT;
1158  if (MSVT.tryParse(MSCompatibilityVersion->getValue())) {
1159  if (D)
1160  D->Diag(diag::err_drv_invalid_value)
1161  << MSCompatibilityVersion->getAsString(Args)
1162  << MSCompatibilityVersion->getValue();
1163  } else {
1164  return MSVT;
1165  }
1166  }
1167 
1168  if (MSCVersion) {
1169  unsigned Version = 0;
1170  if (StringRef(MSCVersion->getValue()).getAsInteger(10, Version)) {
1171  if (D)
1172  D->Diag(diag::err_drv_invalid_value)
1173  << MSCVersion->getAsString(Args) << MSCVersion->getValue();
1174  } else {
1175  return separateMSVCFullVersion(Version);
1176  }
1177  }
1178 
1179  return VersionTuple();
1180 }
1181 
1182 llvm::opt::DerivedArgList *ToolChain::TranslateOpenMPTargetArgs(
1183  const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost,
1184  SmallVectorImpl<llvm::opt::Arg *> &AllocatedArgs) const {
1185  DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
1186  const OptTable &Opts = getDriver().getOpts();
1187  bool Modified = false;
1188 
1189  // Handle -Xopenmp-target flags
1190  for (auto *A : Args) {
1191  // Exclude flags which may only apply to the host toolchain.
1192  // Do not exclude flags when the host triple (AuxTriple)
1193  // matches the current toolchain triple. If it is not present
1194  // at all, target and host share a toolchain.
1195  if (A->getOption().matches(options::OPT_m_Group)) {
1196  if (SameTripleAsHost)
1197  DAL->append(A);
1198  else
1199  Modified = true;
1200  continue;
1201  }
1202 
1203  unsigned Index;
1204  unsigned Prev;
1205  bool XOpenMPTargetNoTriple =
1206  A->getOption().matches(options::OPT_Xopenmp_target);
1207 
1208  if (A->getOption().matches(options::OPT_Xopenmp_target_EQ)) {
1209  llvm::Triple TT(getOpenMPTriple(A->getValue(0)));
1210 
1211  // Passing device args: -Xopenmp-target=<triple> -opt=val.
1212  if (TT.getTriple() == getTripleString())
1213  Index = Args.getBaseArgs().MakeIndex(A->getValue(1));
1214  else
1215  continue;
1216  } else if (XOpenMPTargetNoTriple) {
1217  // Passing device args: -Xopenmp-target -opt=val.
1218  Index = Args.getBaseArgs().MakeIndex(A->getValue(0));
1219  } else {
1220  DAL->append(A);
1221  continue;
1222  }
1223 
1224  // Parse the argument to -Xopenmp-target.
1225  Prev = Index;
1226  std::unique_ptr<Arg> XOpenMPTargetArg(Opts.ParseOneArg(Args, Index));
1227  if (!XOpenMPTargetArg || Index > Prev + 1) {
1228  getDriver().Diag(diag::err_drv_invalid_Xopenmp_target_with_args)
1229  << A->getAsString(Args);
1230  continue;
1231  }
1232  if (XOpenMPTargetNoTriple && XOpenMPTargetArg &&
1233  Args.getAllArgValues(options::OPT_fopenmp_targets_EQ).size() != 1) {
1234  getDriver().Diag(diag::err_drv_Xopenmp_target_missing_triple);
1235  continue;
1236  }
1237  XOpenMPTargetArg->setBaseArg(A);
1238  A = XOpenMPTargetArg.release();
1239  AllocatedArgs.push_back(A);
1240  DAL->append(A);
1241  Modified = true;
1242  }
1243 
1244  if (Modified)
1245  return DAL;
1246 
1247  delete DAL;
1248  return nullptr;
1249 }
1250 
1251 // TODO: Currently argument values separated by space e.g.
1252 // -Xclang -mframe-pointer=no cannot be passed by -Xarch_. This should be
1253 // fixed.
1255  const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A,
1256  llvm::opt::DerivedArgList *DAL,
1257  SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const {
1258  const OptTable &Opts = getDriver().getOpts();
1259  unsigned ValuePos = 1;
1260  if (A->getOption().matches(options::OPT_Xarch_device) ||
1261  A->getOption().matches(options::OPT_Xarch_host))
1262  ValuePos = 0;
1263 
1264  unsigned Index = Args.getBaseArgs().MakeIndex(A->getValue(ValuePos));
1265  unsigned Prev = Index;
1266  std::unique_ptr<llvm::opt::Arg> XarchArg(Opts.ParseOneArg(Args, Index));
1267 
1268  // If the argument parsing failed or more than one argument was
1269  // consumed, the -Xarch_ argument's parameter tried to consume
1270  // extra arguments. Emit an error and ignore.
1271  //
1272  // We also want to disallow any options which would alter the
1273  // driver behavior; that isn't going to work in our model. We
1274  // use options::NoXarchOption to control this.
1275  if (!XarchArg || Index > Prev + 1) {
1276  getDriver().Diag(diag::err_drv_invalid_Xarch_argument_with_args)
1277  << A->getAsString(Args);
1278  return;
1279  } else if (XarchArg->getOption().hasFlag(options::NoXarchOption)) {
1280  auto &Diags = getDriver().getDiags();
1281  unsigned DiagID =
1283  "invalid Xarch argument: '%0', not all driver "
1284  "options can be forwared via Xarch argument");
1285  Diags.Report(DiagID) << A->getAsString(Args);
1286  return;
1287  }
1288  XarchArg->setBaseArg(A);
1289  A = XarchArg.release();
1290  if (!AllocatedArgs)
1291  DAL->AddSynthesizedArg(A);
1292  else
1293  AllocatedArgs->push_back(A);
1294 }
1295 
1296 llvm::opt::DerivedArgList *ToolChain::TranslateXarchArgs(
1297  const llvm::opt::DerivedArgList &Args, StringRef BoundArch,
1298  Action::OffloadKind OFK,
1299  SmallVectorImpl<llvm::opt::Arg *> *AllocatedArgs) const {
1300  DerivedArgList *DAL = new DerivedArgList(Args.getBaseArgs());
1301  bool Modified = false;
1302 
1303  bool IsGPU = OFK == Action::OFK_Cuda || OFK == Action::OFK_HIP;
1304  for (Arg *A : Args) {
1305  bool NeedTrans = false;
1306  bool Skip = false;
1307  if (A->getOption().matches(options::OPT_Xarch_device)) {
1308  NeedTrans = IsGPU;
1309  Skip = !IsGPU;
1310  } else if (A->getOption().matches(options::OPT_Xarch_host)) {
1311  NeedTrans = !IsGPU;
1312  Skip = IsGPU;
1313  } else if (A->getOption().matches(options::OPT_Xarch__) && IsGPU) {
1314  // Do not translate -Xarch_ options for non CUDA/HIP toolchain since
1315  // they may need special translation.
1316  // Skip this argument unless the architecture matches BoundArch
1317  if (BoundArch.empty() || A->getValue(0) != BoundArch)
1318  Skip = true;
1319  else
1320  NeedTrans = true;
1321  }
1322  if (NeedTrans || Skip)
1323  Modified = true;
1324  if (NeedTrans)
1325  TranslateXarchArgs(Args, A, DAL, AllocatedArgs);
1326  if (!Skip)
1327  DAL->append(A);
1328  }
1329 
1330  if (Modified)
1331  return DAL;
1332 
1333  delete DAL;
1334  return nullptr;
1335 }
clang::driver::tools::OffloadPackager
Offload binary tool.
Definition: Clang.h:176
clang::driver::ToolChain::buildStaticLibTool
virtual Tool * buildStaticLibTool() const
Definition: ToolChain.cpp:322
clang::driver::Driver::GetProgramPath
std::string GetProgramPath(StringRef Name, const ToolChain &TC) const
GetProgramPath - Lookup Name in the list of program search paths.
Definition: Driver.cpp:5773
llvm
YAML serialization mapping.
Definition: Dominators.h:30
clang::driver::isOptimizationLevelFast
bool isOptimizationLevelFast(const llvm::opt::ArgList &Args)
clang::driver::ToolChain::getCompilerRT
virtual std::string getCompilerRT(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:516
clang::driver::ToolChain::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: ToolChain.cpp:99
XRayArgs.h
ObjCRuntime.h
clang::driver::tools::arm::setFloatABIInTriple
void setFloatABIInTriple(const Driver &D, const llvm::opt::ArgList &Args, llvm::Triple &triple)
clang::driver::ParsedClangName
Helper structure used to pass information extracted from clang executable name such as i686-linux-and...
Definition: ToolChain.h:64
clang::ento::Nullability
Nullability
Definition: CheckerHelpers.h:55
clang::ObjCRuntime::GCC
@ GCC
'gcc' is the Objective-C runtime shipped with GCC, implementing a fragile Objective-C ABI
Definition: ObjCRuntime.h:53
Driver.h
string
string(SUBSTRING ${CMAKE_CURRENT_BINARY_DIR} 0 ${PATH_LIB_START} PATH_HEAD) string(SUBSTRING $
Definition: CMakeLists.txt:22
clang::driver::Driver::Dir
std::string Dir
The path the driver executable was in, as invoked from the command line.
Definition: Driver.h:153
clang::driver::ToolChain::getDefaultLinker
virtual const char * getDefaultLinker() const
GetDefaultLinker - Get the default linker to use.
Definition: ToolChain.h:456
clang::driver::ToolChain::getTargetAndModeFromProgramName
static ParsedClangName getTargetAndModeFromProgramName(StringRef ProgName)
Return any implicit target and/or mode flag for an invocation of the compiler driver as ProgName.
Definition: ToolChain.cpp:244
clang::driver::ToolChain::getDeviceLibs
virtual llvm::SmallVector< BitCodeLibraryInfo, 12 > getDeviceLibs(const llvm::opt::ArgList &Args) const
Get paths for device libraries.
Definition: ToolChain.cpp:1121
clang::driver::ToolChain::computeMSVCVersion
virtual VersionTuple computeMSVCVersion(const Driver *D, const llvm::opt::ArgList &Args) const
On Windows, returns the MSVC compatibility version.
Definition: ToolChain.cpp:1142
clang::driver::ToolChain::buildCompilerRTBasename
virtual std::string buildCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, FileType Type, bool AddArch) const
Definition: ToolChain.cpp:482
clang::driver::Action::OFK_Cuda
@ OFK_Cuda
Definition: Action.h:93
clang::driver::ToolChain::getDefaultObjCRuntime
virtual ObjCRuntime getDefaultObjCRuntime(bool isNonFragile) const
getDefaultObjCRuntime - Return the default Objective-C runtime for this platform.
Definition: ToolChain.cpp:729
clang::driver::ToolChain::TranslateXarchArgs
virtual void TranslateXarchArgs(const llvm::opt::DerivedArgList &Args, llvm::opt::Arg *&A, llvm::opt::DerivedArgList *DAL, SmallVectorImpl< llvm::opt::Arg * > *AllocatedArgs=nullptr) const
Append the argument following A to DAL assuming A is an Xarch argument.
Definition: ToolChain.cpp:1254
llvm::SmallVector< std::string, 16 >
clang::driver::ToolChain::UnwindTableLevel
UnwindTableLevel
Definition: ToolChain.h:111
clang::driver::tools::arm::getARMFloatABI
FloatABI getARMFloatABI(const ToolChain &TC, const llvm::opt::ArgList &Args)
clang::driver::Action::ActionClass
ActionClass
Definition: Action.h:55
clang::driver::ToolChain::needsProfileRT
static bool needsProfileRT(const llvm::opt::ArgList &Args)
needsProfileRT - returns true if instrumentation profile is on.
Definition: ToolChain.cpp:581
clang::driver::Action::getKind
ActionClass getKind() const
Definition: Action.h:146
clang::driver::ToolChain::GetProgramPath
std::string GetProgramPath(const char *Name) const
Definition: ToolChain.cpp:614
clang::driver::Action::ExtractAPIJobClass
@ ExtractAPIJobClass
Definition: Action.h:61
clang::driver::Action::LipoJobClass
@ LipoJobClass
Definition: Action.h:69
clang::driver::ToolChain::AddClangCXXStdlibIncludeArgs
virtual void AddClangCXXStdlibIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIncludeArgs - Add the clang -cc1 level arguments to set the include paths to use for...
Definition: ToolChain.cpp:989
clang::driver::ToolChain::getDefaultUniversalArchName
StringRef getDefaultUniversalArchName() const
Provide the default architecture name (as expected by -arch) for this toolchain.
Definition: ToolChain.cpp:268
clang::driver::ToolChain::getDriver
const Driver & getDriver() const
Definition: ToolChain.h:232
Job.h
clang::driver::ToolChain::detectLibcxxVersion
virtual std::string detectLibcxxVersion(StringRef IncludePath) const
Definition: ToolChain.cpp:966
parseDriverSuffix
static const DriverSuffix * parseDriverSuffix(StringRef ProgName, size_t &Pos)
Definition: ToolChain.cpp:210
clang::driver::Action::OffloadBundlingJobClass
@ OffloadBundlingJobClass
Definition: Action.h:73
clang::driver::ToolChain::FT_Object
@ FT_Object
Definition: ToolChain.h:129
clang::driver::tools::ClangAs
Clang integrated assembler tool.
Definition: Clang.h:124
clang::driver::ToolChain::getTripleString
std::string getTripleString() const
Definition: ToolChain.h:257
clang::driver::Action::OFK_HIP
@ OFK_HIP
Definition: Action.h:95
clang::driver::ToolChain::addFastMathRuntimeIfAvailable
bool addFastMathRuntimeIfAvailable(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFastMathRuntimeIfAvailable - If a runtime library exists that sets global flags for unsafe floatin...
Definition: ToolChain.cpp:1078
clang::driver::ToolChain::getCompilerRTPath
virtual std::string getCompilerRTPath() const
Definition: ToolChain.cpp:462
clang::driver::Action::AssembleJobClass
@ AssembleJobClass
Definition: Action.h:66
clang::driver::tools::LinkerWrapper
Linker wrapper tool.
Definition: Clang.h:189
clang::driver::ToolChain::HasNativeLLVMSupport
virtual bool HasNativeLLVMSupport() const
HasNativeLTOLinker - Check whether the linker and related tools have native LLVM support.
Definition: ToolChain.cpp:709
clang::driver::ToolChain::GetFilePath
std::string GetFilePath(const char *Name) const
Definition: ToolChain.cpp:610
clang::OffloadBundler
Definition: OffloadBundler.h:47
clang::driver::ToolChain::addClangWarningOptions
virtual void addClangWarningOptions(llvm::opt::ArgStringList &CC1Args) const
Add warning options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:821
clang::driver::Driver::getOpts
const llvm::opt::OptTable & getOpts() const
Definition: Driver.h:365
clang::driver::ToolChain::getSanitizerArgs
SanitizerArgs getSanitizerArgs(const llvm::opt::ArgList &JobArgs) const
Definition: ToolChain.cpp:146
clang::driver::ToolChain::getInputFilename
virtual std::string getInputFilename(const InputInfo &Input) const
Some toolchains need to modify the file name, for example to replace the extension for object files w...
Definition: ToolChain.cpp:293
clang::driver::InputInfo
InputInfo - Wrapper for information about an input source.
Definition: InputInfo.h:22
clang::driver::ToolChain::addExternCSystemIncludeIfExists
static void addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Definition: ToolChain.cpp:941
clang::driver::Driver::getDiags
DiagnosticsEngine & getDiags() const
Definition: Driver.h:367
clang::driver::ToolChain::RuntimeLibType
RuntimeLibType
Definition: ToolChain.h:100
clang::Type
The base class of the type hierarchy.
Definition: Type.h:1565
clang::driver::ToolChain::useIntegratedBackend
virtual bool useIntegratedBackend() const
Check if the toolchain should use the integrated backend.
Definition: ToolChain.cpp:109
InputInfo.h
clang::driver::XRayArgs
Definition: XRayArgs.h:21
clang::driver::types::lookupTypeForExtension
ID lookupTypeForExtension(llvm::StringRef Ext)
lookupTypeForExtension - Lookup the type to use for the file extension Ext.
Definition: Types.cpp:295
clang::driver::tools::arm::setArchNameInTriple
void setArchNameInTriple(const Driver &D, const llvm::opt::ArgList &Args, types::ID InputType, llvm::Triple &Triple)
Action.h
clang::driver::Action::PreprocessJobClass
@ PreprocessJobClass
Definition: Action.h:59
clang::driver::Action::DsymutilJobClass
@ DsymutilJobClass
Definition: Action.h:70
clang::driver::ToolChain::getFilePaths
path_list & getFilePaths()
Definition: ToolChain.h:274
clang::driver::Driver::Diag
DiagnosticBuilder Diag(unsigned DiagID) const
Definition: Driver.h:142
clang::driver::Multilib::gccSuffix
const std::string & gccSuffix() const
Get the detected GCC installation path suffix for the multi-arch target variant.
Definition: Multilib.h:45
clang::driver::Tool
Tool - Information on a specific compilation tool.
Definition: Tool.h:32
clang::driver::ToolChain::ToolChain
ToolChain(const Driver &D, const llvm::Triple &T, const llvm::opt::ArgList &Args)
Definition: ToolChain.cpp:75
Options.h
clang::driver::ToolChain::concat
static std::string concat(StringRef Path, const Twine &A, const Twine &B="", const Twine &C="", const Twine &D="")
Definition: ToolChain.cpp:958
clang::XRayInstrKind::None
constexpr XRayInstrMask None
Definition: XRayInstr.h:38
clang::interp::LE
bool LE(InterpState &S, CodePtr OpPC)
Definition: Interp.h:504
getArchNameForCompilerRTLib
static StringRef getArchNameForCompilerRTLib(const ToolChain &TC, const ArgList &Args)
Definition: ToolChain.cpp:419
clang::driver::ToolChain::isFastMathRuntimeAvailable
virtual bool isFastMathRuntimeAvailable(const llvm::opt::ArgList &Args, std::string &Path) const
If a runtime library exists that sets global flags for unsafe floating point math,...
Definition: ToolChain.cpp:1058
clang::driver::ToolChain::getOS
StringRef getOS() const
Definition: ToolChain.h:251
clang::driver::ToolChain::UNW_None
@ UNW_None
Definition: ToolChain.h:106
clang::driver::ToolChain::addClangCC1ASTargetOptions
virtual void addClangCC1ASTargetOptions(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CC1ASArgs) const
Add options that need to be passed to cc1as for this target.
Definition: ToolChain.cpp:818
llvm::opt
Definition: DiagnosticOptions.h:19
DriverDiagnostic.h
clang::driver::Action::OffloadUnbundlingJobClass
@ OffloadUnbundlingJobClass
Definition: Action.h:74
FindDriverSuffix
static const DriverSuffix * FindDriverSuffix(StringRef ProgName, size_t &Pos)
Definition: ToolChain.cpp:167
clang::DiagnosticsEngine::Error
@ Error
Definition: Diagnostic.h:200
clang::driver::ToolChain::AddClangSystemIncludeArgs
virtual void AddClangSystemIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add the clang cc1 arguments for system include paths.
Definition: ToolChain.cpp:809
clang::driver::ToolChain::RLT_Libgcc
@ RLT_Libgcc
Definition: ToolChain.h:102
clang::driver::ToolChain::AddCCKextLibArgs
virtual void AddCCKextLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddCCKextLibArgs - Add the system specific linker arguments to use for kernel extensions (Darwin-spec...
Definition: ToolChain.cpp:1053
clang::driver::ToolChain::CXXStdlibType
CXXStdlibType
Definition: ToolChain.h:95
clang::driver::Action::OffloadPackagerJobClass
@ OffloadPackagerJobClass
Definition: Action.h:75
Clang.h
llvm::SmallString< 128 >
clang::driver::ToolChain::getTriple
const llvm::Triple & getTriple() const
Definition: ToolChain.h:234
clang::driver::ToolChain::SelectTool
virtual Tool * SelectTool(const JobAction &JA) const
Choose a tool to use to handle the action JA.
Definition: ToolChain.cpp:601
InterfaceStubs.h
clang::driver::ToolChain::SelectedMultilib
Multilib SelectedMultilib
Definition: ToolChain.h:190
clang::driver::ToolChain::buildLinker
virtual Tool * buildLinker() const
Definition: ToolChain.cpp:318
clang::driver::Driver::SysRoot
std::string SysRoot
sysroot, if present
Definition: Driver.h:181
normalizeProgramName
static std::string normalizeProgramName(llvm::StringRef Argv0)
Normalize the program name from argv[0] by stripping the file extension if present and lower-casing t...
Definition: ToolChain.cpp:200
clang::driver::ToolChain::IsIntegratedAssemblerDefault
virtual bool IsIntegratedAssemblerDefault() const
IsIntegratedAssemblerDefault - Does this tool chain enable -integrated-as by default.
Definition: ToolChain.h:397
clang::driver::tools::Clang
Clang compiler tool.
Definition: Clang.h:28
clang::driver::ToolChain::setTripleEnvironment
void setTripleEnvironment(llvm::Triple::EnvironmentType Env)
Definition: ToolChain.cpp:91
clang::driver::ToolChain::getStdlibPaths
path_list getStdlibPaths() const
Definition: ToolChain.cpp:565
separateMSVCFullVersion
static VersionTuple separateMSVCFullVersion(unsigned Version)
Definition: ToolChain.cpp:1128
clang::driver::Action::OffloadClass
@ OffloadClass
Definition: Action.h:58
clang::driver::ToolChain::CST_Libcxx
@ CST_Libcxx
Definition: ToolChain.h:96
clang::driver::Driver::CCCIsCXX
bool CCCIsCXX() const
Whether the driver should follow g++ like behavior.
Definition: Driver.h:211
clang::driver::ToolChain::UNW_CompilerRT
@ UNW_CompilerRT
Definition: ToolChain.h:107
clang::driver::ToolChain::TranslateOpenMPTargetArgs
virtual llvm::opt::DerivedArgList * TranslateOpenMPTargetArgs(const llvm::opt::DerivedArgList &Args, bool SameTripleAsHost, SmallVectorImpl< llvm::opt::Arg * > &AllocatedArgs) const
TranslateOpenMPTargetArgs - Create a new derived argument list for that contains the OpenMP target sp...
Definition: ToolChain.cpp:1182
clang::driver::tools::Flang
Flang compiler tool.
Definition: Flang.h:25
clang::driver::SanitizerArgs
Definition: SanitizerArgs.h:24
SanitizerArgs.h
clang::driver::ToolChain::UNW_Libgcc
@ UNW_Libgcc
Definition: ToolChain.h:108
clang::driver::ToolChain::CST_Libstdcxx
@ CST_Libstdcxx
Definition: ToolChain.h:97
clang::driver::ToolChain::GetExceptionModel
virtual llvm::ExceptionHandling GetExceptionModel(const llvm::opt::ArgList &Args) const
GetExceptionModel - Return the tool chain exception model.
Definition: ToolChain.cpp:735
clang::driver::Driver::ResourceDir
std::string ResourceDir
The path to the compiler resource directory.
Definition: Driver.h:165
clang::driver::ToolChain::getDefaultUnwindTableLevel
virtual UnwindTableLevel getDefaultUnwindTableLevel(const llvm::opt::ArgList &Args) const
How detailed should the unwind tables be by default.
Definition: ToolChain.cpp:298
clang::driver::ToolChain::getArch
llvm::Triple::ArchType getArch() const
Definition: ToolChain.h:248
clang::driver::ToolChain::AddFilePathLibArgs
void AddFilePathLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddFilePathLibArgs - Add each thing in getFilePaths() as a "-L" option.
Definition: ToolChain.cpp:1046
clang::driver::ToolChain::ShouldLinkCXXStdlib
bool ShouldLinkCXXStdlib(const llvm::opt::ArgList &Args) const
Returns if the C++ standard library should be linked in.
Definition: ToolChain.cpp:1021
clang::driver::ToolChain::getRuntimePaths
path_list getRuntimePaths() const
Definition: ToolChain.cpp:543
clang::driver::Action::PrecompileJobClass
@ PrecompileJobClass
Definition: Action.h:60
clang::driver::Action::StaticLibJobClass
@ StaticLibJobClass
Definition: Action.h:77
clang::driver::Action::LinkerWrapperJobClass
@ LinkerWrapperJobClass
Definition: Action.h:76
clang::driver::ToolChain::getCompilerRTBasename
std::string getCompilerRTBasename(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:475
clang::driver::options::NoXarchOption
@ NoXarchOption
Definition: Options.h:25
ToolChain.h
clang::driver::ToolChain::FT_Static
@ FT_Static
Definition: ToolChain.h:129
GetRTTIArgument
static llvm::opt::Arg * GetRTTIArgument(const ArgList &Args)
Definition: ToolChain.cpp:54
clang::driver::ToolChain::GetUnwindLibType
virtual UnwindLibType GetUnwindLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:857
P
StringRef P
Definition: ASTMatchersInternal.cpp:563
clang::driver::ToolChain::getSupportedSanitizers
virtual SanitizerMask getSupportedSanitizers() const
Return sanitizers which are available in this toolchain.
Definition: ToolChain.cpp:1089
clang::driver::ToolChain::UnwindTableLevel::None
@ None
clang::driver::ToolChain::getTool
virtual Tool * getTool(Action::ActionClass AC) const
Definition: ToolChain.cpp:374
clang::driver::Action::BackendJobClass
@ BackendJobClass
Definition: Action.h:65
clang::driver::ToolChain::addSystemIncludes
static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, ArrayRef< StringRef > Paths)
Utility function to add a list of system include directories to CC1.
Definition: ToolChain.cpp:949
clang::driver::ToolChain::AddCXXStdlibLibArgs
virtual void AddCXXStdlibLibArgs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
AddCXXStdlibLibArgs - Add the system specific linker arguments to use for the given C++ standard libr...
Definition: ToolChain.cpp:1027
clang::driver::ToolChain::getArchSpecificLibPath
std::string getArchSpecificLibPath() const
Definition: ToolChain.cpp:574
clang::driver::ToolChain::RM_Enabled
@ RM_Enabled
Definition: ToolChain.h:118
clang::ObjCRuntime::GNUstep
@ GNUstep
'gnustep' is the modern non-fragile GNUstep runtime.
Definition: ObjCRuntime.h:56
clang::driver::ToolChain::GetRuntimeLibType
virtual RuntimeLibType GetRuntimeLibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:831
clang::driver::ToolChain::addProfileRTLibs
virtual void addProfileRTLibs(const llvm::opt::ArgList &Args, llvm::opt::ArgStringList &CmdArgs) const
addProfileRTLibs - When -fprofile-instr-profile is specified, try to pass a suitable profile runtime ...
Definition: ToolChain.cpp:823
clang::driver::Action::AnalyzeJobClass
@ AnalyzeJobClass
Definition: Action.h:62
clang::driver::ToolChain::getCompilerRTArgString
const char * getCompilerRTArgString(const llvm::opt::ArgList &Args, StringRef Component, FileType Type=ToolChain::FT_Static) const
Definition: ToolChain.cpp:537
clang::driver::ToolChain::getOpenMPTriple
static llvm::Triple getOpenMPTriple(StringRef TripleStr)
Definition: ToolChain.h:760
clang::driver::ToolChain
ToolChain - Access to tools for a single platform.
Definition: ToolChain.h:91
clang::driver::ToolChain::GetLinkerPath
std::string GetLinkerPath(bool *LinkerIsLLD=nullptr) const
Returns the linker path, respecting the -fuse-ld= argument to determine the linker suffix or name.
Definition: ToolChain.cpp:618
clang::driver::ToolChain::RLT_CompilerRT
@ RLT_CompilerRT
Definition: ToolChain.h:101
llvm::ArrayRef
Definition: LLVM.h:34
clang::driver::ToolChain::AddCudaIncludeArgs
virtual void AddCudaIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use system-specific CUDA includes.
Definition: ToolChain.cpp:1114
clang::driver::ToolChain::LookupTypeForExtension
virtual types::ID LookupTypeForExtension(StringRef Ext) const
LookupTypeForExtension - Return the default language type to use for the given extension.
Definition: ToolChain.cpp:697
clang::SanitizerKind
Definition: Sanitizers.h:131
clang::driver::ToolChain::useIntegratedAs
virtual bool useIntegratedAs() const
Check if the toolchain should use the integrated assembler.
Definition: ToolChain.cpp:103
clang::driver::ToolChain::AddClangCXXStdlibIsystemArgs
void AddClangCXXStdlibIsystemArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
AddClangCXXStdlibIsystemArgs - Add the clang -cc1 level arguments to set the specified include paths ...
Definition: ToolChain.cpp:1003
clang::driver::ToolChain::computeSysRoot
virtual std::string computeSysRoot() const
Return the sysroot, possibly searching for a default sysroot using target-specific logic.
Definition: ToolChain.cpp:805
clang::driver::ToolChain::ComputeLLVMTriple
virtual std::string ComputeLLVMTriple(const llvm::opt::ArgList &Args, types::ID InputType=types::TY_INVALID) const
ComputeLLVMTriple - Return the LLVM target triple to use, after taking command line arguments into ac...
Definition: ToolChain.cpp:752
clang::driver::ToolChain::getLibraryPaths
path_list & getLibraryPaths()
Definition: ToolChain.h:271
clang::driver::Action::BindArchClass
@ BindArchClass
Definition: Action.h:57
clang::driver::ToolChain::IsNonIntegratedBackendSupported
virtual bool IsNonIntegratedBackendSupported() const
IsNonIntegratedBackendSupported - Does this tool chain support -fno-integrated-objemitter.
Definition: ToolChain.h:409
clang::driver::ToolChain::isBareMetal
virtual bool isBareMetal() const
isBareMetal - Is this a bare metal target.
Definition: ToolChain.h:587
clang::driver::types::ID
ID
Definition: Types.h:23
clang::driver::tools::OffloadBundler
Offload bundler tool.
Definition: Clang.h:145
clang::ObjCRuntime
The basic abstraction for the target Objective-C runtime.
Definition: ObjCRuntime.h:28
clang::driver::Action::CompileJobClass
@ CompileJobClass
Definition: Action.h:64
clang::driver::ToolChain::getOSLibName
virtual StringRef getOSLibName() const
Definition: ToolChain.cpp:442
clang::driver::ToolChain::IsIntegratedBackendSupported
virtual bool IsIntegratedBackendSupported() const
IsIntegratedBackendSupported - Does this tool chain support -fintegrated-objemitter.
Definition: ToolChain.h:405
clang::driver::ToolChain::FileType
FileType
Definition: ToolChain.h:129
clang::driver::Driver::GetFilePath
std::string GetFilePath(StringRef Name, const ToolChain &TC) const
GetFilePath - Lookup Name in the list of file search paths.
Definition: Driver.cpp:5713
clang::driver::ToolChain::GetDefaultCXXStdlibType
virtual CXXStdlibType GetDefaultCXXStdlibType() const
Definition: ToolChain.h:463
clang::driver::ToolChain::GetCXXStdlibType
virtual CXXStdlibType GetCXXStdlibType(const llvm::opt::ArgList &Args) const
Definition: ToolChain.cpp:893
clang::driver::ToolChain::AddIAMCUIncludeArgs
virtual void AddIAMCUIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use MCU GCC toolchain includes.
Definition: ToolChain.cpp:1125
clang::driver::ToolChain::GetDefaultUnwindLibType
virtual UnwindLibType GetDefaultUnwindLibType() const
Definition: ToolChain.h:467
Sanitizers.h
clang::driver::InputInfo::getFilename
const char * getFilename() const
Definition: InputInfo.h:83
clang::driver::ToolChain::isThreadModelSupported
virtual bool isThreadModelSupported(const StringRef Model) const
isThreadModelSupported() - Does this target support a thread model?
Definition: ToolChain.cpp:739
clang::DiagnosticsEngine::getCustomDiagID
unsigned getCustomDiagID(Level L, const char(&FormatString)[N])
Return an ID for a diagnostic with the specified format string and level.
Definition: Diagnostic.h:868
clang
Definition: CalledOnceCheck.h:17
clang::driver::Driver
Driver - Encapsulate logic for constructing compilation processes from a set of gcc-driver-like comma...
Definition: Driver.h:75
clang::driver::Action::MigrateJobClass
@ MigrateJobClass
Definition: Action.h:63
clang::driver::ToolChain::defaultToIEEELongDouble
bool defaultToIEEELongDouble() const
Check whether use IEEE binary128 as long double format by default.
Definition: ToolChain.cpp:141
clang::driver::tools::ifstool::Merger
Definition: InterfaceStubs.h:19
clang::driver::ToolChain::UnwindLibType
UnwindLibType
Definition: ToolChain.h:105
clang::driver::ToolChain::AddHIPIncludeArgs
virtual void AddHIPIncludeArgs(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args) const
Add arguments to use system-specific HIP includes.
Definition: ToolChain.cpp:1117
clang::driver::Action::VerifyDebugInfoJobClass
@ VerifyDebugInfoJobClass
Definition: Action.h:71
clang::driver::Driver::getVFS
llvm::vfs::FileSystem & getVFS() const
Definition: Driver.h:369
CalculateRTTIMode
static ToolChain::RTTIMode CalculateRTTIMode(const ArgList &Args, const llvm::Triple &Triple, const Arg *CachedRTTIArg)
Definition: ToolChain.cpp:59
clang::driver::ToolChain::addExternCSystemInclude
static void addExternCSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory with extern "C" semantics to CC1 arguments.
Definition: ToolChain.cpp:934
clang::driver::ToolChain::needsGCovInstrumentation
static bool needsGCovInstrumentation(const llvm::opt::ArgList &Args)
Returns true if gcov instrumentation (-fprofile-arcs or –coverage) is on.
Definition: ToolChain.cpp:595
clang::driver::ToolChain::addClangTargetOptions
virtual void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, Action::OffloadKind DeviceOffloadKind) const
Add options that need to be passed to cc1 for this target.
Definition: ToolChain.cpp:814
clang::driver::ToolChain::isCrossCompiling
virtual bool isCrossCompiling() const
Returns true if the toolchain is targeting a non-native architecture.
Definition: ToolChain.cpp:713
clang::driver::ToolChain::RTTIMode
RTTIMode
Definition: ToolChain.h:117
ARM.h
clang::driver::ToolChain::getXRayArgs
const XRayArgs & getXRayArgs() const
Definition: ToolChain.cpp:152
clang::driver::Action::OffloadKind
OffloadKind
Definition: Action.h:86
clang::driver::ToolChain::useRelaxRelocations
virtual bool useRelaxRelocations() const
Check whether to enable x86 relax relocations by default.
Definition: ToolChain.cpp:137
Flang.h
clang::driver::ToolChain::~ToolChain
virtual ~ToolChain()
llvm::SmallVectorImpl
Definition: Randstruct.h:18
clang::driver::ToolChain::addSystemInclude
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args, const Twine &Path)
Utility function to add a system include directory to CC1 arguments.
Definition: ToolChain.cpp:919
AIX
clang::driver::toolchains::AIX AIX
Definition: AIX.cpp:19
clang::driver::ToolChain::FT_Shared
@ FT_Shared
Definition: ToolChain.h:129
clang::driver::JobAction
Definition: Action.h:398
clang::driver::Action::LinkJobClass
@ LinkJobClass
Definition: Action.h:67
clang::driver::Action::IfsMergeJobClass
@ IfsMergeJobClass
Definition: Action.h:68
clang::driver::ToolChain::GetDefaultRuntimeLibType
virtual RuntimeLibType GetDefaultRuntimeLibType() const
GetDefaultRuntimeLibType - Get the default runtime library variant to use.
Definition: ToolChain.h:459
clang::driver::ToolChain::buildAssembler
virtual Tool * buildAssembler() const
Definition: ToolChain.cpp:314
clang::SanitizerMask
Definition: Sanitizers.h:30
clang::driver::Action::InputClass
@ InputClass
Definition: Action.h:56
clang::driver::ToolChain::IsIntegratedBackendDefault
virtual bool IsIntegratedBackendDefault() const
IsIntegratedBackendDefault - Does this tool chain enable -fintegrated-objemitter by default.
Definition: ToolChain.h:401
clang::driver::Driver::IsFlangMode
bool IsFlangMode() const
Whether the driver should invoke flang for fortran inputs.
Definition: Driver.h:224
clang::driver::ToolChain::GetStaticLibToolPath
std::string GetStaticLibToolPath() const
Returns the linker path for emitting a static library.
Definition: ToolChain.cpp:690
clang::driver::Action::VerifyPCHJobClass
@ VerifyPCHJobClass
Definition: Action.h:72
clang::driver::ToolChain::ComputeEffectiveClangTriple
virtual std::string ComputeEffectiveClangTriple(const llvm::opt::ArgList &Args, types::ID InputType=types::TY_INVALID) const
ComputeEffectiveClangTriple - Return the Clang triple to use for this target, which may take into acc...
Definition: ToolChain.cpp:800
clang::driver::ToolChain::RM_Disabled
@ RM_Disabled
Definition: ToolChain.h:119