Skip to content

Commit aef6bc4

Browse files
committed
if-else -> StringSwitch
1 parent f38fc71 commit aef6bc4

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

clang/lib/Sema/SemaBoundsSafety.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include "clang/Sema/Initialization.h"
2424
#include "clang/Sema/Sema.h"
2525

26+
#include "llvm/ADT/StringSwitch.h"
27+
2628
namespace clang {
2729

2830
static CountAttributedType::DynamicCountPointerKind
@@ -334,15 +336,13 @@ static void EmitIncompleteCountedByPointeeNotes(Sema &S,
334336
SourceRange AttrSrcRange = CATL.getAttrNameRange(S);
335337

336338
StringRef Spelling = CATL.getAttrNameAsWritten(S);
337-
StringRef FixedSpelling;
338-
if (Spelling == "__counted_by")
339-
FixedSpelling = "__sized_by";
340-
else if (Spelling == "counted_by")
341-
FixedSpelling = "sized_by";
342-
else if (Spelling == "__counted_by_or_null")
343-
FixedSpelling = "__sized_by_or_null";
344-
else if (Spelling == "counted_by_or_null")
345-
FixedSpelling = "sized_by_or_null";
339+
StringRef FixedSpelling =
340+
llvm::StringSwitch<StringRef>(Spelling)
341+
.Case("__counted_by", "__sized_by")
342+
.Case("counted_by", "sized_by")
343+
.Case("__counted_by_or_null", "__sized_by_or_null")
344+
.Case("counted_by_or_null", "sized_by_or_null")
345+
.Default("");
346346
FixItHint Fix;
347347
if (!FixedSpelling.empty())
348348
Fix = FixItHint::CreateReplacement(AttrSrcRange, FixedSpelling);

0 commit comments

Comments
 (0)