Skip to content

[cxx-interop] Do not emit IR for C++20 requires expr #65652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 5, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions lib/IRGen/GenClangDecl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
11 changes: 11 additions & 0 deletions test/Interop/Cxx/concepts/Inputs/method-requires.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
inline void calledFromConceptBody(int x) {}
inline void calledFromMethodBody(int x) {}

struct MyStruct {
template <typename T>
void foo(T x)
requires requires(const T x) { calledFromConceptBody(x); }
{
calledFromMethodBody(x);
}
};
4 changes: 4 additions & 0 deletions test/Interop/Cxx/concepts/Inputs/module.modulemap
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
module MethodRequires {
header "method-requires.h"
export *
}
10 changes: 10 additions & 0 deletions test/Interop/Cxx/concepts/method-requires.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// RUN: %target-swiftxx-frontend -emit-ir -Xcc -std=gnu++20 -I %S/Inputs %s | %FileCheck %s
//
// REQUIRES: OS=macosx
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add a note saying why this needs macOS in C++ 20 mode . Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Filed #65710


import MethodRequires

var s = MyStruct()
s.foo(123)
// CHECK-NOT: calledFromConceptBody
// CHECK: calledFromMethodBody