{"url":"https://api.github.com/repos/llvm/llvm-project/issues/96364","repository_url":"https://api.github.com/repos/llvm/llvm-project","labels_url":"https://api.github.com/repos/llvm/llvm-project/issues/96364/labels{/name}","comments_url":"https://api.github.com/repos/llvm/llvm-project/issues/96364/comments","events_url":"https://api.github.com/repos/llvm/llvm-project/issues/96364/events","html_url":"https://github.com/llvm/llvm-project/pull/96364","id":2367315727,"node_id":"PR_kwDOBITxeM5zOfh7","number":96364,"title":"[Clang][Parse] Fix ambiguity with nested-name-specifiers that may declarative","user":{"login":"sdkrystian","id":16629302,"node_id":"MDQ6VXNlcjE2NjI5MzAy","avatar_url":"https://avatars.githubusercontent.com/u/16629302?v=4","gravatar_id":"","url":"https://api.github.com/users/sdkrystian","html_url":"https://github.com/sdkrystian","followers_url":"https://api.github.com/users/sdkrystian/followers","following_url":"https://api.github.com/users/sdkrystian/following{/other_user}","gists_url":"https://api.github.com/users/sdkrystian/gists{/gist_id}","starred_url":"https://api.github.com/users/sdkrystian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdkrystian/subscriptions","organizations_url":"https://api.github.com/users/sdkrystian/orgs","repos_url":"https://api.github.com/users/sdkrystian/repos","events_url":"https://api.github.com/users/sdkrystian/events{/privacy}","received_events_url":"https://api.github.com/users/sdkrystian/received_events","type":"User","user_view_type":"public","site_admin":false},"labels":[{"id":1958965060,"node_id":"MDU6TGFiZWwxOTU4OTY1MDYw","url":"https://api.github.com/repos/llvm/llvm-project/labels/clang","name":"clang","color":"79b5d1","default":false,"description":"Clang issues not falling into any other category","archived_at":null,"archived_by":null},{"id":1958998266,"node_id":"MDU6TGFiZWwxOTU4OTk4MjY2","url":"https://api.github.com/repos/llvm/llvm-project/labels/clang:frontend","name":"clang:frontend","color":"3b12ce","default":false,"description":"Language frontend issues, e.g. anything involving \"Sema\"","archived_at":null,"archived_by":null}],"state":"closed","locked":false,"assignees":[],"milestone":null,"comments":9,"created_at":"2024-06-21T22:20:54Z","updated_at":"2025-05-05T16:37:04Z","closed_at":"2024-07-29T18:01:01Z","assignee":null,"author_association":"MEMBER","issue_field_values":[],"type":null,"active_lock_reason":null,"draft":false,"pull_request":{"url":"https://api.github.com/repos/llvm/llvm-project/pulls/96364","html_url":"https://github.com/llvm/llvm-project/pull/96364","diff_url":"https://github.com/llvm/llvm-project/pull/96364.diff","patch_url":"https://github.com/llvm/llvm-project/pull/96364.patch","merged_at":"2024-07-29T18:01:01Z"},"body":"Consider the following:\r\n```cpp\r\ntemplate<typename T>\r\nstruct A { };\r\n\r\ntemplate<typename T>\r\nint A<T>::B::* f(); // error: no member named 'B' in 'A<T>'\r\n```\r\n\r\nAlthough this is clearly valid, clang rejects it because the _nested-name-specifier_ `A<T>::` is parsed as-if it was declarative, meaning, we parse it as-if it was the _nested-name-specifier_ in a redeclaration/specialization. However, we don't (and can't) know whether the _nested-name-specifier_ is declarative until we see the '`*`' token, but at that point we have already complained that `A` has no member named `B`! This patch addresses this bug by adding support for _fully_ unannotated _and_ unbounded tentative parsing, which allows for us to parse past tokens without having to cache them until we reach a point where we can guarantee to be past the construct we are disambiguating.\r\n\r\nI don't know where the approach taken here is ideal -- alternatives are welcome. However, the performance impact (as measured by [llvm-compile-time-tracker](https://llvm-compile-time-tracker.com/?config=Overview&stat=instructions%3Au&remote=sdkrystian)) is quite minimal (0.09%, which I plan to further improve).","closed_by":{"login":"sdkrystian","id":16629302,"node_id":"MDQ6VXNlcjE2NjI5MzAy","avatar_url":"https://avatars.githubusercontent.com/u/16629302?v=4","gravatar_id":"","url":"https://api.github.com/users/sdkrystian","html_url":"https://github.com/sdkrystian","followers_url":"https://api.github.com/users/sdkrystian/followers","following_url":"https://api.github.com/users/sdkrystian/following{/other_user}","gists_url":"https://api.github.com/users/sdkrystian/gists{/gist_id}","starred_url":"https://api.github.com/users/sdkrystian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdkrystian/subscriptions","organizations_url":"https://api.github.com/users/sdkrystian/orgs","repos_url":"https://api.github.com/users/sdkrystian/repos","events_url":"https://api.github.com/users/sdkrystian/events{/privacy}","received_events_url":"https://api.github.com/users/sdkrystian/received_events","type":"User","user_view_type":"public","site_admin":false},"reactions":{"url":"https://api.github.com/repos/llvm/llvm-project/issues/96364/reactions","total_count":0,"+1":0,"-1":0,"laugh":0,"hooray":0,"confused":0,"heart":0,"rocket":0,"eyes":0},"timeline_url":"https://api.github.com/repos/llvm/llvm-project/issues/96364/timeline","performed_via_github_app":null,"state_reason":null}