[clang] New indent pp directives before hash with code (PR #186686)
Björn Schäpers via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 12:38:12 PDT 2026
================
@@ -1238,6 +1243,18 @@ void UnwrappedLineParser::parsePPUnknown() {
nextToken();
if (Style.IndentPPDirectives != FormatStyle::PPDIS_None)
Line->Level += PPBranchLevel + 1;
+ // For BeforeHashWithCode, PP directives inside unreachable branches must
+ // not be emitted: in multi-pass formatting the surrounding C++ braces may
+ // have been skipped (PP_Unreachable code is not parsed), leaving
+ // Line->Level too low. The resulting incorrect replacement would conflict
+ // with the correct one produced by the reachable pass, causing an
+ // "overlapping replacement" error and an empty output. Simply discard the
+ // accumulated tokens so the reachable pass wins.
----------------
HazardyKnusperkeks wrote:
I'd:
* Move the comment into the `if`
* Drop the For BefoeHashWithCode
And we don't to that double space after a full stop.
https://github.com/llvm/llvm-project/pull/186686
More information about the cfe-commits
mailing list