fscheidl wrote:

> What `clang_CXXMethod_getQualifiers` is supposed to return for a member 
> function with an explicit object parameter (available since C++23)?
> 
> ```c++
> struct S {
>   void f() const&;
>   void g(this const S& self);
> };
> ```
> 
> I think the right approach here would be to ask for the first parameter (or 
> object parameter, if that is available as an API), and interrogate its type 
> whether qualifiers are present. But I consider it a rather open question 
> whether `clang_CXXMethod_getQualifiers` should be concerned with qualifiers 
> after parameter-declaration-clause (so, lexical property), or with qualifiers 
> of object parameter (semantic property).
> 
> CC @AaronBallman

I'd expect `clang_CXXMethod_getQualifiers` to return the actual method 
qualifiers (the ones after the parameter list) - the naming itself implies 
we're querying qualifiers of the method, not of its parameters. While the 
qualifiers on an explicit object parameter may be semantically related, they 
are lexically distinct as you noted and users can inspect the explicit object 
parameter's qualifiers through the parameter cursor itself.

libclang doesn't currently expose a way to check whether a method has an 
explicit object parameter though (Clang has 
`CXXMethodDecl::isExplicitObjectMemberFunction` and 
`ParmVarDecl::isExplicitObjectParameter` internally, but neither is exposed via 
libclang). We could add something like 
`clang_CXXMethod_isExplicitObjectMemberFunction` so users can distinguish the 
two forms.

I'd also document the behavior for explicit object member functions and add a 
test case for those cases.

https://github.com/llvm/llvm-project/pull/183305
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to