HomePhabricator

Allow any comment to be a trailing comment when -fparse-all-comments is on.

Description

Allow any comment to be a trailing comment when -fparse-all-comments is on.

This helps with freeform documentation styles, where otherwise code like

enum class E {
  E1,  // D1
  E2   // D2
};

would result in D1 being associated with E2. To properly associate E1
with D1 and E2 with D2, this patch allows all raw comments C such that
C.isParseAllComments() to participate in trailing comment checks inside
getRawCommentForDeclNoCache. This takes care of linking the intended
documentation with the intended decls. There remains an issue with code
like:

foo();  // DN
int x;

To prevent DN from being associated with x, this patch adds a new test
on preceding-line comments C (where C.isParseAllComments() and also
C's kind is RCK_OrdinaryBCPL or RCK_OrdinaryC) that checks whether C
is the first non-whitespace thing on C's starting line.

Patch from Luke Zarko <zarko@google.com>, D11069 reviewed by rsmith.

Details

Committed
jdennettJul 15 2015, 12:13 PM
Parents
rL242316: clang-format: Fix return type breaking with overloaded operator functions
Branches
Unknown
Tags
Unknown