[all-commits] [llvm/llvm-project] 6f6c40: [pseudo] Eliminate the false `::` nested-name-spec...

Haojian Wu via All-commits all-commits at lists.llvm.org
Thu Jul 28 02:01:31 PDT 2022


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 6f6c40a875c84443f255f3a6b4efc0bc0f2fb67a
      https://github.com/llvm/llvm-project/commit/6f6c40a875c84443f255f3a6b4efc0bc0f2fb67a
  Author: Haojian Wu <hokein.wu at gmail.com>
  Date:   2022-07-28 (Thu, 28 Jul 2022)

  Changed paths:
    M clang-tools-extra/pseudo/include/clang-pseudo/Token.h
    M clang-tools-extra/pseudo/lib/cxx/CXX.cpp
    M clang-tools-extra/pseudo/lib/cxx/cxx.bnf
    A clang-tools-extra/pseudo/test/cxx/nested-name-specifier.cpp

  Log Message:
  -----------
  [pseudo] Eliminate the false `::` nested-name-specifier ambiguity

The solution is to favor the longest possible nest-name-specifier, and
drop other alternatives by using the guard, per per C++ [basic.lookup.qual.general].

Motivated cases:

```
Foo::Foo() {};
// the constructor can be parsed as:
//  - Foo ::Foo(); // where the first Foo is return-type, and ::Foo is the function declarator
//  + Foo::Foo(); // where Foo::Foo is the function declarator
```

```
void test() {

// a very slow parsing case when there are many qualifers!
X::Y::Z;
// The statement can be parsed as:
//  - X ::Y::Z; // ::Y::Z is the declarator
//  - X::Y ::Z; // ::Z is the declarator
//  + X::Y::Z;  // a declaration without declarator (X::Y::Z is decl-specifier-seq)
//  + X::Y::Z;  // a qualifed-id expression
}
```

Differential Revision: https://reviews.llvm.org/D130511




More information about the All-commits mailing list