tool_runner_base.h 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. // Part of the Carbon Language project, under the Apache License v2.0 with LLVM
  2. // Exceptions. See /LICENSE for license information.
  3. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
  4. #ifndef CARBON_TOOLCHAIN_DRIVER_TOOL_RUNNER_BASE_H_
  5. #define CARBON_TOOLCHAIN_DRIVER_TOOL_RUNNER_BASE_H_
  6. #include <optional>
  7. #include "common/ostream.h"
  8. #include "llvm/ADT/ArrayRef.h"
  9. #include "llvm/ADT/StringRef.h"
  10. #include "toolchain/base/install_paths.h"
  11. namespace Carbon {
  12. // Base that factors out common utilities needed when implementing a runner of
  13. // an external tool, especially tools part of the LLVM and Clang C++ toolchain
  14. // that Carbon will end up wrapping.
  15. //
  16. // Note that this struct just collects common data and helper methods, and does
  17. // not itself impose any invariants or form a meaningful API. It should be used
  18. // as an implementation detail only.
  19. class ToolRunnerBase {
  20. public:
  21. // Construct the tool runner bas.
  22. //
  23. // If `vlog_stream` is provided, it will be used for `CARBON_VLOG`s. If it is
  24. // also equal to `&llvm::errs()`, and so tied to stderr, that will be used by
  25. // verbose flag injection helpers in this class.
  26. explicit ToolRunnerBase(const InstallPaths* install_paths,
  27. llvm::raw_ostream* vlog_stream = nullptr);
  28. protected:
  29. // We use protected members as this base is just factoring out common
  30. // implementation details of other runners.
  31. //
  32. // NOLINTBEGIN(misc-non-private-member-variables-in-classes)
  33. const InstallPaths* installation_;
  34. llvm::raw_ostream* vlog_stream_;
  35. // NOLINTEND(misc-non-private-member-variables-in-classes)
  36. };
  37. } // namespace Carbon
  38. #endif // CARBON_TOOLCHAIN_DRIVER_TOOL_RUNNER_BASE_H_