Files
carbon-lang/toolchain/base/llvm_tools.h
T
Nicholas Bishop dc5917e88b roll llvm to 6ec87e7ec4b3 (#7856)
The `Support/LLVMDriver.h` header was renamed to `Driver.h`, and the API
of `llvm::ToolContext` changed such that a constructor call is needed
instead of aggregate initialization.

A couple new bazel deps were added (libxml2 and xz), and rules_cc
required an updated version. The addition of libxml2 and xz required
some additions to check_non_test_cc_deps.py. libxml2 also required
allow-listing an additional URL in CI jobs.

Dropped `0011_Temporarily_remove_reference_to_hermetic_toolchain.patch`,
no longer needed.

Added `0012_Drop_dependencies_on_linux_uapi_and_pyyaml.patch` to remove
a couple dependencies from llvm that Carbon doesn't currently require.
These were causing bazel queries in check_deps and
forbid_llvm_googletest.py to fail.
2026-09-29 03:32:33 +00:00

76 lines
2.3 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_BASE_LLVM_TOOLS_H_
#define CARBON_TOOLCHAIN_BASE_LLVM_TOOLS_H_
#include <cstdint>
#include "common/command_line.h"
#include "common/enum_base.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Driver.h"
namespace Carbon {
CARBON_DEFINE_RAW_ENUM_CLASS(LLVMTool, uint8_t) {
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) \
CARBON_RAW_ENUM_ENUMERATOR(Identifier)
#include "toolchain/base/llvm_tools.def"
};
// An enum-like class for each of the LLVM tools.
//
// This can be used like an enum to track a specific one of the LLVM tools. It
// also has a collection of methods to access various aspects of the tools
// themselves, including the symbol used to invoke the given tool.
//
// The instances of this class are generated from `llvm_tools.bzl`, see that
// file for more details.
class LLVMTool : public CARBON_ENUM_BASE(LLVMTool) {
public:
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) \
CARBON_ENUM_CONSTANT_DECL(Identifier)
#include "toolchain/base/llvm_tools.def"
static const llvm::ArrayRef<LLVMTool> Tools;
using MainFnT = auto(int argc, char** argv, const llvm::ToolContext& context)
-> int;
using EnumBase::EnumBase;
auto bin_name() const -> llvm::StringLiteral { return BinNames[AsInt()]; }
auto main_fn() const -> MainFnT* { return MainFns[AsInt()]; }
auto subcommand_info() const -> const CommandLine::CommandInfo& {
return SubcommandInfos[AsInt()];
}
private:
static const LLVMTool ToolsStorage[];
static const llvm::StringLiteral BinNames[];
static MainFnT* const MainFns[];
static const CommandLine::CommandInfo SubcommandInfos[];
};
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) \
CARBON_ENUM_CONSTANT_DEFINITION(LLVMTool, Identifier)
#include "toolchain/base/llvm_tools.def"
inline constexpr LLVMTool LLVMTool::ToolsStorage[] = {
#define CARBON_LLVM_TOOL(Identifier, Name, BinName, MainFn) \
LLVMTool::Identifier,
#include "toolchain/base/llvm_tools.def"
};
inline constexpr llvm::ArrayRef<LLVMTool> LLVMTool::Tools = ToolsStorage;
} // namespace Carbon
#endif // CARBON_TOOLCHAIN_BASE_LLVM_TOOLS_H_