Use Overload of lookupTarget Accepting Triple (#6205)

The overload accepting a string/llvm::StringRef is deprecated and will
be removed when LLVM 22 branches.
This commit is contained in:
Aiden Grossman
2025-10-13 18:52:49 +00:00
committed by GitHub
parent 6d9ee96584
commit 5714f4deb2
2 changed files with 3 additions and 3 deletions
+2 -2
View File
@@ -19,12 +19,12 @@ namespace Carbon {
auto CodeGen::Make(llvm::Module* module, llvm::StringRef target_triple_str, auto CodeGen::Make(llvm::Module* module, llvm::StringRef target_triple_str,
Diagnostics::Consumer* consumer) -> std::optional<CodeGen> { Diagnostics::Consumer* consumer) -> std::optional<CodeGen> {
llvm::Triple target_triple(target_triple_str);
std::string error; std::string error;
const llvm::Target* target = const llvm::Target* target =
llvm::TargetRegistry::lookupTarget(target_triple_str, error); llvm::TargetRegistry::lookupTarget(target_triple, error);
CARBON_CHECK(target, "Target should be validated before codegen: {0}", error); CARBON_CHECK(target, "Target should be validated before codegen: {0}", error);
llvm::Triple target_triple(target_triple_str);
module->setTargetTriple(target_triple); module->setTargetTriple(target_triple);
constexpr llvm::StringLiteral CPU = "generic"; constexpr llvm::StringLiteral CPU = "generic";
+1 -1
View File
@@ -885,7 +885,7 @@ auto CompileSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
// Validate the target before passing it to Clang. // Validate the target before passing it to Clang.
std::string target_error; std::string target_error;
const llvm::Target* target = llvm::TargetRegistry::lookupTarget( const llvm::Target* target = llvm::TargetRegistry::lookupTarget(
options_.codegen_options.target, target_error); llvm::Triple(options_.codegen_options.target), target_error);
if (!target) { if (!target) {
CARBON_DIAGNOSTIC(CompileTargetInvalid, Error, "invalid target: {0}", CARBON_DIAGNOSTIC(CompileTargetInvalid, Error, "invalid target: {0}",
std::string); std::string);