================
@@ -4651,7 +4697,27 @@ void UnwrappedLineParser::addUnwrappedLine(LineLevel 
AdjustLevel) {
     // At the top level we only get here when no unexpansion is going on, or
     // when conditional formatting led to unfinished macro reconstructions.
     assert(!Reconstruct || (CurrentLines != &Lines) || !PPStack.empty());
+    // For BeforeHashWithCode, code lines inside PP conditional blocks must be
+    // indented by the PP nesting depth so that code appears more indented than
+    // its enclosing PP directive (mirroring how C++ block content is indented
+    // relative to the opening brace). PP directive lines already have
+    // PPBranchLevel+1 added in parsePPUnknown; code lines need the same
+    // treatment. We temporarily adjust Level here and restore it afterwards so
+    // that the next line still starts from the correct C++ brace level.
+    // For BeforeHashWithCode, code lines inside PP blocks need their level
+    // raised to match the enclosing PP directive's nesting depth. Using
+    // Line->PPLevel (set at first-token push time) instead of the current
+    // PPBranchLevel, which may have been altered by later PP directives that
+    // readToken processed after the code tokens but before addUnwrappedLine.
+    const bool BWHCCodeLine =
+        Style.IndentPPDirectives == FormatStyle::PPDIS_BeforeHashWithCode &&
+        !Line->InPPDirective && Line->PPLevel > 0;
+    const unsigned PPAdj = BWHCCodeLine ? Line->PPLevel : 0;
----------------
turgu1 wrote:

You comment is about the BWHCCodeLine name?

https://github.com/llvm/llvm-project/pull/186686
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to