owenpan added inline comments.

================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:389
           auto *ClosingLine = AnnotatedLines.begin() + ClosingLineIndex + 1;
           auto OutdentBy = I[J]->Level - TheLine->Level;
           for (auto *CompactedLine = I + J; CompactedLine <= ClosingLine;
----------------
See below.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:392-393
                ++CompactedLine) {
             if (!(*CompactedLine)->InPPDirective)
-              (*CompactedLine)->Level -= OutdentBy;
+              (*CompactedLine)->Level -= std::min(OutdentBy, 
(*CompactedLine)->Level);
           }
----------------
Or similar.


================
Comment at: clang/unittests/Format/FormatTest.cpp:4230-4237
+  verifyNoCrash("namespace ns1 { namespace ns2 { namespace ns3 {\n"
+                "void func_in_ns() {\n"
+                "  int res{0};\n"
+                "// block for debug mode\n"
+                "#ifndef NDEBUG\n"
+                "#endif\n"
+                "}\n"
----------------
It seems that we can reduce the test case.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D158363/new/

https://reviews.llvm.org/D158363

_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to