[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 8 22:58:58 PST 2022
owenpan added inline comments.
================
Comment at: clang/lib/Format/UnwrappedLineParser.cpp:112
: Line(Line), TokenSource(TokenSource), ResetToken(ResetToken),
- PreviousLineLevel(Line.Level), PreviousTokenSource(TokenSource),
- Token(nullptr), PreviousToken(nullptr) {
+ PreviousLineLevel(Line.Level), PreviousLinePPLevel(Line.PPLevel),
+ PreviousTokenSource(TokenSource), Token(nullptr),
----------------
goldstein.w.n wrote:
> owenpan wrote:
> > Do you need to add `PreviousLinePPLevel` here? If yes, can you add test cases for it? Otherwise, you don't need to make any changes to `ScopedMacroState`.
> It's needed.
>
> Without:
> ```
> Expected equality of these values:
> Expected.str()
> Which is: "#ifndef foo\n#define foo\nif (emacs) {\n#ifdef is\n #define lit \\\n if (af) { \\\n return duh(); \\\n }\n#endif\n}\n#endif"
> format(test::messUp(Code), ObjCStyle)
> Which is: "#ifndef foo\n#define foo\nif (emacs) {\n#ifdef is\n #define lit \\\n if (af) { \\\n return duh(); \\\n }\n#endif\n}\n#endif"
> With diff:
> @@ -3,8 +3,8 @@
> if (emacs) {
> #ifdef is
> - #define lit \\
> - if (af) { \\
> - return duh(); \\
> - }
> + #define lit \\
> + if (af) { \\
> + return duh(); \\
> + }
> #endif
> }
> ```
I don't have to touch `ScopedMacroState`. Perhaps it has something to do with the way you set/adjust/use `PPLevel`.
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