[PATCH] D121550: [clang-format] Fix crash on invalid requires expression

Björn Schäpers via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Sun Mar 13 14:09:51 PDT 2022


HazardyKnusperkeks added inline comments.


================
Comment at: clang/lib/Format/TokenAnnotator.cpp:215
+    assert(CurrentToken->Previous && "Unknown previous token");
+    FormatToken &OpeningParen = *CurrentToken->Previous;
+    assert(OpeningParen.is(tok::l_paren));
----------------
curdeius wrote:
> Maybe you can commit the rename as a NFC commit and rebase the patch to remove the noise?
Done in D121557


================
Comment at: clang/unittests/Format/TokenAnnotatorTest.cpp:335
+
+  // Invalid Code, but we don't want to crash. See http://llvm.org/PR54350.
+  Tokens = annotate("bool r10 = requires (struct new_struct { int x; } s) { "
----------------
curdeius wrote:
> I'd prefer a valid C++ code (if it's not too complicated) if possible but that's acceptable.
I thought I'd stick to the bug report. The only thing that comes to my mind does compile on gcc, but clang gives a specific error (which I support, without having looked into the standard). https://gcc.godbolt.org/z/WvT9861b6


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

https://reviews.llvm.org/D121550



More information about the cfe-commits mailing list