diff options
Diffstat (limited to 'contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp')
-rw-r--r-- | contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp | 35 |
1 files changed, 18 insertions, 17 deletions
diff --git a/contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp b/contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp index a3d388a5ae44..d5bf553e2412 100644 --- a/contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp +++ b/contrib/llvm-project/clang/lib/Edit/RewriteObjCFoundationAPI.cpp @@ -18,6 +18,7 @@ #include "clang/AST/ParentMap.h" #include "clang/Edit/Commit.h" #include "clang/Lex/Lexer.h" +#include <optional> using namespace clang; using namespace edit; @@ -642,7 +643,7 @@ static bool shouldNotRewriteImmediateMessageArgs(const ObjCMessageExpr *Msg, static bool rewriteToCharLiteral(const ObjCMessageExpr *Msg, const CharacterLiteral *Arg, const NSAPI &NS, Commit &commit) { - if (Arg->getKind() != CharacterLiteral::Ascii) + if (Arg->getKind() != CharacterLiteralKind::Ascii) return false; if (NS.isNSNumberLiteralSelector(NSAPI::NSNumberWithChar, Msg->getSelector())) { @@ -691,12 +692,12 @@ static bool getLiteralInfo(SourceRange literalRange, if (text.empty()) return false; - Optional<bool> UpperU, UpperL; + std::optional<bool> UpperU, UpperL; bool UpperF = false; struct Suff { static bool has(StringRef suff, StringRef &text) { - if (text.endswith(suff)) { + if (text.ends_with(suff)) { text = text.substr(0, text.size()-suff.size()); return true; } @@ -704,7 +705,7 @@ static bool getLiteralInfo(SourceRange literalRange, } }; - while (1) { + while (true) { if (Suff::has("u", text)) { UpperU = false; } else if (Suff::has("U", text)) { @@ -725,11 +726,11 @@ static bool getLiteralInfo(SourceRange literalRange, break; } - if (!UpperU.hasValue() && !UpperL.hasValue()) + if (!UpperU && !UpperL) UpperU = UpperL = true; - else if (UpperU.hasValue() && !UpperL.hasValue()) + else if (UpperU && !UpperL) UpperL = UpperU; - else if (UpperL.hasValue() && !UpperU.hasValue()) + else if (UpperL && !UpperU) UpperU = UpperL; Info.U = *UpperU ? "U" : "u"; @@ -738,9 +739,9 @@ static bool getLiteralInfo(SourceRange literalRange, Info.F = UpperF ? "F" : "f"; Info.Hex = Info.Octal = false; - if (text.startswith("0x")) + if (text.starts_with("0x")) Info.Hex = true; - else if (!isFloat && !isIntZero && text.startswith("0")) + else if (!isFloat && !isIntZero && text.starts_with("0")) Info.Octal = true; SourceLocation B = literalRange.getBegin(); @@ -775,8 +776,8 @@ static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg, ASTContext &Ctx = NS.getASTContext(); Selector Sel = Msg->getSelector(); - Optional<NSAPI::NSNumberLiteralMethodKind> - MKOpt = NS.getNSNumberLiteralMethodKind(Sel); + std::optional<NSAPI::NSNumberLiteralMethodKind> MKOpt = + NS.getNSNumberLiteralMethodKind(Sel); if (!MKOpt) return false; NSAPI::NSNumberLiteralMethodKind MK = *MKOpt; @@ -796,28 +797,28 @@ static bool rewriteToNumberLiteral(const ObjCMessageExpr *Msg, case NSAPI::NSNumberWithUnsignedInt: case NSAPI::NSNumberWithUnsignedInteger: CallIsUnsigned = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case NSAPI::NSNumberWithInt: case NSAPI::NSNumberWithInteger: break; case NSAPI::NSNumberWithUnsignedLong: CallIsUnsigned = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case NSAPI::NSNumberWithLong: CallIsLong = true; break; case NSAPI::NSNumberWithUnsignedLongLong: CallIsUnsigned = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case NSAPI::NSNumberWithLongLong: CallIsLongLong = true; break; case NSAPI::NSNumberWithDouble: CallIsDouble = true; - LLVM_FALLTHROUGH; + [[fallthrough]]; case NSAPI::NSNumberWithFloat: CallIsFloating = true; break; @@ -983,8 +984,8 @@ static bool rewriteToNumericBoxedExpression(const ObjCMessageExpr *Msg, ASTContext &Ctx = NS.getASTContext(); Selector Sel = Msg->getSelector(); - Optional<NSAPI::NSNumberLiteralMethodKind> - MKOpt = NS.getNSNumberLiteralMethodKind(Sel); + std::optional<NSAPI::NSNumberLiteralMethodKind> MKOpt = + NS.getNSNumberLiteralMethodKind(Sel); if (!MKOpt) return false; NSAPI::NSNumberLiteralMethodKind MK = *MKOpt; |