Clang allows continuations that have whitespace between the backslash and the newline. This patch ensures that the dependency source minimizer can handle the whitespace between the backslash and the newline when looking for a line continuation.
Details
- Reviewers
dexonsmith Bigcheese kousikk aganea - Commits
- rC373007: [clang-scan-deps] Allow continuation line backslashes followed by whitespace
rL373007: [clang-scan-deps] Allow continuation line backslashes followed by whitespace
rG15d5f5dd350e: [clang-scan-deps] Allow continuation line backslashes followed by whitespace in…
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
The code looks correct. I have some nitpicks about how the functions are named, but you don't need to go with my suggestions specifically.
clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp | ||
---|---|---|
247–248 | I don't love this name change, since the idea of the function is to take a "first, last" half-open range and reverse "last" back to exclude the spaces. "UntilFirstSpace" suggests that it would stop early and make the half-open range include a space. Of course it's all a bit weird because it's not returning a range, just the end of it. So the intent of both of these functions is to trim the trailing whitespace, it's just this one points at the beginning of the whitespace to serve as the end of the range, and the other one points at the last thing before the trailing whitespace. Perhaps we can be more explicit about what precisely is being returned, instead of describing intent. What about findFirstTrailingSpace? | |
258–264 | What about findLastNonSpace? |
clang/lib/Lex/DependencyDirectivesSourceMinimizer.cpp | ||
---|---|---|
247–248 | You might also reimplement this in terms of the other for clarity: static const char *findFirstTrailingSpace(const char *First, const char *Last) { const char *LastNonSpace = findLastNonSpace(First, Last); if (Last == LastNonSpace) return Last; assert(isHorizontalWhitespace(LastNonSpace[1])); return LastNonSpace + 1; } ... unless you think that will hurt performance. |
I don't love this name change, since the idea of the function is to take a "first, last" half-open range and reverse "last" back to exclude the spaces. "UntilFirstSpace" suggests that it would stop early and make the half-open range include a space.
Of course it's all a bit weird because it's not returning a range, just the end of it. So the intent of both of these functions is to trim the trailing whitespace, it's just this one points at the beginning of the whitespace to serve as the end of the range, and the other one points at the last thing before the trailing whitespace. Perhaps we can be more explicit about what precisely is being returned, instead of describing intent.
What about findFirstTrailingSpace?