@@ -429,7 +429,7 @@ class Instrumenter : InstrumenterBase {
429
429
++EI;
430
430
}
431
431
}
432
- } else {
432
+ } else if ( shouldLog (AE-> getSrc ())) {
433
433
std::pair<PatternBindingDecl *, VarDecl *> PV =
434
434
buildPatternAndVariable (AE->getSrc ());
435
435
DeclRefExpr *DRE = new (Context)
@@ -521,7 +521,7 @@ class Instrumenter : InstrumenterBase {
521
521
}
522
522
Handled = true ; // Never log ()
523
523
}
524
- if (!Handled) {
524
+ if (!Handled && shouldLog (E) ) {
525
525
// do the same as for all other expressions
526
526
std::pair<PatternBindingDecl *, VarDecl *> PV =
527
527
buildPatternAndVariable (E);
@@ -539,7 +539,7 @@ class Instrumenter : InstrumenterBase {
539
539
}
540
540
}
541
541
} else {
542
- if (E->getType ()->getCanonicalType () != Context.TheEmptyTupleType ) {
542
+ if (E->getType ()->getCanonicalType () != Context.TheEmptyTupleType && shouldLog (E) ) {
543
543
std::pair<PatternBindingDecl *, VarDecl *> PV =
544
544
buildPatternAndVariable (E);
545
545
Added<Stmt *> Log = buildLoggerCall (
@@ -559,7 +559,7 @@ class Instrumenter : InstrumenterBase {
559
559
} else if (auto *S = Element.dyn_cast <Stmt *>()) {
560
560
S->walk (CF);
561
561
if (auto *RS = dyn_cast<ReturnStmt>(S)) {
562
- if (RS->hasResult ()) {
562
+ if (RS->hasResult () && shouldLog (RS-> getResult ()) ) {
563
563
std::pair<PatternBindingDecl *, VarDecl *> PV =
564
564
buildPatternAndVariable (RS->getResult ());
565
565
DeclRefExpr *DRE = new (Context) DeclRefExpr (
@@ -620,7 +620,7 @@ class Instrumenter : InstrumenterBase {
620
620
if (PL && Options.LogFunctionParameters ) {
621
621
size_t EI = 0 ;
622
622
for (const auto &PD : *PL) {
623
- if (PD->hasName ()) {
623
+ if (PD->hasName () && shouldLog (PD) ) {
624
624
DeclBaseName Name = PD->getName ();
625
625
Expr *PVVarRef = new (Context)
626
626
DeclRefExpr (PD, DeclNameLoc (), /* implicit=*/ true ,
@@ -657,6 +657,10 @@ class Instrumenter : InstrumenterBase {
657
657
// after or instead of the expression they're looking at. Only call this
658
658
// if the variable has an initializer.
659
659
Added<Stmt *> logVarDecl (VarDecl *VD) {
660
+ if (!shouldLog (VD)) {
661
+ return nullptr ;
662
+ }
663
+
660
664
if (isa<ConstructorDecl>(TypeCheckDC) && VD->getNameStr ().equals (" self" )) {
661
665
// Don't log "self" in a constructor
662
666
return nullptr ;
@@ -673,6 +677,10 @@ class Instrumenter : InstrumenterBase {
673
677
if (auto *DRE = dyn_cast<DeclRefExpr>(*RE)) {
674
678
VarDecl *VD = cast<VarDecl>(DRE->getDecl ());
675
679
680
+ if (!shouldLog (VD)) {
681
+ return nullptr ;
682
+ }
683
+
676
684
if (isa<ConstructorDecl>(TypeCheckDC) && VD->getBaseName () == " self" ) {
677
685
// Don't log "self" in a constructor
678
686
return nullptr ;
@@ -686,6 +694,10 @@ class Instrumenter : InstrumenterBase {
686
694
Expr *B = MRE->getBase ();
687
695
ConcreteDeclRef M = MRE->getMember ();
688
696
697
+ if (!shouldLog (M.getDecl ())) {
698
+ return nullptr ;
699
+ }
700
+
689
701
if (isa<ConstructorDecl>(TypeCheckDC) && digForName (B) == " self" ) {
690
702
// Don't log attributes of "self" in a constructor
691
703
return nullptr ;
@@ -785,6 +797,15 @@ class Instrumenter : InstrumenterBase {
785
797
return std::make_pair (PBD, VD);
786
798
}
787
799
800
+ bool shouldLog (ASTNode node) {
801
+ // Don't try to log ~Copyable types, as we can't pass them to the generic logging functions yet.
802
+ if (auto *VD = dyn_cast_or_null<ValueDecl>(node.dyn_cast <Decl *>()))
803
+ return VD->hasInterfaceType () ? !VD->getInterfaceType ()->isNoncopyable () : true ;
804
+ if (auto *E = node.dyn_cast <Expr *>())
805
+ return !E->getType ()->isNoncopyable ();
806
+ return true ;
807
+ }
808
+
788
809
Added<Stmt *> buildLoggerCall (Added<Expr *> E, SourceRange SR,
789
810
StringRef Name) {
790
811
Expr *NameExpr = new (Context) StringLiteralExpr (
0 commit comments