sammccall added inline comments.
================ Comment at: clang/lib/Format/Format.cpp:1949 continue; + // Don't treat space in `void foo() &&` as evidence. + if (const auto *Prev = Tok->getPreviousNonComment()) { ---------------- benhamilton wrote: > Do we also need to worry about `T && foo();` style declarations? > A space before && in that case *should* trigger right-alignment. Are you concerned the exclusion here might fire? ================ Comment at: clang/lib/Format/Format.cpp:1951 + if (const auto *Prev = Tok->getPreviousNonComment()) { + if (Prev->is(tok::r_paren) && Prev->MatchingParen) + if (const auto *Func = Prev->MatchingParen->getPreviousNonComment()) ---------------- benhamilton wrote: > If this is parsing a general function declaration, I think it's not safe to > assume that the token immediately before the ref-spec is the close-paren. > > It looks like `Prev` can be a few other things, including at least: > > * `tok::kw_const` > * `tok::kw_volatile` > * `tok::kw_throw` > * `tok::kw_noexcept` > > and probably C++ attribute(s) as well: > > > noptr-declarator ( parameter-list ) cv(optional) ref(optional) > > except(optional) attr(optional) > > * https://en.cppreference.com/w/cpp/language/function > * https://en.cppreference.com/w/cpp/language/declarations > > I *think* they can also be in any order, so the ref-spec could come at the > very end after cv-qualifier, an expection specification, and C++ attributes. > const/volatile: a space between const and & does indicate right alignment. (And clang-format emits a space under PAS_Right) throw etc: these are not possible, there's no "in any order". Here's the grammar: http://eel.is/c++draft/dcl.decl.general#nt:parameters-and-qualifiers Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D118921/new/ https://reviews.llvm.org/D118921 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits