@@ -32,9 +32,10 @@ using namespace clang;
3232// is the taken from the constraint graph solution. The unchecked portion is
3333// assigned to string reference Type and the checked (itype) portion is assigned
3434// to the string reference Itype.
35- void DeclRewriter::buildItypeDecl (PVConstraint *Defn , DeclaratorDecl *Decl,
35+ void DeclRewriter::buildItypeDecl (PVConstraint *Int, PVConstraint *Ext , DeclaratorDecl *Decl,
3636 std::string &Type, std::string &IType,
3737 ProgramInfo &Info, ArrayBoundsRewriter &ABR) {
38+ PVConstraint *Defn = Ext;
3839 const EnvironmentMap &Env = Info.getConstraints ().getVariables ();
3940 // True when the type of this variable is defined by a typedef, and the
4041 // constraint variable representing the typedef solved to an unchecked type.
@@ -54,18 +55,20 @@ void DeclRewriter::buildItypeDecl(PVConstraint *Defn, DeclaratorDecl *Decl,
5455 // unchecked portion of the itype. The typedef is used directly in the checked
5556 // portion of the itype.
5657 bool IsCheckedTypedef = Defn->isTypedef () && !IsUncheckedTypedef;
57- if (IsCheckedTypedef || Defn->getFV ()) {
58+ if (IsCheckedTypedef || Defn->getFV () || true /* test */ ) {
5859 // Generate the type string from PVC if we need to unmask a typedef, this is
5960 // a function pointer, or this is a constant size array. When unmasking a
6061 // typedef, the expansion of the typedef does not exist in the original
6162 // source, so it must be constructed. For function pointers, a function
6263 // pointer appearing in the unchecked portion of an itype must contain an
6364 // extra set of parenthesis (e.g. `void ((*f)())` instead of `void (f*)()`)
6465 // for the declaration to parse correctly.
65- Type = Defn ->mkString (Info.getConstraints (),
66+ Type = (Int ? Int : Ext) ->mkString (Info.getConstraints (),
6667 MKSTRING_OPTS (UnmaskTypedef = IsCheckedTypedef,
67- ForItypeBase = true ));
68- } else {
68+ ForItypeBase = !Int));
69+ }
70+ #if 0
71+ else {
6972 // In the remaining cases, the unchecked portion of the itype is just the
7073 // original type of the pointer. The first branch tries to generate the type
7174 // using the type and name for this specific declaration. This is important
@@ -84,6 +87,7 @@ void DeclRewriter::buildItypeDecl(PVConstraint *Defn, DeclaratorDecl *Decl,
8487 Type += " ";
8588 }
8689 }
90+ #endif
8791
8892 IType = " : itype(" ;
8993 IType += Defn->mkString (Info.getConstraints (),
@@ -204,7 +208,7 @@ void DeclRewriter::rewriteDecls(ASTContext &Context, ProgramInfo &Info,
204208 std::string Type, IType;
205209 // VarDecl and FieldDecl subclass DeclaratorDecl, so the cast will
206210 // always succeed.
207- DeclRewriter::buildItypeDecl (PV, cast<DeclaratorDecl>(D), Type, IType,
211+ DeclRewriter::buildItypeDecl (nullptr , PV, cast<DeclaratorDecl>(D), Type, IType,
208212 Info, ABRewriter);
209213 NewTy += Type + IType;
210214 } else {
@@ -780,12 +784,12 @@ void FunctionDeclBuilder::buildCheckedDecl(
780784}
781785
782786
783- void FunctionDeclBuilder::buildItypeDecl (PVConstraint *Defn ,
787+ void FunctionDeclBuilder::buildItypeDecl (PVConstraint *Int, PVConstraint *Ext ,
784788 DeclaratorDecl *Decl,
785789 std::string &Type, std::string &IType,
786790 bool &RewriteParm, bool &RewriteRet) {
787791 Info.getPerfStats ().incrementNumITypes ();
788- DeclRewriter::buildItypeDecl (Defn , Decl, Type, IType, Info, ABRewriter);
792+ DeclRewriter::buildItypeDecl (Int, Ext , Decl, Type, IType, Info, ABRewriter);
789793 RewriteParm = true ;
790794 RewriteRet |= isa_and_nonnull<FunctionDecl>(Decl);
791795}
@@ -804,7 +808,7 @@ void FunctionDeclBuilder::buildDeclVar(const FVComponentVariable *CV,
804808 bool ItypeSolution = CV->hasItypeSolution (Info.getConstraints ());
805809 if (ItypeSolution ||
806810 (CheckedSolution && _3COpts.ItypesForExtern && !StaticFunc)) {
807- buildItypeDecl (CV->getExternal (), Decl, Type, IType, RewriteParm,
811+ buildItypeDecl (CV->getInternal (), CV-> getExternal (), Decl, Type, IType, RewriteParm,
808812 RewriteRet);
809813 return ;
810814 }
0 commit comments