[PATCH] D47095: [clang-format/ObjC] Correctly parse Objective-C methods with 'class' in name
Ben Hamilton via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed May 23 08:49:36 PDT 2018
benhamilton added inline comments.
================
Comment at: lib/Format/UnwrappedLineParser.cpp:2137
+ do {
+ if (FormatTok->Tok.isOneOf(tok::semi, tok::r_brace)) {
+ nextToken();
----------------
jolesiak wrote:
> `tok::r_brace` could be skiped - see comment to line 2143.
Done.
================
Comment at: lib/Format/UnwrappedLineParser.cpp:2143
+ parseBlock(/*MustBeDeclaration=*/false);
+ addUnwrappedLine();
+ } else {
----------------
jolesiak wrote:
> We have to add `return` after `addUnwrappedLine` as `parseBlock` does consume `tok::r_brace`. Without `return` we will consume tokens after `}`. This problem will rarely occur as most lines end with `tok::semi` or `tok::r_brace` and it will be terminated properly (however maybe not handled properly as we just skip every token in `else`) by `if` branch.
>
> Test like:
> ```
> @implementation Foo
> - (foo)foo {
> }
> @end
> @implementation Bar
> - (bar)bar {
> }
> @end
> ```
> will distinguish version with `return` from one without. Therefore, I think we should add it.
Done, test added.
Repository:
rC Clang
https://reviews.llvm.org/D47095
More information about the cfe-commits
mailing list