Index: lib/Format/TokenAnnotator.cpp =================================================================== --- lib/Format/TokenAnnotator.cpp +++ lib/Format/TokenAnnotator.cpp @@ -1165,33 +1165,41 @@ Tok.Previous->is(Keywords.kw_in)) return false; - // Skip "const" as it does not have an influence on whether this is a name. - FormatToken *PreviousNotConst = Tok.Previous; - while (PreviousNotConst && PreviousNotConst->is(tok::kw_const)) - PreviousNotConst = PreviousNotConst->Previous; - - if (!PreviousNotConst) + // Skip "const" and comment as it does not have an influence on whether + // this is a name. + FormatToken *PreviousNotConstNorComment = Tok.Previous; + while (PreviousNotConstNorComment && + PreviousNotConstNorComment->isOneOf(tok::kw_const, tok::comment)) + PreviousNotConstNorComment = PreviousNotConstNorComment->Previous; + + if (!PreviousNotConstNorComment) return false; - bool IsPPKeyword = PreviousNotConst->is(tok::identifier) && - PreviousNotConst->Previous && - PreviousNotConst->Previous->is(tok::hash); - - if (PreviousNotConst->is(TT_TemplateCloser)) - return PreviousNotConst && PreviousNotConst->MatchingParen && - PreviousNotConst->MatchingParen->Previous && - PreviousNotConst->MatchingParen->Previous->isNot(tok::period) && - PreviousNotConst->MatchingParen->Previous->isNot(tok::kw_template); - - if (PreviousNotConst->is(tok::r_paren) && PreviousNotConst->MatchingParen && - PreviousNotConst->MatchingParen->Previous && - PreviousNotConst->MatchingParen->Previous->is(tok::kw_decltype)) + bool IsPPKeyword = PreviousNotConstNorComment->is(tok::identifier) && + PreviousNotConstNorComment->Previous && + PreviousNotConstNorComment->Previous->is(tok::hash); + + if (PreviousNotConstNorComment->is(TT_TemplateCloser)) + return PreviousNotConstNorComment && + PreviousNotConstNorComment->MatchingParen && + PreviousNotConstNorComment->MatchingParen->Previous && + PreviousNotConstNorComment->MatchingParen->Previous->isNot( + tok::period) && + PreviousNotConstNorComment->MatchingParen->Previous->isNot( + tok::kw_template); + + if (PreviousNotConstNorComment->is(tok::r_paren) && + PreviousNotConstNorComment->MatchingParen && + PreviousNotConstNorComment->MatchingParen->Previous && + PreviousNotConstNorComment->MatchingParen->Previous->is( + tok::kw_decltype)) return true; return (!IsPPKeyword && - PreviousNotConst->isOneOf(tok::identifier, tok::kw_auto)) || - PreviousNotConst->is(TT_PointerOrReference) || - PreviousNotConst->isSimpleTypeSpecifier(); + PreviousNotConstNorComment->isOneOf(tok::identifier, + tok::kw_auto)) || + PreviousNotConstNorComment->is(TT_PointerOrReference) || + PreviousNotConstNorComment->isSimpleTypeSpecifier(); } /// \brief Determine whether ')' is ending a cast.