@@ -429,7 +429,7 @@ class Instrumenter : InstrumenterBase {
429
429
++EI;
430
430
}
431
431
}
432
- } else if (shouldLogType (AE->getSrc ()-> getType ())) {
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 && shouldLogType (E-> getType () )) {
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 && shouldLogType (E-> getType () )) {
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 () && shouldLogType (RS->getResult ()-> getType ())) {
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 (
@@ -621,7 +621,7 @@ class Instrumenter : InstrumenterBase {
621
621
if (PL && Options.LogFunctionParameters ) {
622
622
size_t EI = 0 ;
623
623
for (const auto &PD : *PL) {
624
- if (PD->hasName () && shouldLogType (PD-> getInterfaceType () )) {
624
+ if (PD->hasName () && shouldLog (PD)) {
625
625
DeclBaseName Name = PD->getName ();
626
626
Expr *PVVarRef = new (Context)
627
627
DeclRefExpr (PD, DeclNameLoc (), /* implicit=*/ true ,
@@ -658,7 +658,7 @@ class Instrumenter : InstrumenterBase {
658
658
// after or instead of the expression they're looking at. Only call this
659
659
// if the variable has an initializer.
660
660
Added<Stmt *> logVarDecl (VarDecl *VD) {
661
- if (!shouldLogType (VD-> getInterfaceType () )) {
661
+ if (!shouldLog (VD)) {
662
662
return nullptr ;
663
663
}
664
664
@@ -678,7 +678,7 @@ class Instrumenter : InstrumenterBase {
678
678
if (auto *DRE = dyn_cast<DeclRefExpr>(*RE)) {
679
679
VarDecl *VD = cast<VarDecl>(DRE->getDecl ());
680
680
681
- if (!shouldLogType (VD-> getInterfaceType () )) {
681
+ if (!shouldLog (VD)) {
682
682
return nullptr ;
683
683
}
684
684
@@ -694,9 +694,8 @@ class Instrumenter : InstrumenterBase {
694
694
} else if (auto *MRE = dyn_cast<MemberRefExpr>(*RE)) {
695
695
Expr *B = MRE->getBase ();
696
696
ConcreteDeclRef M = MRE->getMember ();
697
- VarDecl *VD = cast<VarDecl>(M.getDecl ());
698
697
699
- if (!shouldLogType (VD-> getInterfaceType ())) {
698
+ if (!shouldLog (M. getDecl ())) {
700
699
return nullptr ;
701
700
}
702
701
@@ -799,11 +798,12 @@ class Instrumenter : InstrumenterBase {
799
798
return std::make_pair (PBD, VD);
800
799
}
801
800
802
- bool shouldLogType (Type Ty ) {
801
+ bool shouldLog (ASTNode node ) {
803
802
// Don't try to log ~Copyable types, as we can't pass them to the generic logging functions yet.
804
- if (Ty->isNoncopyable ()) {
805
- return false ;
806
- }
803
+ if (auto *VD = dyn_cast_or_null<ValueDecl>(node.dyn_cast <Decl *>()))
804
+ return VD->hasInterfaceType () ? !VD->getInterfaceType ()->isNoncopyable () : true ;
805
+ if (auto *E = node.dyn_cast <Expr *>())
806
+ return !E->getType ()->isNoncopyable ();
807
807
return true ;
808
808
}
809
809
0 commit comments