Skip to content
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

Revert "[PlaygroundTransform] Disable logging ~Copyable types as they can’t be passed to the generic logging function" #71918

Closed
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
31 changes: 5 additions & 26 deletions lib/Sema/PlaygroundTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -429,7 +429,7 @@ class Instrumenter : InstrumenterBase {
++EI;
}
}
} else if (shouldLog(AE->getSrc())) {
} else {
std::pair<PatternBindingDecl *, VarDecl *> PV =
buildPatternAndVariable(AE->getSrc());
DeclRefExpr *DRE = new (Context)
Expand Down Expand Up @@ -521,7 +521,7 @@ class Instrumenter : InstrumenterBase {
}
Handled = true; // Never log ()
}
if (!Handled && shouldLog(E)) {
if (!Handled) {
// do the same as for all other expressions
std::pair<PatternBindingDecl *, VarDecl *> PV =
buildPatternAndVariable(E);
Expand All @@ -539,7 +539,7 @@ class Instrumenter : InstrumenterBase {
}
}
} else {
if (E->getType()->getCanonicalType() != Context.TheEmptyTupleType && shouldLog(E)) {
if (E->getType()->getCanonicalType() != Context.TheEmptyTupleType) {
std::pair<PatternBindingDecl *, VarDecl *> PV =
buildPatternAndVariable(E);
Added<Stmt *> Log = buildLoggerCall(
Expand All @@ -559,7 +559,7 @@ class Instrumenter : InstrumenterBase {
} else if (auto *S = Element.dyn_cast<Stmt *>()) {
S->walk(CF);
if (auto *RS = dyn_cast<ReturnStmt>(S)) {
if (RS->hasResult() && shouldLog(RS->getResult())) {
if (RS->hasResult()) {
std::pair<PatternBindingDecl *, VarDecl *> PV =
buildPatternAndVariable(RS->getResult());
DeclRefExpr *DRE = new (Context) DeclRefExpr(
Expand Down Expand Up @@ -620,7 +620,7 @@ class Instrumenter : InstrumenterBase {
if (PL && Options.LogFunctionParameters) {
size_t EI = 0;
for (const auto &PD : *PL) {
if (PD->hasName() && shouldLog(PD)) {
if (PD->hasName()) {
DeclBaseName Name = PD->getName();
Expr *PVVarRef = new (Context)
DeclRefExpr(PD, DeclNameLoc(), /*implicit=*/true,
Expand Down Expand Up @@ -657,10 +657,6 @@ class Instrumenter : InstrumenterBase {
// after or instead of the expression they're looking at. Only call this
// if the variable has an initializer.
Added<Stmt *> logVarDecl(VarDecl *VD) {
if (!shouldLog(VD)) {
return nullptr;
}

if (isa<ConstructorDecl>(TypeCheckDC) && VD->getNameStr().equals("self")) {
// Don't log "self" in a constructor
return nullptr;
Expand All @@ -677,10 +673,6 @@ class Instrumenter : InstrumenterBase {
if (auto *DRE = dyn_cast<DeclRefExpr>(*RE)) {
VarDecl *VD = cast<VarDecl>(DRE->getDecl());

if (!shouldLog(VD)) {
return nullptr;
}

if (isa<ConstructorDecl>(TypeCheckDC) && VD->getBaseName() == "self") {
// Don't log "self" in a constructor
return nullptr;
Expand All @@ -694,10 +686,6 @@ class Instrumenter : InstrumenterBase {
Expr *B = MRE->getBase();
ConcreteDeclRef M = MRE->getMember();

if (!shouldLog(M.getDecl())) {
return nullptr;
}

if (isa<ConstructorDecl>(TypeCheckDC) && digForName(B) == "self") {
// Don't log attributes of "self" in a constructor
return nullptr;
Expand Down Expand Up @@ -797,15 +785,6 @@ class Instrumenter : InstrumenterBase {
return std::make_pair(PBD, VD);
}

bool shouldLog(ASTNode node) {
// Don't try to log ~Copyable types, as we can't pass them to the generic logging functions yet.
if (auto *VD = dyn_cast_or_null<ValueDecl>(node.dyn_cast<Decl *>()))
return VD->hasInterfaceType() ? !VD->getInterfaceType()->isNoncopyable() : true;
if (auto *E = node.dyn_cast<Expr *>())
return !E->getType()->isNoncopyable();
return true;
}

Added<Stmt *> buildLoggerCall(Added<Expr *> E, SourceRange SR,
StringRef Name) {
Expr *NameExpr = new (Context) StringLiteralExpr(
Expand Down
24 changes: 0 additions & 24 deletions test/PlaygroundTransform/noncopyable_assignment.swift

This file was deleted.

22 changes: 0 additions & 22 deletions test/PlaygroundTransform/noncopyable_declaration.swift

This file was deleted.

24 changes: 0 additions & 24 deletions test/PlaygroundTransform/noncopyable_functions.swift

This file was deleted.

34 changes: 17 additions & 17 deletions utils/build-presets.ini
Original file line number Diff line number Diff line change
Expand Up @@ -845,10 +845,10 @@ test-installable-package
toolchain-benchmarks

# Path to the root of the installation filesystem.
install-destdir=%(install_destdir)s
install-destdir=/home/build-user/swift-nightly-install

# Path to the .tar.gz package we would create.
installable-package=%(installable_package)s
installable-package=/home/build-user/swift-DEVELOPMENT-SNAPSHOT-2024-02-27-a-amazonlinux2.tar.gz

# This ensures the default module cache
# location is local to this run, allowing
Expand Down Expand Up @@ -911,21 +911,21 @@ no-assertions


[preset: mixin_buildbot_linux,no_test]
skip-test-cmark
skip-test-lldb
skip-test-swift
skip-test-llbuild
skip-test-swiftpm
skip-test-swift-driver
skip-test-xctest
skip-test-foundation
skip-test-libdispatch
skip-test-playgroundsupport
skip-test-libicu
skip-test-indexstore-db
skip-test-sourcekit-lsp
skip-test-swiftdocc
skip-test-wasm-stdlib
; skip-test-cmark
; skip-test-lldb
; skip-test-swift
; skip-test-llbuild
; skip-test-swiftpm
; skip-test-swift-driver
; skip-test-xctest
; skip-test-foundation
; skip-test-libdispatch
; skip-test-playgroundsupport
; skip-test-libicu
; skip-test-indexstore-db
; skip-test-sourcekit-lsp
; skip-test-swiftdocc
; skip-test-wasm-stdlib

# Linux package with out test
[preset: buildbot_linux,no_test]
Expand Down