Skip to content

Commit 68631b3

Browse files
committed
[cxx-interop] Pull over fix from 8e7766b and apply to strstr, sin, and cos.
1 parent d348e3d commit 68631b3

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

lib/ClangImporter/ImportDecl.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3203,7 +3203,9 @@ namespace {
32033203
// instead of checking if they come from the `std` module.
32043204
if (!d->getDeclName().isIdentifier())
32053205
return false;
3206-
return d->getName() == "abs" || d->getName() == "div";
3206+
return d->getName() == "abs" || d->getName() == "div" ||
3207+
d->getName() == "strstr" || d->getName() == "sin" ||
3208+
d->getName() == "cos";
32073209
};
32083210
if (decl->getOwningModule() &&
32093211
(decl->getOwningModule()
@@ -3214,7 +3216,8 @@ namespace {
32143216
Impl.getClangPreprocessor().getSourceManager().getFilename(
32153217
decl->getLocation());
32163218
if (filename.endswith("cmath") || filename.endswith("math.h") ||
3217-
filename.endswith("stdlib.h") || filename.endswith("cstdlib")) {
3219+
filename.endswith("stdlib.h") || filename.endswith("cstdlib") ||
3220+
filename.endswith("string.h")) {
32183221
return nullptr;
32193222
}
32203223
}

test/Interop/Cxx/stdlib/avoid-import-cxx-math.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,5 @@ func test() {
2020

2121
let _ = CxxStdlib.abs(x) // expected-error {{module 'CxxStdlib' has no member named 'abs'}}
2222
let _ = CxxStdlib.div(x) // expected-error {{module 'CxxStdlib' has no member named 'div'}}
23+
let _ = CxxStdlib.strstr("a", "aaa") // expected-error {{module 'CxxStdlib' has no member named 'strstr'}}
2324
}

0 commit comments

Comments
 (0)