|
23 | 23 | #include "clang/Sema/Initialization.h" |
24 | 24 | #include "clang/Sema/Sema.h" |
25 | 25 |
|
| 26 | +#include "llvm/ADT/StringSwitch.h" |
| 27 | + |
26 | 28 | namespace clang { |
27 | 29 |
|
28 | 30 | static CountAttributedType::DynamicCountPointerKind |
@@ -334,15 +336,13 @@ static void EmitIncompleteCountedByPointeeNotes(Sema &S, |
334 | 336 | SourceRange AttrSrcRange = CATL.getAttrNameRange(S); |
335 | 337 |
|
336 | 338 | 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(""); |
346 | 346 | FixItHint Fix; |
347 | 347 | if (!FixedSpelling.empty()) |
348 | 348 | Fix = FixItHint::CreateReplacement(AttrSrcRange, FixedSpelling); |
|
0 commit comments