@@ -640,22 +640,22 @@ void ProgramInfo::addVariable(clang::DeclaratorDecl *D,
640640 NewCV = F;
641641
642642 auto RetTy = FD->getReturnType ();
643- unifyIfTypedef (RetTy. getTypePtr () , *AstContext, FD, F->getExternalReturn ());
644- unifyIfTypedef (RetTy. getTypePtr () , *AstContext, FD, F->getInternalReturn ());
643+ unifyIfTypedef (RetTy, *AstContext, F->getExternalReturn (), Wild_to_Safe );
644+ unifyIfTypedef (RetTy, *AstContext, F->getInternalReturn (), Safe_to_Wild );
645645 ensureNtCorrect (RetTy, *AstContext, F->getExternalReturn ());
646646 ensureNtCorrect (RetTy, *AstContext, F->getInternalReturn ());
647647
648648 // Add mappings from the parameters PLoc to the constraint variables for
649649 // the parameters.
650650 for (unsigned I = 0 ; I < FD->getNumParams (); I++) {
651651 ParmVarDecl *PVD = FD->getParamDecl (I);
652- const Type *Ty = PVD->getType (). getTypePtr ();
652+ QualType ParamTy = PVD->getType ();
653653 PVConstraint *PVInternal = F->getInternalParam (I);
654654 PVConstraint *PVExternal = F->getExternalParam (I);
655- unifyIfTypedef (Ty , *AstContext, PVD, PVInternal );
656- unifyIfTypedef (Ty , *AstContext, PVD, PVExternal );
657- ensureNtCorrect (PVD-> getType () , *AstContext, PVInternal);
658- ensureNtCorrect (PVD-> getType () , *AstContext, PVExternal);
655+ unifyIfTypedef (ParamTy , *AstContext, PVExternal, Wild_to_Safe );
656+ unifyIfTypedef (ParamTy , *AstContext, PVInternal, Safe_to_Wild );
657+ ensureNtCorrect (ParamTy , *AstContext, PVInternal);
658+ ensureNtCorrect (ParamTy , *AstContext, PVExternal);
659659 PVInternal->setValidDecl ();
660660 PersistentSourceLoc PSL = PersistentSourceLoc::mkPSL (PVD, *AstContext);
661661 // Constraint variable is stored on the parent function, so we need to
@@ -675,13 +675,13 @@ void ProgramInfo::addVariable(clang::DeclaratorDecl *D,
675675
676676 } else if (VarDecl *VD = dyn_cast<VarDecl>(D)) {
677677 assert (!isa<ParmVarDecl>(VD));
678- const Type *Ty = VD->getTypeSourceInfo ()->getTypeLoc ().getTypePtr ();
679- if (Ty ->isPointerType () || Ty ->isArrayType ()) {
678+ QualType QT = VD->getTypeSourceInfo ()->getTypeLoc ().getType ();
679+ if (QT ->isPointerType () || QT ->isArrayType ()) {
680680 PVConstraint *P = new PVConstraint (D, *this , *AstContext);
681681 P->setValidDecl ();
682682 NewCV = P;
683683 std::string VarName (VD->getName ());
684- unifyIfTypedef (Ty , *AstContext, VD , P);
684+ unifyIfTypedef (QT , *AstContext, P);
685685 ensureNtCorrect (VD->getType (), *AstContext, P);
686686 if (VD->hasGlobalStorage ()) {
687687 // If we see a definition for this global variable, indicate so in
@@ -699,10 +699,10 @@ void ProgramInfo::addVariable(clang::DeclaratorDecl *D,
699699 }
700700
701701 } else if (FieldDecl *FlD = dyn_cast<FieldDecl>(D)) {
702- const Type *Ty = FlD->getTypeSourceInfo ()->getTypeLoc ().getTypePtr ();
703- if (Ty ->isPointerType () || Ty ->isArrayType ()) {
702+ QualType QT = FlD->getTypeSourceInfo ()->getTypeLoc ().getType ();
703+ if (QT ->isPointerType () || QT ->isArrayType ()) {
704704 PVConstraint *P = new PVConstraint (D, *this , *AstContext);
705- unifyIfTypedef (Ty , *AstContext, FlD , P);
705+ unifyIfTypedef (QT , *AstContext, P);
706706 NewCV = P;
707707 NewCV->setValidDecl ();
708708 }
@@ -725,16 +725,16 @@ void ProgramInfo::ensureNtCorrect(const QualType &QT, const ASTContext &C,
725725 }
726726}
727727
728- void ProgramInfo::unifyIfTypedef (const Type *Ty , ASTContext &Context,
729- DeclaratorDecl *Decl, PVConstraint *P ) {
730- if (const auto *TDT = dyn_cast<TypedefType>(Ty )) {
728+ void ProgramInfo::unifyIfTypedef (const QualType &QT , ASTContext &Context,
729+ PVConstraint *P, ConsAction CA ) {
730+ if (const auto *TDT = dyn_cast<TypedefType>(QT. getTypePtr () )) {
731731 auto *TDecl = TDT->getDecl ();
732732 auto PSL = PersistentSourceLoc::mkPSL (TDecl, Context);
733733 auto O = lookupTypedef (PSL);
734734 if (O.hasValue ()) {
735735 auto *Bounds = &O.getValue ();
736- P->setTypedef (TDecl , TDecl->getNameAsString ());
737- constrainConsVarGeq (P, Bounds, CS, &PSL, Same_to_Same, true , this );
736+ P->setTypedef (Bounds , TDecl->getNameAsString ());
737+ constrainConsVarGeq (P, Bounds, CS, &PSL, CA, false , this );
738738 }
739739 }
740740}
0 commit comments