[clang] New indent pp directives before hash with code (PR #186686)
Guy Turcotte via cfe-commits
cfe-commits at lists.llvm.org
Sun Mar 15 13:31:02 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.
----------------
turgu1 wrote:
Done
https://github.com/llvm/llvm-project/pull/186686
More information about the cfe-commits
mailing list