[PATCH] D141959: [clang-format] Fix inconsistent identification of operator&

David K Turner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Feb 1 13:40:10 PST 2023


dkt01 marked 8 inline comments as done.
dkt01 added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:1195-1198
+      // Handle unbalanced braces.
+      if (!Scopes.empty())
+        Scopes.pop_back();
       // Lines can start with '}'.
----------------
owenpan wrote:
> dkt01 wrote:
> > owenpan wrote:
> > > I don't think it's about unbalanced braces here.
> > `if (!Scopes.empty())` handles unbalanced braces.  `if(Tok->Previous)` handles the case where a line starts with an rbrace.
> I can't think of an example. Do you have one?
The format unit test `FormatUnbalancedStructuralElements` feeds in strings that have only right braces, so without this check the pop fails.


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

https://reviews.llvm.org/D141959



More information about the cfe-commits mailing list