Repository: carbon-language/carbon-lang
File: toolchain/base/install_paths.h (C/C++)

Code before:
  auto clang_resource_path() const -> std::filesystem::path;

  // The path to the root of the runtimes.
  auto runtimes_root() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libunwind_path() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libcxx_path() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libcxxabi_path() const -> std::filesystem::path;

  // The path to the LLVM `libc` runtime.
  auto libc_path() const -> std::filesystem::path;

  // The installation digest path.
  //
  // This file contains a digest of the installation.
  auto digest_path() const -> std::filesystem::path;

 private:
  friend class InstallPathsTestPeer;

  InstallPaths() { SetError("No prefix provided!"); }
  explicit InstallPaths(std::filesystem::path root) : root_(std::move(root)) {}

  static auto MakeFromFile(std::filesystem::path file) -> InstallPaths;

  // Set an error message on the install paths and reset the prefix to empty,
  // which should use the current working directory.
  auto SetError(llvm::Twine message) -> void;

  // Check that the install paths have a marker file at
  // `prefix()/lib/carbon/carbon_install.txt". If not, calls `SetError` with the
  // relevant error message.
  auto CheckMarkerFile() -> void;

  // Read a manifest file.
  auto ReadManifest(std::filesystem::path manifest_path,
                    std::filesystem::path manifest_file) const
      -> ErrorOr<llvm::SmallVector<std::string>>;

  // The computed installation root. In the event of an error, this will be the
  // empty string.
  //
  // When run from Bazel (for example, in unit tests or development binaries)
  // this will look like:
  // `bazel-bin/some/bazel/target.runfiles/_main/toolchain/install/prefix/lib/carbon`
  //

Review comment (suggestion):
```suggestion
  InstallPaths() { SetError("No root provided!"); }
```

Code after:
  // The path to the root of the runtimes.
  auto runtimes_root() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libunwind_path() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libcxx_path() const -> std::filesystem::path;

  // The path to `libunwind` runtime.
  auto libcxxabi_path() const -> std::filesystem::path;

  // The path to the LLVM `libc` runtime.
  auto libc_path() const -> std::filesystem::path;

  // The installation digest path.
  //
  // This file contains a digest of the installation.
  auto digest_path() const -> std::filesystem::path;

 private:
  friend class InstallPathsTestPeer;

  InstallPaths() { SetError("No root provided!"); }
  explicit InstallPaths(std::filesystem::path root) : root_(std::move(root)) {}

  static auto MakeFromFile(std::filesystem::path file) -> InstallPaths;

  // Set an error message on the install paths and reset the `root_` to empty,
  // which should use the current working directory.
  auto SetError(llvm::Twine message) -> void;

  // Check that the install paths have a marker file at
  // `root()/lib/carbon/carbon_install.txt". If not, calls `SetError` with the
  // relevant error message.
  auto CheckMarkerFile() -> void;

  // Read a manifest file.
  auto ReadManifest(std::filesystem::path manifest_path,
                    std::filesystem::path manifest_file) const
      -> ErrorOr<llvm::SmallVector<std::string>>;

  // The computed installation root. In the event of an error, this will be the
  // empty string.
  //
  // When run from Bazel (for example, in unit tests or development binaries)
  // this will look like:
  // `bazel-bin/some/bazel/target.runfiles/_main/toolchain/install/prefix/lib/carbon`
  //
  // When installed, it's expected to be similar to the CMake install prefix,
  // followed by `lib/carbon`: