diff --git a/lib/IRGen/GenClangDecl.cpp b/lib/IRGen/GenClangDecl.cpp index 922d283a6e88e..158984a283031 100644 --- a/lib/IRGen/GenClangDecl.cpp +++ b/lib/IRGen/GenClangDecl.cpp @@ -119,6 +119,8 @@ class ClangDeclFinder return true; } + bool TraverseRequiresExpr(clang::RequiresExpr *RE) { return true; } + // Do not traverse type locs, as they might contain expressions that reference // code that should not be instantiated and/or emitted. bool TraverseTypeLoc(clang::TypeLoc TL) { return true; } diff --git a/test/Interop/Cxx/concepts/Inputs/method-requires.h b/test/Interop/Cxx/concepts/Inputs/method-requires.h new file mode 100644 index 0000000000000..3248559fc6de5 --- /dev/null +++ b/test/Interop/Cxx/concepts/Inputs/method-requires.h @@ -0,0 +1,11 @@ +inline void calledFromConceptBody(int x) {} +inline void calledFromMethodBody(int x) {} + +struct MyStruct { + template + void foo(T x) + requires requires(const T x) { calledFromConceptBody(x); } + { + calledFromMethodBody(x); + } +}; diff --git a/test/Interop/Cxx/concepts/Inputs/module.modulemap b/test/Interop/Cxx/concepts/Inputs/module.modulemap new file mode 100644 index 0000000000000..63293c4df4749 --- /dev/null +++ b/test/Interop/Cxx/concepts/Inputs/module.modulemap @@ -0,0 +1,4 @@ +module MethodRequires { + header "method-requires.h" + export * +} diff --git a/test/Interop/Cxx/concepts/method-requires.swift b/test/Interop/Cxx/concepts/method-requires.swift new file mode 100644 index 0000000000000..3f31960c60a09 --- /dev/null +++ b/test/Interop/Cxx/concepts/method-requires.swift @@ -0,0 +1,10 @@ +// RUN: %target-swiftxx-frontend -emit-ir -Xcc -std=gnu++20 -I %S/Inputs %s | %FileCheck %s +// +// REQUIRES: OS=macosx + +import MethodRequires + +var s = MyStruct() +s.foo(123) +// CHECK-NOT: calledFromConceptBody +// CHECK: calledFromMethodBody