@@ -1624,6 +1624,7 @@ Atom *PointerVariableConstraint::getAtom(unsigned AtomIdx, Constraints &CS) {
1624
1624
// Brain Transplant params and returns in [FromCV], recursively.
1625
1625
void FunctionVariableConstraint::brainTransplant (ConstraintVariable *FromCV,
1626
1626
ProgramInfo &I) {
1627
+ llvm::errs () << " Brain Transplanting\n " ;
1627
1628
FVConstraint *From = dyn_cast<FVConstraint>(FromCV);
1628
1629
assert (From != nullptr );
1629
1630
// Transplant returns.
@@ -1639,6 +1640,7 @@ void FunctionVariableConstraint::brainTransplant(ConstraintVariable *FromCV,
1639
1640
1640
1641
void FunctionVariableConstraint::mergeDeclaration (ConstraintVariable *FromCV,
1641
1642
ProgramInfo &I) {
1643
+ llvm::errs () << " Merging\n " ;
1642
1644
FVConstraint *From = dyn_cast<FVConstraint>(FromCV);
1643
1645
assert (From != nullptr );
1644
1646
// Transplant returns.
@@ -1663,8 +1665,8 @@ void FunctionVariableConstraint::handle_params
1663
1665
// The only case where the params are not equal, and it's not
1664
1666
// an untype call, is a variadic call. Variadic calls wil not
1665
1667
// generate deferments.
1666
- if (paramsEq && To->getDeferredParams ().size () == 0
1667
- && From->getDeferredParams ().size () == 0 ) {
1668
+ if (paramsEq || ( To->getDeferredParams ().size () == 0
1669
+ && From->getDeferredParams ().size () == 0 ) ) {
1668
1670
for (unsigned i = 0 ; i < From->numParams (); i++) {
1669
1671
CVarSet &FromP = From->getParamVar (i);
1670
1672
CVarSet &P = To->getParamVar (i);
@@ -1676,29 +1678,24 @@ void FunctionVariableConstraint::handle_params
1676
1678
FVConstraint *Empty = fromEmpty ? From : To;
1677
1679
FVConstraint *Typed = fromEmpty ? To : From;
1678
1680
auto &CS = I.getConstraints ();
1681
+ // Copy constraint variables over the empty declaration
1682
+ for (unsigned i = 0 ; i < Typed->numParams (); i++) {
1683
+ CVarSet &TypedP = Typed->getParamVar (i);
1684
+ auto TypedV = getOnly (TypedP);
1685
+ CVarSet EmptyP;
1686
+ ConstraintVariable *NewV = TypedV->getCopy (CS);
1687
+ f (TypedV, NewV);
1688
+ EmptyP.insert (NewV);
1689
+ Empty->paramVars .push_back (EmptyP);
1690
+ constrainConsVarGeq (EmptyP, TypedP, CS, nullptr , Wild_to_Safe, false , &I);
1691
+ }
1692
+ // Constraint the deffered parameters
1679
1693
for (auto deferred : Empty->getDeferredParams ()) {
1680
- ConstraintResolver CB (I, deferred.C );
1681
1694
assert (Typed->numParams () == deferred.PS .size ());
1682
1695
for (unsigned i = 0 ; i < deferred.PS .size (); i++) {
1683
1696
CVarSet ParamDC = Typed->getParamVar (i);
1684
- CVarSet ArgDC = deferred.PS [i].first ;
1685
- Empty->paramVars .push_back (ParamDC);
1686
- auto TFD = deferred.TFD ;
1697
+ CVarSet ArgDC = deferred.PS [i];
1687
1698
constrainConsVarGeq (ParamDC, ArgDC, CS, &(deferred.PL ), Wild_to_Safe, false , &I);
1688
- if (AllTypes && TFD != nullptr &&
1689
- !CB.containsValidCons (ParamDC) &&
1690
- !CB.containsValidCons (ArgDC)) {
1691
- auto *PVD = TFD->getParamDecl (i);
1692
- auto &ABI = I.getABoundsInfo ();
1693
- BoundsKey PVKey, AGKey;
1694
- if ((CB.resolveBoundsKey (ParamDC, PVKey) ||
1695
- ABI.tryGetVariable (PVD, PVKey)) &&
1696
- (CB.resolveBoundsKey (ArgDC, AGKey) ||
1697
- ABI.tryGetVariable (deferred.PS [i].second ,
1698
- *(deferred.C ), AGKey))) {
1699
- ABI.addAssignment (PVKey, AGKey);
1700
- }
1701
- }
1702
1699
}
1703
1700
}
1704
1701
}
@@ -1708,11 +1705,9 @@ void FunctionVariableConstraint::handle_params
1708
1705
void
1709
1706
FunctionVariableConstraint::addDeferredParams
1710
1707
(PersistentSourceLoc PL,
1711
- ASTContext *C,
1712
- FunctionDecl *TFD,
1713
- std::vector<std::pair<CVarSet, Expr*>> Ps)
1708
+ std::vector<CVarSet> Ps)
1714
1709
{
1715
- ParamDeferment P = { PL, C, TFD, Ps };
1710
+ ParamDeferment P = { PL, Ps };
1716
1711
deferredParams.push_back (P);
1717
1712
return ;
1718
1713
}
0 commit comments