https://github.com/AdityaSinha149 updated https://github.com/llvm/llvm-project/pull/238231
>From 84866ac0c5ce03093974095715a2104240db521d Mon Sep 17 00:00:00 2001 From: AdityaSinha149 <[email protected]> Date: Tue, 3 Nov 2026 12:28:30 +0530 Subject: [PATCH] [NFC][clang][Driver] Changed if-else to a StringSwitch in CreateFileHandler --- clang/lib/Driver/OffloadBundler.cpp | 23 +++++------------------ 1 file changed, 5 insertions(+), 18 deletions(-) diff --git a/clang/lib/Driver/OffloadBundler.cpp b/clang/lib/Driver/OffloadBundler.cpp index 1989bc6631fdeb..38981e27150c02 100644 --- a/clang/lib/Driver/OffloadBundler.cpp +++ b/clang/lib/Driver/OffloadBundler.cpp @@ -912,32 +912,19 @@ CreateFileHandler(MemoryBuffer &FirstInput, const OffloadBundlerConfig &BundlerConfig) { std::string FilesType = BundlerConfig.FilesType; - if (FilesType == "i") - return std::make_unique<TextFileHandler>(/*Comment=*/"//"); - if (FilesType == "ii") - return std::make_unique<TextFileHandler>(/*Comment=*/"//"); - if (FilesType == "cui") - return std::make_unique<TextFileHandler>(/*Comment=*/"//"); - if (FilesType == "hipi") + if (FilesType == "i" || FilesType == "ii" || FilesType == "cui" || + FilesType == "hipi") return std::make_unique<TextFileHandler>(/*Comment=*/"//"); // TODO: `.d` should be eventually removed once `-M` and its variants are // handled properly in offload compilation. - if (FilesType == "d") + if (FilesType == "d" || FilesType == "s") return std::make_unique<TextFileHandler>(/*Comment=*/"#"); if (FilesType == "ll") return std::make_unique<TextFileHandler>(/*Comment=*/";"); - if (FilesType == "bc") + if (FilesType == "bc" || FilesType == "gch" || FilesType == "ast") return std::make_unique<BinaryFileHandler>(BundlerConfig); - if (FilesType == "s") - return std::make_unique<TextFileHandler>(/*Comment=*/"#"); - if (FilesType == "o") + if (FilesType == "o" || FilesType == "a") return CreateObjectFileHandler(FirstInput, BundlerConfig); - if (FilesType == "a") - return CreateObjectFileHandler(FirstInput, BundlerConfig); - if (FilesType == "gch") - return std::make_unique<BinaryFileHandler>(BundlerConfig); - if (FilesType == "ast") - return std::make_unique<BinaryFileHandler>(BundlerConfig); return createStringError(errc::invalid_argument, "'" + FilesType + "': invalid file type specified"); _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
