[clang] [clang] SourceLocIdentKind::Function should not be dependent (PR #94942)

Qizhi Hu via cfe-commits cfe-commits at lists.llvm.org
Sun Jun 16 01:17:03 PDT 2024


jcsxky wrote:

> So, looked into this more. You are correct that `Function` needs not be dependent because we only ever show the name of the function unqualified. However, `FunctionSig` does. Here is an example of what we are trying to preserve https://godbolt.org/z/M3eTa8nn5 (the clang 17 behavior was incorrect)
> 
> I apologize for not realizing earlier that your change was actually sensible in the case of `Function`

Never mind! After looking into the code a little bit more, `FunctionSig` indeed needs to be dependent.
```cpp
template<int N>
constexpr int g() {
  return N;
}

template <typename T>
struct S {
    void f(auto) {
        constexpr const char* F = __builtin_FUNCSIG();
        static_assert(__builtin_strlen(F)==g<__builtin_strlen(F)>());
    }

};

void f(){
	S<int>{}.f(0);
}
```
However, it still crash when we changed from  `__builtin_FUNCTION` to `__builtin_FUNCSIG` in the testcase from https://github.com/llvm/llvm-project/issues/80210. The underlying issue is that `CurContext` is `FunctionTemplateDecl` which is dependent and we used it as `ParentContext` of `SourceLocExpr` when transforming `decltype` of function `construct_at`. This makes transformed return type of `construct_at` dependent which is not what we want. I will close this patch since it  doesn't resolve the underlying issue.  Thanks for your time for the review! @cor3ntin 








https://github.com/llvm/llvm-project/pull/94942


More information about the cfe-commits mailing list