[PATCH] D125794: [pseudo] Remove unnecessary user-defined-string-literal rule.

Haojian Wu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 17 07:53:50 PDT 2022


hokein created this revision.
hokein added a reviewer: sammccall.
Herald added a project: All.
hokein requested review of this revision.
Herald added a subscriber: alextsao1999.
Herald added a project: clang-tools-extra.

We accidently define two identical rules for user-defined-string-literal
(one left recursive and the other one is right recursive), it explodes
states when parsing a long long "" "" "" string literal.

TEST on a huge file which contains ~2.6w "" string literal:

before this patch: more than minutes
after this patch: < 1s


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D125794

Files:
  clang-tools-extra/pseudo/lib/cxx.bnf


Index: clang-tools-extra/pseudo/lib/cxx.bnf
===================================================================
--- clang-tools-extra/pseudo/lib/cxx.bnf
+++ clang-tools-extra/pseudo/lib/cxx.bnf
@@ -713,7 +713,7 @@
 #! so it doesn't belong to the grammar. However, we extend the grammar to
 #! support it, to make the pseudoparser fully functional on practical code.
 string-literal := string-literal-chunk
-string-literal := string-literal string-literal-chunk
+string-literal := string-literal-chunk string-literal
 user-defined-literal := user-defined-integer-literal
 user-defined-literal := user-defined-floating-point-literal
 user-defined-literal := user-defined-string-literal
@@ -726,7 +726,6 @@
 user-defined-string-literal-chunk := UTF32_STRING_LITERAL
 user-defined-string-literal := user-defined-string-literal-chunk
 user-defined-string-literal := string-literal-chunk user-defined-string-literal
-user-defined-string-literal := user-defined-string-literal string-literal-chunk
 user-defined-floating-point-literal := NUMERIC_CONSTANT
 user-defined-character-literal := CHAR_CONSTANT
 user-defined-character-literal := WIDE_CHAR_CONSTANT


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D125794.430064.patch
Type: text/x-patch
Size: 1151 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220517/2c28ee2a/attachment.bin>


More information about the cfe-commits mailing list