[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos
Sam McCall via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Mar 23 07:30:43 PDT 2018
sammccall added a comment.
I'm not familiar with clang-format internals, sorry if questions are dumb.
My first inclination is that doing something reasonable for incomplete inputs makes sense, but it doesn't seem to be worth spending complexity on things that are actually intended to not be protos - people should just not use R"pb in this case.
I recall you had a reason for wanting to try this out anyway though, but I can't remember what it is. (Can you add it to the description?)
================
Comment at: lib/Format/TokenAnnotator.cpp:665
}
+ if ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
----------------
I don't really understand what this is doing.
It seems to be detecting some particular sequence of invalid tokens `}:`,`]:`,`>:`. Why are these special?
What's the contract of consumeToken()? It's hard to see from the callsites.
================
Comment at: lib/Format/TokenAnnotator.cpp:773
case tok::r_brace:
- // Lines can start with '}'.
- if (Tok->Previous)
+ // Lines can start with '}' except in text protos.
+ if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
----------------
In what sense of "line" is this true?
Repository:
rC Clang
https://reviews.llvm.org/D44203
More information about the cfe-commits
mailing list