[PATCH] D158363: [clang-format] Fix segmentation fault when formatting nested namespaces

Owen Pan via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 24 01:05:38 PDT 2023


owenpan accepted this revision.
owenpan added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang/lib/Format/UnwrappedLineFormatter.cpp:389
           auto *ClosingLine = AnnotatedLines.begin() + ClosingLineIndex + 1;
-          auto OutdentBy = I[J]->Level - TheLine->Level;
+          int OutdentBy = I[J]->Level - TheLine->Level;
+          assert(OutdentBy >= 0);
----------------
I forgot to suggest `const`.


================
Comment at: clang/unittests/Format/FormatTest.cpp:4231-4234
+                "// block for debug mode\n"
+                "#ifndef NDEBUG\n"
+                "#endif\n"
+                "}}} // namespace ns1::ns2::ns3",
----------------
Did you run `git-clang-format`?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D158363



More information about the cfe-commits mailing list