[PATCH] D137181: [clang-format] Don't use 'PPIndentWidth' inside multi-line macros
Owen Pan via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 15 00:44:07 PST 2022
owenpan added a comment.
In D137181#3924002 <https://reviews.llvm.org/D137181#3924002>, @sstwcw wrote:
> Can you make `TokenAnnotator::printDebugInfo` print `PPLevel`?
@goldstein.w.n can you add it as follows?
$ git diff TokenAnnotator.cpp
diff --git a/clang/lib/Format/TokenAnnotator.cpp b/clang/lib/Format/TokenAnnotator.cpp
index 75570552146c..536472e9d136 100644
--- a/clang/lib/Format/TokenAnnotator.cpp
+++ b/clang/lib/Format/TokenAnnotator.cpp
@@ -5093,8 +5093,9 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line,
}
void TokenAnnotator::printDebugInfo(const AnnotatedLine &Line) const {
- llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", T=" << Line.Type
- << ", C=" << Line.IsContinuation << "):\n";
+ llvm::errs() << "AnnotatedTokens(L=" << Line.Level << ", P=" << Line.PPLevel
+ << ", T=" << Line.Type << ", C=" << Line.IsContinuation
+ << "):\n";
const FormatToken *Tok = Line.First;
while (Tok) {
llvm::errs() << " M=" << Tok->MustBreakBefore
> Since you changed the rules for indentation in `UnwrappedLineFormatter`, do you also need to change `UnwrappedLineParser::mightFitOnOneLine`?
`mightFitOnOneLine` is not called on PPDirective lines, but it's a good idea to add an assertion.
================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:836
}
return Line.Level * Style.IndentWidth + Length <= ColumnLimit;
----------------
We don't call `mightFitOnOneLine` on PPDirective lines.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137181/new/
https://reviews.llvm.org/D137181
More information about the cfe-commits
mailing list