Skip to content

Commit 5714f4d

Browse files
Use Overload of lookupTarget Accepting Triple (#6205)
The overload accepting a string/llvm::StringRef is deprecated and will be removed when LLVM 22 branches.
1 parent 6d9ee96 commit 5714f4d

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

toolchain/codegen/codegen.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,12 @@ namespace Carbon {
1919

2020
auto CodeGen::Make(llvm::Module* module, llvm::StringRef target_triple_str,
2121
Diagnostics::Consumer* consumer) -> std::optional<CodeGen> {
22+
llvm::Triple target_triple(target_triple_str);
2223
std::string error;
2324
const llvm::Target* target =
24-
llvm::TargetRegistry::lookupTarget(target_triple_str, error);
25+
llvm::TargetRegistry::lookupTarget(target_triple, error);
2526
CARBON_CHECK(target, "Target should be validated before codegen: {0}", error);
2627

27-
llvm::Triple target_triple(target_triple_str);
2828
module->setTargetTriple(target_triple);
2929

3030
constexpr llvm::StringLiteral CPU = "generic";

toolchain/driver/compile_subcommand.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -885,7 +885,7 @@ auto CompileSubcommand::Run(DriverEnv& driver_env) -> DriverResult {
885885
// Validate the target before passing it to Clang.
886886
std::string target_error;
887887
const llvm::Target* target = llvm::TargetRegistry::lookupTarget(
888-
options_.codegen_options.target, target_error);
888+
llvm::Triple(options_.codegen_options.target), target_error);
889889
if (!target) {
890890
CARBON_DIAGNOSTIC(CompileTargetInvalid, Error, "invalid target: {0}",
891891
std::string);

0 commit comments

Comments
 (0)