Skip to content

Commit 4a86174

Browse files
authored
[AutoDiff] [SR-14240] Align name mangling for Clang-imported declarations (#38850)
* Adding fix for handling Clang-imported names, along with test case. * Correct EOL.
1 parent 133a832 commit 4a86174

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

lib/AST/ASTMangler.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,14 @@ void ASTMangler::beginManglingWithAutoDiffOriginalFunction(
459459
appendOperator(attr->Name);
460460
return;
461461
}
462+
// For imported Clang declarations, use the Clang name in order to match how
463+
// DifferentiationMangler handles these.
464+
auto clangDecl = getClangDeclForMangling(afd);
465+
if (clangDecl) {
466+
beginManglingWithoutPrefix();
467+
appendOperator(clangDecl->getName());
468+
return;
469+
}
462470
beginMangling();
463471
if (auto *cd = dyn_cast<ConstructorDecl>(afd))
464472
appendConstructorEntity(cd, /*isAllocating*/ !cd->isConvenienceInit());
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
// RUN: %target-run-simple-swift(-Xfrontend -requirement-machine=off)
2+
3+
// SR-14240: Error: symbol 'powTJfSSpSr' (powTJfSSpSr) is in generated IR file,
4+
// but not in TBD file.
5+
6+
import _Differentiation
7+
8+
#if canImport(Darwin)
9+
import Darwin
10+
#elseif canImport(Glibc)
11+
import Glibc
12+
#elseif os(Windows)
13+
import CRT
14+
#else
15+
#error("Unsupported platform")
16+
#endif
17+
18+
@inlinable
19+
@derivative(of: pow)
20+
func powVJP(
21+
_ base: Double, _ exponent: Double
22+
) -> (value: Double, pullback: (Double) -> (Double, Double)) {
23+
fatalError()
24+
}

0 commit comments

Comments
 (0)