[pseudo] Eliminate the type-name identifier ambiguities in the grammar.
authorHaojian Wu <hokein.wu@gmail.com>
Tue, 16 Aug 2022 19:23:11 +0000 (21:23 +0200)
committerHaojian Wu <hokein.wu@gmail.com>
Wed, 17 Aug 2022 12:30:53 +0000 (14:30 +0200)
commit6a9f79e1020db9f581d00791f1f644b64facfebe
tree45cfe7ce4c9905c96fa39cb7c24ad82d991919b7
parentd7e06d5675b62b5d3d89e6d6210c34b74a1a8356
[pseudo] Eliminate the type-name identifier ambiguities in the grammar.

See https://reviews.llvm.org/D130626 for motivation.

Identifier in the grammar has different categories (type-name, template-name,
namespace-name), they requires semantic information to resolve. This patch is
to eliminate the "local" ambiguities in type-name, and namespace-name, which
gives us a performance boost of the parser:

  - eliminate all different type rules (class-name, enum-name, typedef-name), and
    fold them into a unified type-name, this removes the #1 type-name ambiguity, and
    gives us a big performance boost;
  - remove the namespace-alis rules, as they're hard and uninteresting;

Note that we could eliminate more and gain more performance (like fold template-name,
type-name, namespace together), but at current stage, we'd like keep all existing
categories of the identifier (as they might assist in correlated disambiguation &
keep the representation of important concepts uniform).

| file               |ambiguous nodes |  forest size     | glrParse performance |
|SemaCodeComplete.cpp|  11k -> 5.7K   | 10.4MB -> 7.9MB  | 7.1MB/s -> 9.98MB/s  |
|       AST.cpp      |  1.3k -> 0.73K | 0.99MB -> 0.77MB | 6.7MB/s -> 8.4MB/s   |

Differential Revision: https://reviews.llvm.org/D130747
clang-tools-extra/pseudo/lib/cxx/cxx.bnf
clang-tools-extra/pseudo/test/glr.cpp