Skip to content

Commit 083d56f

Browse files
committed
---
yaml --- r: 294778 b: refs/heads/tensorflow c: 140a5b0 h: refs/heads/master
1 parent 0f7eef9 commit 083d56f

File tree

2 files changed

+45
-7
lines changed

2 files changed

+45
-7
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -816,7 +816,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-04-25-a: 22f738a831d43aff2b9c9773bcb65
816816
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2018-05-08-a: 7d98cc16689baba5c8a3b90a9329bdcc1a12b4e9
817817
refs/heads/cherr42: a566ad54b073c2c56ac0a705d0a5bed9743135a5
818818
"refs/heads/codable_test_comment_fix": fc8f6824f7f347e1e8db55bff62db385c5728b5a
819-
refs/heads/tensorflow: b26ba2dce9bf57900265c71693f4eeff8518d92e
819+
refs/heads/tensorflow: 140a5b0018d30000acd6ec6c5aa4eea2cf148ab6
820820
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-11-a: 8126fd7a652e2f70ad6d76505239e34fb2ef3e1a
821821
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-12-a: b3fd3dd84df6717f2e2e9df58c6d7e99fed57086
822822
refs/tags/swift-4.1-DEVELOPMENT-SNAPSHOT-2018-05-13-a: 71135119579039dc321c5f65d870050fe36efda2

branches/tensorflow/lib/Sema/CodeSynthesis.cpp

Lines changed: 44 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2338,26 +2338,64 @@ static void synthesizeStubBody(AbstractFunctionDecl *fn, void *) {
23382338
return;
23392339
}
23402340

2341+
auto *staticStringDecl = ctx.getStaticStringDecl();
2342+
auto staticStringType = staticStringDecl->getDeclaredType();
2343+
auto staticStringInit = ctx.getStringBuiltinInitDecl(staticStringDecl);
2344+
2345+
auto *uintDecl = ctx.getUIntDecl();
2346+
auto uintType = uintDecl->getDeclaredType();
2347+
auto uintInit = ctx.getIntBuiltinInitDecl(uintDecl);
2348+
23412349
// Create a call to Swift._unimplementedInitializer
23422350
auto loc = classDecl->getLoc();
23432351
Expr *ref = new (ctx) DeclRefExpr(unimplementedInitDecl,
23442352
DeclNameLoc(loc),
23452353
/*Implicit=*/true);
2354+
ref->setType(unimplementedInitDecl->getInterfaceType()
2355+
->removeArgumentLabels(1));
23462356

23472357
llvm::SmallString<64> buffer;
23482358
StringRef fullClassName = ctx.AllocateCopy(
23492359
(classDecl->getModuleContext()->getName().str() +
23502360
"." +
23512361
classDecl->getName().str()).toStringRef(buffer));
23522362

2353-
Expr *className = new (ctx) StringLiteralExpr(fullClassName, loc,
2363+
auto *className = new (ctx) StringLiteralExpr(fullClassName, loc,
23542364
/*Implicit=*/true);
2355-
Expr *call = CallExpr::createImplicit(ctx, ref, { className },
2356-
{ ctx.Id_className });
2357-
ctor->setBody(BraceStmt::create(ctx, SourceLoc(),
2358-
ASTNode(call),
2359-
SourceLoc(),
2365+
className->setBuiltinInitializer(staticStringInit);
2366+
assert(isa<ConstructorDecl>(className->getBuiltinInitializer().getDecl()));
2367+
className->setType(staticStringType);
2368+
2369+
auto *initName = new (ctx) MagicIdentifierLiteralExpr(
2370+
MagicIdentifierLiteralExpr::Function, loc, /*Implicit=*/true);
2371+
initName->setType(staticStringType);
2372+
initName->setBuiltinInitializer(staticStringInit);
2373+
2374+
auto *file = new (ctx) MagicIdentifierLiteralExpr(
2375+
MagicIdentifierLiteralExpr::File, loc, /*Implicit=*/true);
2376+
file->setType(staticStringType);
2377+
file->setBuiltinInitializer(staticStringInit);
2378+
2379+
auto *line = new (ctx) MagicIdentifierLiteralExpr(
2380+
MagicIdentifierLiteralExpr::Line, loc, /*Implicit=*/true);
2381+
line->setType(uintType);
2382+
line->setBuiltinInitializer(uintInit);
2383+
2384+
auto *column = new (ctx) MagicIdentifierLiteralExpr(
2385+
MagicIdentifierLiteralExpr::Column, loc, /*Implicit=*/true);
2386+
column->setType(uintType);
2387+
column->setBuiltinInitializer(uintInit);
2388+
2389+
Expr *call = CallExpr::createImplicit(
2390+
ctx, ref, { className, initName, file, line, column }, {});
2391+
call->setType(ctx.getNeverType());
2392+
2393+
SmallVector<ASTNode, 2> stmts;
2394+
stmts.push_back(call);
2395+
stmts.push_back(new (ctx) ReturnStmt(SourceLoc(), /*Result=*/nullptr));
2396+
ctor->setBody(BraceStmt::create(ctx, SourceLoc(), stmts, SourceLoc(),
23602397
/*implicit=*/true));
2398+
ctor->setBodyTypeCheckedIfPresent();
23612399
}
23622400

23632401
static std::tuple<GenericEnvironment *, GenericParamList *, SubstitutionMap>

0 commit comments

Comments
 (0)