Tool.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #pragma once
  2. #ifdef __GNUC__
  3. #pragma GCC diagnostic push
  4. #pragma GCC diagnostic ignored "-Wunused-parameter"
  5. #endif
  6. //===--- Tool.h - Compilation Tools -----------------------------*- C++ -*-===//
  7. //
  8. // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
  9. // See https://llvm.org/LICENSE.txt for license information.
  10. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  11. //
  12. //===----------------------------------------------------------------------===//
  13. #ifndef LLVM_CLANG_DRIVER_TOOL_H
  14. #define LLVM_CLANG_DRIVER_TOOL_H
  15. #include "clang/Basic/LLVM.h"
  16. namespace llvm {
  17. namespace opt {
  18. class ArgList;
  19. }
  20. }
  21. namespace clang {
  22. namespace driver {
  23. class Compilation;
  24. class InputInfo;
  25. class Job;
  26. class JobAction;
  27. class ToolChain;
  28. typedef SmallVector<InputInfo, 4> InputInfoList;
  29. /// Tool - Information on a specific compilation tool.
  30. class Tool {
  31. /// The tool name (for debugging).
  32. const char *Name;
  33. /// The human readable name for the tool, for use in diagnostics.
  34. const char *ShortName;
  35. /// The tool chain this tool is a part of.
  36. const ToolChain &TheToolChain;
  37. public:
  38. Tool(const char *Name, const char *ShortName, const ToolChain &TC);
  39. public:
  40. virtual ~Tool();
  41. const char *getName() const { return Name; }
  42. const char *getShortName() const { return ShortName; }
  43. const ToolChain &getToolChain() const { return TheToolChain; }
  44. virtual bool hasIntegratedAssembler() const { return false; }
  45. virtual bool hasIntegratedBackend() const { return true; }
  46. virtual bool canEmitIR() const { return false; }
  47. virtual bool hasIntegratedCPP() const = 0;
  48. virtual bool isLinkJob() const { return false; }
  49. virtual bool isDsymutilJob() const { return false; }
  50. /// Does this tool have "good" standardized diagnostics, or should the
  51. /// driver add an additional "command failed" diagnostic on failures.
  52. virtual bool hasGoodDiagnostics() const { return false; }
  53. /// ConstructJob - Construct jobs to perform the action \p JA,
  54. /// writing to \p Output and with \p Inputs, and add the jobs to
  55. /// \p C.
  56. ///
  57. /// \param TCArgs - The argument list for this toolchain, with any
  58. /// tool chain specific translations applied.
  59. /// \param LinkingOutput - If this output will eventually feed the
  60. /// linker, then this is the final output name of the linked image.
  61. virtual void ConstructJob(Compilation &C, const JobAction &JA,
  62. const InputInfo &Output,
  63. const InputInfoList &Inputs,
  64. const llvm::opt::ArgList &TCArgs,
  65. const char *LinkingOutput) const = 0;
  66. /// Construct jobs to perform the action \p JA, writing to the \p Outputs and
  67. /// with \p Inputs, and add the jobs to \p C. The default implementation
  68. /// assumes a single output and is expected to be overloaded for the tools
  69. /// that support multiple inputs.
  70. ///
  71. /// \param TCArgs The argument list for this toolchain, with any
  72. /// tool chain specific translations applied.
  73. /// \param LinkingOutput If this output will eventually feed the
  74. /// linker, then this is the final output name of the linked image.
  75. virtual void ConstructJobMultipleOutputs(Compilation &C, const JobAction &JA,
  76. const InputInfoList &Outputs,
  77. const InputInfoList &Inputs,
  78. const llvm::opt::ArgList &TCArgs,
  79. const char *LinkingOutput) const;
  80. };
  81. } // end namespace driver
  82. } // end namespace clang
  83. #endif
  84. #ifdef __GNUC__
  85. #pragma GCC diagnostic pop
  86. #endif