diff --git a/clang/lib/Format/UnwrappedLineFormatter.cpp b/clang/lib/Format/UnwrappedLineFormatter.cpp --- a/clang/lib/Format/UnwrappedLineFormatter.cpp +++ b/clang/lib/Format/UnwrappedLineFormatter.cpp @@ -101,30 +101,26 @@ Style.isCSharp()) return 0; - auto isAccessModifier = [this, &RootToken]() { - bool returnValue{false}; - if (RootToken.isAccessSpecifier(Style.isCpp())) { - returnValue = true; - } else if (RootToken.isObjCAccessSpecifier()) { - returnValue = true; - } + auto IsAccessModifier = [this, &RootToken]() { + if (RootToken.isAccessSpecifier(Style.isCpp())) + return true; + else if (RootToken.isObjCAccessSpecifier()) + return true; // Handle Qt signals else if ((RootToken.isOneOf(Keywords.kw_signals, Keywords.kw_qsignals) && - RootToken.Next && RootToken.Next->is(tok::colon))) { - returnValue = true; - } + RootToken.Next && RootToken.Next->is(tok::colon))) + return true; // Handle malformed access specifier i.e. 'private' without trailing ':' else if ((RootToken.isAccessSpecifier(false) && (!RootToken.Next || - (C_OperatorsFollowingVar.find(RootToken.Next->Tok.getKind()) == - clang::format::C_OperatorsFollowingVar.end() && - !RootToken.Next->Tok.is(tok::coloncolon))))) { - returnValue = true; - } - return returnValue; + (!C_OperatorsFollowingVar.count( + RootToken.Next->Tok.getKind()) && + !RootToken.Next->Tok.is(tok::coloncolon))))) + return true; + return false; }; - if (isAccessModifier()) { + if (IsAccessModifier()) { // The AccessModifierOffset may be overridden by IndentAccessModifiers, // in which case we take a negative value of the IndentWidth to simulate // the upper indent level. diff --git a/clang/lib/Format/UnwrappedLineParser.cpp b/clang/lib/Format/UnwrappedLineParser.cpp --- a/clang/lib/Format/UnwrappedLineParser.cpp +++ b/clang/lib/Format/UnwrappedLineParser.cpp @@ -2494,7 +2494,7 @@ } void UnwrappedLineParser::parseAccessSpecifier() { - auto *accessSpecifierCandidate = FormatTok; + auto *AccessSpecifierCandidate = FormatTok; nextToken(); // Understand Qt's slots. if (FormatTok->isOneOf(Keywords.kw_slots, Keywords.kw_qslots)) @@ -2504,15 +2504,12 @@ nextToken(); addUnwrappedLine(); // is not a variable name or namespacename - } else if (C_OperatorsFollowingVar.find(FormatTok->Tok.getKind()) == - C_OperatorsFollowingVar.end() && - !FormatTok->Tok.is(tok::coloncolon)) { + } else if (!C_OperatorsFollowingVar.count(FormatTok->Tok.getKind()) && + !FormatTok->Tok.is(tok::coloncolon)) addUnwrappedLine(); - } // consider the accessSpecifier to be a C identifier - else if (accessSpecifierCandidate) { - accessSpecifierCandidate->Tok.setKind(tok::identifier); - } + else if (AccessSpecifierCandidate) + AccessSpecifierCandidate->Tok.setKind(tok::identifier); } void UnwrappedLineParser::parseConcept() {