Skip to content

Commit 476478a

Browse files
kuharaokblast
authored andcommitted
[ADT] Prepare for deprecation of StringSwitch cases with 4+ args. NFC. (llvm#164173)
Update `.Cases` and `.CasesLower` with 4+ args to use the `initializer_list` overload. The deprecation of these functions will come in a separate PR. For more context, see: llvm#163405.
1 parent ba29445 commit 476478a

File tree

19 files changed

+72
-68
lines changed

19 files changed

+72
-68
lines changed

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2665,8 +2665,9 @@ void RewriteInstance::readRelocations(const SectionRef &Section) {
26652665
return;
26662666
}
26672667
const bool SkipRelocs = StringSwitch<bool>(RelocatedSectionName)
2668-
.Cases(".plt", ".rela.plt", ".got.plt",
2669-
".eh_frame", ".gcc_except_table", true)
2668+
.Cases({".plt", ".rela.plt", ".got.plt",
2669+
".eh_frame", ".gcc_except_table"},
2670+
true)
26702671
.Default(false);
26712672
if (SkipRelocs) {
26722673
LLVM_DEBUG(

clang/lib/AST/Decl.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3380,11 +3380,11 @@ bool FunctionDecl::isMSVCRTEntryPoint() const {
33803380
return false;
33813381

33823382
return llvm::StringSwitch<bool>(getName())
3383-
.Cases("main", // an ANSI console app
3384-
"wmain", // a Unicode console App
3385-
"WinMain", // an ANSI GUI app
3386-
"wWinMain", // a Unicode GUI app
3387-
"DllMain", // a DLL
3383+
.Cases({"main", // an ANSI console app
3384+
"wmain", // a Unicode console App
3385+
"WinMain", // an ANSI GUI app
3386+
"wWinMain", // a Unicode GUI app
3387+
"DllMain"}, // a DLL
33883388
true)
33893389
.Default(false);
33903390
}

clang/lib/Basic/Targets/Mips.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,11 +68,11 @@ void MipsTargetInfo::fillValidCPUList(
6868

6969
unsigned MipsTargetInfo::getISARev() const {
7070
return llvm::StringSwitch<unsigned>(getCPU())
71-
.Cases("mips32", "mips64", 1)
72-
.Cases("mips32r2", "mips64r2", "octeon", "octeon+", 2)
73-
.Cases("mips32r3", "mips64r3", 3)
74-
.Cases("mips32r5", "mips64r5", "p5600", 5)
75-
.Cases("mips32r6", "mips64r6", "i6400", "i6500", 6)
71+
.Cases({"mips32", "mips64"}, 1)
72+
.Cases({"mips32r2", "mips64r2", "octeon", "octeon+"}, 2)
73+
.Cases({"mips32r3", "mips64r3"}, 3)
74+
.Cases({"mips32r5", "mips64r5", "p5600"}, 5)
75+
.Cases({"mips32r6", "mips64r6", "i6400", "i6500"}, 6)
7676
.Default(0);
7777
}
7878

clang/lib/Driver/ToolChains/Arch/Mips.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,9 +482,9 @@ bool mips::isFPXXDefault(const llvm::Triple &Triple, StringRef CPUName,
482482
return false;
483483

484484
return llvm::StringSwitch<bool>(CPUName)
485-
.Cases("mips2", "mips3", "mips4", "mips5", true)
486-
.Cases("mips32", "mips32r2", "mips32r3", "mips32r5", true)
487-
.Cases("mips64", "mips64r2", "mips64r3", "mips64r5", true)
485+
.Cases({"mips2", "mips3", "mips4", "mips5"}, true)
486+
.Cases({"mips32", "mips32r2", "mips32r3", "mips32r5"}, true)
487+
.Cases({"mips64", "mips64r2", "mips64r3", "mips64r5"}, true)
488488
.Default(false);
489489
}
490490

clang/lib/Driver/ToolChains/Darwin.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,15 @@ llvm::Triple::ArchType darwin::getArchTypeForMachOArchName(StringRef Str) {
5151
// translation.
5252

5353
return llvm::StringSwitch<llvm::Triple::ArchType>(Str)
54-
.Cases("i386", "i486", "i486SX", "i586", "i686", llvm::Triple::x86)
55-
.Cases("pentium", "pentpro", "pentIIm3", "pentIIm5", "pentium4",
54+
.Cases({"i386", "i486", "i486SX", "i586", "i686"}, llvm::Triple::x86)
55+
.Cases({"pentium", "pentpro", "pentIIm3", "pentIIm5", "pentium4"},
5656
llvm::Triple::x86)
57-
.Cases("x86_64", "x86_64h", llvm::Triple::x86_64)
57+
.Cases({"x86_64", "x86_64h"}, llvm::Triple::x86_64)
5858
// This is derived from the driver.
59-
.Cases("arm", "armv4t", "armv5", "armv6", "armv6m", llvm::Triple::arm)
60-
.Cases("armv7", "armv7em", "armv7k", "armv7m", llvm::Triple::arm)
61-
.Cases("armv7s", "xscale", llvm::Triple::arm)
62-
.Cases("arm64", "arm64e", llvm::Triple::aarch64)
59+
.Cases({"arm", "armv4t", "armv5", "armv6", "armv6m"}, llvm::Triple::arm)
60+
.Cases({"armv7", "armv7em", "armv7k", "armv7m"}, llvm::Triple::arm)
61+
.Cases({"armv7s", "xscale"}, llvm::Triple::arm)
62+
.Cases({"arm64", "arm64e"}, llvm::Triple::aarch64)
6363
.Case("arm64_32", llvm::Triple::aarch64_32)
6464
.Case("r600", llvm::Triple::r600)
6565
.Case("amdgcn", llvm::Triple::amdgcn)

clang/lib/Frontend/FrontendAction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ static std::error_code collectModuleHeaderIncludes(
629629
// Check whether this entry has an extension typically associated with
630630
// headers.
631631
if (!llvm::StringSwitch<bool>(llvm::sys::path::extension(Dir->path()))
632-
.Cases(".h", ".H", ".hh", ".hpp", true)
632+
.Cases({".h", ".H", ".hh", ".hpp"}, true)
633633
.Default(false))
634634
continue;
635635

clang/lib/Lex/PPLexerChange.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ void Preprocessor::diagnoseMissingHeaderInUmbrellaDir(const Module &Mod) {
302302
// Check whether this entry has an extension typically associated with
303303
// headers.
304304
if (!StringSwitch<bool>(llvm::sys::path::extension(Entry->path()))
305-
.Cases(".h", ".H", ".hh", ".hpp", true)
305+
.Cases({".h", ".H", ".hh", ".hpp"}, true)
306306
.Default(false))
307307
continue;
308308

clang/lib/Parse/ParsePragma.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,10 +1419,11 @@ bool Parser::HandlePragmaLoopHint(LoopHint &Hint) {
14191419

14201420
// Return a valid hint if pragma unroll or nounroll were specified
14211421
// without an argument.
1422-
auto IsLoopHint = llvm::StringSwitch<bool>(PragmaNameInfo->getName())
1423-
.Cases("unroll", "nounroll", "unroll_and_jam",
1424-
"nounroll_and_jam", true)
1425-
.Default(false);
1422+
auto IsLoopHint =
1423+
llvm::StringSwitch<bool>(PragmaNameInfo->getName())
1424+
.Cases({"unroll", "nounroll", "unroll_and_jam", "nounroll_and_jam"},
1425+
true)
1426+
.Default(false);
14261427

14271428
if (Toks.empty() && IsLoopHint) {
14281429
ConsumeAnnotationToken();

clang/lib/Sema/SemaChecking.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6926,13 +6926,13 @@ StringRef Sema::GetFormatStringTypeName(FormatStringType FST) {
69266926

69276927
FormatStringType Sema::GetFormatStringType(StringRef Flavor) {
69286928
return llvm::StringSwitch<FormatStringType>(Flavor)
6929-
.Cases("gnu_scanf", "scanf", FormatStringType::Scanf)
6930-
.Cases("gnu_printf", "printf", "printf0", "syslog",
6929+
.Cases({"gnu_scanf", "scanf"}, FormatStringType::Scanf)
6930+
.Cases({"gnu_printf", "printf", "printf0", "syslog"},
69316931
FormatStringType::Printf)
6932-
.Cases("NSString", "CFString", FormatStringType::NSString)
6933-
.Cases("gnu_strftime", "strftime", FormatStringType::Strftime)
6934-
.Cases("gnu_strfmon", "strfmon", FormatStringType::Strfmon)
6935-
.Cases("kprintf", "cmn_err", "vcmn_err", "zcmn_err",
6932+
.Cases({"NSString", "CFString"}, FormatStringType::NSString)
6933+
.Cases({"gnu_strftime", "strftime"}, FormatStringType::Strftime)
6934+
.Cases({"gnu_strfmon", "strfmon"}, FormatStringType::Strfmon)
6935+
.Cases({"kprintf", "cmn_err", "vcmn_err", "zcmn_err"},
69366936
FormatStringType::Kprintf)
69376937
.Case("freebsd_kprintf", FormatStringType::FreeBSDKPrintf)
69386938
.Case("os_trace", FormatStringType::OSLog)

clang/lib/Sema/SemaExpr.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12811,7 +12811,7 @@ QualType Sema::CheckCompareOperands(ExprResult &LHS, ExprResult &RHS,
1281112811
if (auto *CTSD = dyn_cast<ClassTemplateSpecializationDecl>(DC)) {
1281212812
if (CTSD->isInStdNamespace() &&
1281312813
llvm::StringSwitch<bool>(CTSD->getName())
12814-
.Cases("less", "less_equal", "greater", "greater_equal", true)
12814+
.Cases({"less", "less_equal", "greater", "greater_equal"}, true)
1281512815
.Default(false)) {
1281612816
if (RHSType->isNullPtrType())
1281712817
RHS = ImpCastExprToType(RHS.get(), LHSType, CK_NullToPointer);

0 commit comments

Comments
 (0)