Files
carbon-lang/toolchain/driver/clang_subcommand.h
T
Jon Ross-PerkinsandChandler Carruth c107aaad13 Add a clang subcommand. (#4322)
This makes something like `bazel run :toolchain -- clang -- -c test.cpp`
work, because that can be run in-process. Note that `bazel run
:toolchain -- clang -- test.cpp` still requires subprocessing, and does
not work.

Note, the vision here is that we are trying to align how clang and
carbon compile c++ code. This is work towards intertwining command
execution.

---------

Co-authored-by: Chandler Carruth <chandlerc@gmail.com>
2024-09-23 23:21:20 +00:00

41 lines
1.2 KiB
C++

// Part of the Carbon Language project, under the Apache License v2.0 with LLVM
// Exceptions. See /LICENSE for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
#ifndef CARBON_TOOLCHAIN_DRIVER_CLANG_SUBCOMMAND_H_
#define CARBON_TOOLCHAIN_DRIVER_CLANG_SUBCOMMAND_H_
#include "common/command_line.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringRef.h"
#include "toolchain/driver/driver_env.h"
#include "toolchain/driver/driver_subcommand.h"
namespace Carbon {
// Options for the clang subcommand, which is just a thin wrapper.
//
// See the implementation of `Build` for documentation on members.
struct ClangOptions {
static const CommandLine::CommandInfo Info;
auto Build(CommandLine::CommandBuilder& b) -> void;
llvm::SmallVector<llvm::StringRef> args;
};
// Implements the clang subcommand of the driver.
class ClangSubcommand : public DriverSubcommand {
public:
auto BuildOptions(CommandLine::CommandBuilder& b) { options_.Build(b); }
auto Run(DriverEnv& driver_env) -> DriverResult override;
private:
ClangOptions options_;
};
} // namespace Carbon
#endif // CARBON_TOOLCHAIN_DRIVER_CLANG_SUBCOMMAND_H_