@@ -88,7 +88,7 @@ class ConstraintVariable {
88
88
// the name of the variable, false for just the type.
89
89
// The 'forIType' parameter is true when the generated string is expected
90
90
// to be used inside an itype
91
- virtual std::string mkString (EnvironmentMap &E,
91
+ virtual std::string mkString (const EnvironmentMap &E,
92
92
bool emitName=true , bool forItype=false ,
93
93
bool emitPointee=false ) const = 0;
94
94
@@ -123,20 +123,20 @@ class ConstraintVariable {
123
123
// have a binding in E other than top. E should be the EnvironmentMap that
124
124
// results from running unification on the set of constraints and the
125
125
// environment.
126
- bool isChecked (EnvironmentMap &E) const ;
126
+ bool isChecked (const EnvironmentMap &E) const ;
127
127
128
128
// Returns true if this constraint variable has a different checked type after
129
129
// running unification. Note that if the constraint variable had a checked
130
130
// type in the input program, it will have the same checked type after solving
131
131
// so, the type will not have changed. To test if the type is checked, use
132
132
// isChecked instead.
133
- virtual bool anyChanges (EnvironmentMap &E) const = 0;
133
+ virtual bool anyChanges (const EnvironmentMap &E) const = 0;
134
134
135
135
// Here, AIdx is the pointer level which needs to be checked.
136
136
// By default, we check for all pointer levels (or VarAtoms)
137
- virtual bool hasWild (EnvironmentMap &E, int AIdx = -1 ) const = 0;
138
- virtual bool hasArr (EnvironmentMap &E, int AIdx = -1 ) const = 0;
139
- virtual bool hasNtArr (EnvironmentMap &E, int AIdx = -1 ) const = 0;
137
+ virtual bool hasWild (const EnvironmentMap &E, int AIdx = -1 ) const = 0;
138
+ virtual bool hasArr (const EnvironmentMap &E, int AIdx = -1 ) const = 0;
139
+ virtual bool hasNtArr (const EnvironmentMap &E, int AIdx = -1 ) const = 0;
140
140
141
141
// Force use of equality constraints in function calls for this CV
142
142
virtual void equateArgumentConstraints (ProgramInfo &I) = 0;
@@ -158,14 +158,11 @@ class ConstraintVariable {
158
158
159
159
virtual ~ConstraintVariable () {};
160
160
161
- // Sometimes, constraint variables can be produced that are empty. This
162
- // tests for the existence of those constraint variables.
163
- virtual bool isEmpty (void ) const = 0;
164
-
165
161
virtual bool getIsOriginallyChecked () const = 0;
166
162
};
167
163
168
164
typedef std::set<ConstraintVariable *> CVarSet;
165
+ typedef Option<ConstraintVariable> CVarOption;
169
166
170
167
enum ConsAction {
171
168
Safe_to_Wild,
@@ -239,6 +236,12 @@ class PointerVariableConstraint : public ConstraintVariable {
239
236
bool &AllArray, bool &ArrayRun, bool Nt) const ;
240
237
void addArrayAnnotations (std::stack<std::string> &CheckedArrs,
241
238
std::deque<std::string> &EndStrs) const ;
239
+
240
+ // Utility used by the constructor to extract string representation of the
241
+ // base type that preserves macros where possible.
242
+ static std::string extractBaseType (DeclaratorDecl *D, QualType QT,
243
+ const Type *Ty, const ASTContext &C);
244
+
242
245
// Flag to indicate that this constraint is a part of function prototype
243
246
// e.g., Parameters or Return.
244
247
bool partOFFuncPrototype;
@@ -247,7 +250,7 @@ class PointerVariableConstraint : public ConstraintVariable {
247
250
// the values used as arguments.
248
251
std::set<ConstraintVariable *> argumentConstraints;
249
252
// Get solution for the atom of a pointer.
250
- const ConstAtom *getSolution (const Atom *A, EnvironmentMap &E) const ;
253
+ const ConstAtom *getSolution (const Atom *A, const EnvironmentMap &E) const ;
251
254
252
255
PointerVariableConstraint (PointerVariableConstraint *Ot, Constraints &CS);
253
256
PointerVariableConstraint *Parent;
@@ -341,7 +344,7 @@ class PointerVariableConstraint : public ConstraintVariable {
341
344
return S->getKind () == PointerVariable;
342
345
}
343
346
344
- std::string mkString (EnvironmentMap &E, bool EmitName =true ,
347
+ std::string mkString (const EnvironmentMap &E, bool EmitName =true ,
345
348
bool ForItype = false ,
346
349
bool EmitPointee = false ) const override ;
347
350
@@ -355,11 +358,11 @@ class PointerVariableConstraint : public ConstraintVariable {
355
358
void constrainToWild (Constraints &CS, const std::string &Rsn,
356
359
PersistentSourceLoc *PL) const override ;
357
360
void constrainOuterTo (Constraints &CS, ConstAtom *C, bool doLB = false );
358
- bool anyChanges (EnvironmentMap &E) const override ;
359
- bool anyArgumentIsWild (EnvironmentMap &E);
360
- bool hasWild (EnvironmentMap &E, int AIdx = -1 ) const override ;
361
- bool hasArr (EnvironmentMap &E, int AIdx = -1 ) const override ;
362
- bool hasNtArr (EnvironmentMap &E, int AIdx = -1 ) const override ;
361
+ bool anyChanges (const EnvironmentMap &E) const override ;
362
+ bool anyArgumentIsWild (const EnvironmentMap &E);
363
+ bool hasWild (const EnvironmentMap &E, int AIdx = -1 ) const override ;
364
+ bool hasArr (const EnvironmentMap &E, int AIdx = -1 ) const override ;
365
+ bool hasNtArr (const EnvironmentMap &E, int AIdx = -1 ) const override ;
363
366
364
367
void equateArgumentConstraints (ProgramInfo &I) override ;
365
368
@@ -369,8 +372,6 @@ class PointerVariableConstraint : public ConstraintVariable {
369
372
// Get the set of constraint variables corresponding to the arguments.
370
373
const std::set<ConstraintVariable *> &getArgumentConstraints () const ;
371
374
372
- bool isEmpty (void ) const override { return vars.size () == 0 ; }
373
-
374
375
ConstraintVariable *getCopy (Constraints &CS) override ;
375
376
376
377
// Retrieve the atom at the specified index. This function includes special
@@ -461,7 +462,7 @@ class FunctionVariableConstraint : public ConstraintVariable {
461
462
bool solutionEqualTo (Constraints &CS,
462
463
const ConstraintVariable *CV) const override ;
463
464
464
- std::string mkString (EnvironmentMap &E, bool EmitName =true ,
465
+ std::string mkString (const EnvironmentMap &E, bool EmitName =true ,
465
466
bool ForItype = false ,
466
467
bool EmitPointee = false ) const override ;
467
468
void print (llvm::raw_ostream &O) const override ;
@@ -471,28 +472,15 @@ class FunctionVariableConstraint : public ConstraintVariable {
471
472
void constrainToWild (Constraints &CS, const std::string &Rsn) const override ;
472
473
void constrainToWild (Constraints &CS, const std::string &Rsn,
473
474
PersistentSourceLoc *PL) const override ;
474
- bool anyChanges (EnvironmentMap &E) const override ;
475
- bool hasWild (EnvironmentMap &E, int AIdx = -1 ) const override ;
476
- bool hasArr (EnvironmentMap &E, int AIdx = -1 ) const override ;
477
- bool hasNtArr (EnvironmentMap &E, int AIdx = -1 ) const override ;
475
+ bool anyChanges (const EnvironmentMap &E) const override ;
476
+ bool hasWild (const EnvironmentMap &E, int AIdx = -1 ) const override ;
477
+ bool hasArr (const EnvironmentMap &E, int AIdx = -1 ) const override ;
478
+ bool hasNtArr (const EnvironmentMap &E, int AIdx = -1 ) const override ;
478
479
479
480
void equateArgumentConstraints (ProgramInfo &P) override ;
480
481
481
482
ConstraintVariable *getCopy (Constraints &CS) override ;
482
483
483
- // An FVConstraint is empty if every constraint associated is empty.
484
- bool isEmpty (void ) const override {
485
-
486
- if (ReturnVar != nullptr )
487
- return false ;
488
-
489
- for (const auto &u : ParamVars)
490
- if (!u->isEmpty ())
491
- return false ;
492
-
493
- return true ;
494
- }
495
-
496
484
bool getIsOriginallyChecked () const override ;
497
485
498
486
~FunctionVariableConstraint () override {};
0 commit comments