Skip to content

Commit 9a496e8

Browse files
authored
Merge pull request #65652 from apple/egorzhdan/cxx-requires-irgen
[cxx-interop] Do not emit IR for C++20 requires expr
2 parents f667c86 + 21745e5 commit 9a496e8

File tree

4 files changed

+27
-0
lines changed

4 files changed

+27
-0
lines changed

lib/IRGen/GenClangDecl.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,8 @@ class ClangDeclFinder
119119
return true;
120120
}
121121

122+
bool TraverseRequiresExpr(clang::RequiresExpr *RE) { return true; }
123+
122124
// Do not traverse type locs, as they might contain expressions that reference
123125
// code that should not be instantiated and/or emitted.
124126
bool TraverseTypeLoc(clang::TypeLoc TL) { return true; }
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
inline void calledFromConceptBody(int x) {}
2+
inline void calledFromMethodBody(int x) {}
3+
4+
struct MyStruct {
5+
template <typename T>
6+
void foo(T x)
7+
requires requires(const T x) { calledFromConceptBody(x); }
8+
{
9+
calledFromMethodBody(x);
10+
}
11+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
module MethodRequires {
2+
header "method-requires.h"
3+
export *
4+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
// RUN: %target-swiftxx-frontend -emit-ir -Xcc -std=gnu++20 -I %S/Inputs %s | %FileCheck %s
2+
//
3+
// REQUIRES: OS=macosx
4+
5+
import MethodRequires
6+
7+
var s = MyStruct()
8+
s.foo(123)
9+
// CHECK-NOT: calledFromConceptBody
10+
// CHECK: calledFromMethodBody

0 commit comments

Comments
 (0)