[PATCH] D25153: preprocessor supports `-dI` flag
Steve O'Brien via cfe-commits
cfe-commits at lists.llvm.org
Wed Oct 5 18:15:30 PDT 2016
elsteveogrande marked an inline comment as done.
elsteveogrande added inline comments.
> majnemer wrote in PrintPreprocessedOutput.cpp:331-349
> I think this loop would be easier to understand like so:
>
> while (!Path.empty()) {
> if (Path.consume_front("\\")) {
> Buffer.push_back("\\\\");
> } else if (Path.consume_front("\"")) {
> Buffer.push_back("\\\"");
> } else if (Path.consume_front("*/")) {
> Buffer.push_back("*\\/");
> } else {
> Buffer.push_back(Path.front());
> Path = Path.drop_front();
> }
> }
>
> The big takeaway is that we now avoid messy `I + 1 < N` type checks.
yes! I like this much better, thanks. Didn't know about that method, very handy.
Also at the risk of changing more stuff and possibly churning more (thank you for sticking with me this long!) I'll change it to use either a `std::stringstream`, or `std::string` with `operator+=` to build it up.
A `std::vector<char>` won't take additional strings `push_back`'ed like that, and while it's more handy than `char[]`, it's slightly weird, when this is stringstream's purpose, imho.
https://reviews.llvm.org/D25153
More information about the cfe-commits
mailing list