From: Daniel Jasper Date: Fri, 31 Mar 2017 13:30:24 +0000 (+0000) Subject: clang-format: Fix post-commit review comment of r299204, use Style.isCpp(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b8297df0f95fdc4fadc80712d288efd62fbc722a;p=clang clang-format: Fix post-commit review comment of r299204, use Style.isCpp(). Also, while at it, s/IsCpp/isCpp/ so that it follows LLVM style. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@299214 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/Format/Format.h b/include/clang/Format/Format.h index 27c913f07c..47eacb50a3 100644 --- a/include/clang/Format/Format.h +++ b/include/clang/Format/Format.h @@ -963,7 +963,7 @@ struct FormatStyle { /// Should be used for TableGen code. LK_TableGen }; - bool IsCpp() const { return Language == LK_Cpp || Language == LK_ObjC; } + bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; } /// \brief Language, this format style is targeted at. LanguageKind Language; diff --git a/lib/Format/ContinuationIndenter.cpp b/lib/Format/ContinuationIndenter.cpp index 5ae8839b34..c3f386bd67 100644 --- a/lib/Format/ContinuationIndenter.cpp +++ b/lib/Format/ContinuationIndenter.cpp @@ -158,7 +158,7 @@ bool ContinuationIndenter::mustBreak(const LineState &State) { return true; if ((startsNextParameter(Current, Style) || Previous.is(tok::semi) || (Previous.is(TT_TemplateCloser) && Current.is(TT_StartOfName) && - Style.IsCpp() && + Style.isCpp() && // FIXME: This is a temporary workaround for the case where clang-format // sets BreakBeforeParameter to avoid bin packing and this creates a // completely unnecessary line break after a template type that isn't @@ -605,7 +605,7 @@ unsigned ContinuationIndenter::addTokenOnNewLine(LineState &State, // Any break on this level means that the parent level has been broken // and we need to avoid bin packing there. bool NestedBlockSpecialCase = - !Style.IsCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 && + !Style.isCpp() && Current.is(tok::r_brace) && State.Stack.size() > 1 && State.Stack[State.Stack.size() - 2].NestedBlockInlined; if (!NestedBlockSpecialCase) for (unsigned i = 0, e = State.Stack.size() - 1; i != e; ++i) diff --git a/lib/Format/Format.cpp b/lib/Format/Format.cpp index 9bb2a97ce5..27f5849b39 100644 --- a/lib/Format/Format.cpp +++ b/lib/Format/Format.cpp @@ -1671,7 +1671,7 @@ bool isDeletedHeader(llvm::StringRef HeaderName, tooling::Replacements fixCppIncludeInsertions(StringRef Code, const tooling::Replacements &Replaces, const FormatStyle &Style) { - if (!Style.IsCpp()) + if (!Style.isCpp()) return Replaces; tooling::Replacements HeaderInsertions; @@ -1895,7 +1895,7 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) { LangOpts.CPlusPlus11 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.CPlusPlus14 = Style.Standard == FormatStyle::LS_Cpp03 ? 0 : 1; LangOpts.LineComment = 1; - bool AlternativeOperators = Style.IsCpp(); + bool AlternativeOperators = Style.isCpp(); LangOpts.CXXOperatorNames = AlternativeOperators ? 1 : 0; LangOpts.Bool = 1; LangOpts.ObjC1 = 1; diff --git a/lib/Format/FormatTokenLexer.cpp b/lib/Format/FormatTokenLexer.cpp index 90b80a4544..91c9af005a 100644 --- a/lib/Format/FormatTokenLexer.cpp +++ b/lib/Format/FormatTokenLexer.cpp @@ -560,7 +560,7 @@ FormatToken *FormatTokenLexer::getNextToken() { Column = FormatTok->LastLineColumnWidth; } - if (Style.IsCpp()) { + if (Style.isCpp()) { if (!(Tokens.size() > 0 && Tokens.back()->Tok.getIdentifierInfo() && Tokens.back()->Tok.getIdentifierInfo()->getPPKeywordID() == tok::pp_define) && diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 043d83df50..fe7e419271 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -311,13 +311,13 @@ private: // In C++, this can happen either in array of templates (foo[10]) // or when array is a nested template type (unique_ptr[]>). bool CppArrayTemplates = - Style.IsCpp() && Parent && + Style.isCpp() && Parent && Parent->is(TT_TemplateCloser) && (Contexts.back().CanBeExpression || Contexts.back().IsExpression || Contexts.back().InTemplateArgument); bool StartsObjCMethodExpr = - !CppArrayTemplates && Style.IsCpp() && + !CppArrayTemplates && Style.isCpp() && Contexts.back().CanBeExpression && Left->isNot(TT_LambdaLSquare) && CurrentToken->isNot(tok::l_brace) && (!Parent || @@ -435,7 +435,7 @@ private: if (CurrentToken->isOneOf(tok::colon, tok::l_brace)) { FormatToken *Previous = CurrentToken->getPreviousNonComment(); if (((CurrentToken->is(tok::colon) && - (!Contexts.back().ColonIsDictLiteral || !Style.IsCpp())) || + (!Contexts.back().ColonIsDictLiteral || !Style.isCpp())) || Style.Language == FormatStyle::LK_Proto) && (Previous->Tok.getIdentifierInfo() || Previous->is(tok::string_literal))) @@ -1220,7 +1220,7 @@ private: /// \brief Determine whether ')' is ending a cast. bool rParenEndsCast(const FormatToken &Tok) { // C-style casts are only used in C++ and Java. - if (!Style.IsCpp() && Style.Language != FormatStyle::LK_Java) + if (!Style.isCpp() && Style.Language != FormatStyle::LK_Java) return false; // Empty parens aren't casts and there are no casts at the end of the line. @@ -2233,7 +2233,7 @@ bool TokenAnnotator::spaceRequiredBefore(const AnnotatedLine &Line, const FormatToken &Left = *Right.Previous; if (Right.Tok.getIdentifierInfo() && Left.Tok.getIdentifierInfo()) return true; // Never ever merge two identifiers. - if (Style.IsCpp()) { + if (Style.isCpp()) { if (Left.is(tok::kw_operator)) return Right.is(tok::coloncolon); } else if (Style.Language == FormatStyle::LK_Proto) { diff --git a/lib/Format/UnwrappedLineParser.cpp b/lib/Format/UnwrappedLineParser.cpp index a0354a32a8..5be68ad5c6 100644 --- a/lib/Format/UnwrappedLineParser.cpp +++ b/lib/Format/UnwrappedLineParser.cpp @@ -916,8 +916,7 @@ void UnwrappedLineParser::parseStructuralElement() { return; } } - if ((Style.Language == FormatStyle::LK_Cpp || - Style.Language == FormatStyle::LK_ObjC) && + if (Style.isCpp() && FormatTok->isOneOf(Keywords.kw_signals, Keywords.kw_qsignals, Keywords.kw_slots, Keywords.kw_qslots)) { nextToken(); @@ -952,7 +951,7 @@ void UnwrappedLineParser::parseStructuralElement() { if (!parseEnum()) break; // This only applies for C++. - if (!Style.IsCpp()) { + if (!Style.isCpp()) { addUnwrappedLine(); return; } @@ -1133,7 +1132,7 @@ void UnwrappedLineParser::parseStructuralElement() { } bool UnwrappedLineParser::tryToParseLambda() { - if (!Style.IsCpp()) { + if (!Style.isCpp()) { nextToken(); return false; } @@ -1743,7 +1742,7 @@ bool UnwrappedLineParser::parseEnum() { nextToken(); // If there are two identifiers in a row, this is likely an elaborate // return type. In Java, this can be "implements", etc. - if (Style.IsCpp() && FormatTok->is(tok::identifier)) + if (Style.isCpp() && FormatTok->is(tok::identifier)) return false; } }