[clang] [clang] SemaFunctionEffects: When verifying a function, ignore any trailing 'requires' clause. (PR #114266)

Doug Wyatt via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 4 07:50:03 PST 2024


================
@@ -985,6 +986,9 @@ class Analyzer {
       if (auto *Dtor = dyn_cast<CXXDestructorDecl>(CurrentCaller.CDecl))
         followDestructor(dyn_cast<CXXRecordDecl>(Dtor->getParent()), Dtor);
 
+      if (auto *FD = dyn_cast<FunctionDecl>(CurrentCaller.CDecl))
+        TrailingRequiresClause = FD->getTrailingRequiresClause();
----------------
dougsonos wrote:

Looking at an AST dump from:

```c++
template <class _Tp, _Tp __v>
struct integral_constant {
  static constexpr const _Tp value = __v;
  typedef _Tp value_type;
  typedef integral_constant type;
  constexpr operator value_type() const noexcept { return value; }
  constexpr value_type operator()() const noexcept { return value; }
};

template <class _Tp, _Tp __v>
constexpr const _Tp integral_constant<_Tp, __v>::value;

typedef integral_constant<bool, true> true_type;
typedef integral_constant<bool, false> false_type;

template <class _Tp>
struct is_default_constructible : public integral_constant<bool, __is_constructible(_Tp)> {};

template <class _Tp>
inline constexpr bool is_default_constructible_v = __is_constructible(_Tp);

template <typename T>
void f()
	requires is_default_constructible_v<T>
{
    auto g = [](int x) requires is_default_constructible_v<T> {

    };
}
```

There are separate `UnresolvedLookupExpr`'s attached to the `FunctionDecl` for `f` and to the lambda-generated class's `operator()` and `CXXConversionDecl`.

I found `getTrailingReturnClause()` being used by `RecursiveASTVisitor<T>::TraverseFunctionHelper()`.

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


More information about the cfe-commits mailing list