-
Notifications
You must be signed in to change notification settings - Fork 5
293 convert partial #304
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
293 convert partial #304
Changes from all commits
b80ba17
11d8db1
2e577b2
56fd248
653c567
c531cb1
8139e9d
2f74c07
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -276,12 +276,6 @@ class PointerVariableConstraint : public ConstraintVariable { | |
// pointers. | ||
bool IsZeroWidthArray; | ||
|
||
// Was this variable a checked pointer in the input program? | ||
// This is important for two reasons: (1) externs that are checked should be | ||
// kept that way during solving, (2) nothing that was originally checked | ||
// should be modified during rewriting. | ||
bool OriginallyChecked; | ||
|
||
public: | ||
// Constructor for when we know a CVars and a type string. | ||
PointerVariableConstraint(CAtoms V, std::string T, std::string Name, | ||
|
@@ -290,8 +284,8 @@ class PointerVariableConstraint : public ConstraintVariable { | |
ConstraintVariable(PointerVariable, "" /*not used*/, Name), | ||
BaseType(T),vars(V),FV(F), ArrPresent(isArr), ItypeStr(is), | ||
partOFFuncPrototype(false), Parent(nullptr), | ||
BoundsAnnotationStr(""), IsGeneric(Generic), IsZeroWidthArray(false), | ||
OriginallyChecked(false) {} | ||
BoundsAnnotationStr(""), IsGeneric(Generic), IsZeroWidthArray(false) | ||
{} | ||
|
||
std::string getTy() const { return BaseType; } | ||
bool getArrPresent() const { return ArrPresent; } | ||
|
@@ -311,7 +305,9 @@ class PointerVariableConstraint : public ConstraintVariable { | |
|
||
bool getIsGeneric() const { return IsGeneric; } | ||
|
||
bool getIsOriginallyChecked() const override { return OriginallyChecked; } | ||
bool getIsOriginallyChecked() const override { | ||
return llvm::any_of(vars, [](Atom *A) { return isa<ConstAtom>(A); }); | ||
} | ||
|
||
bool solutionEqualTo(Constraints &CS, | ||
const ConstraintVariable *CV) const override; | ||
|
@@ -381,7 +377,7 @@ class PointerVariableConstraint : public ConstraintVariable { | |
// Get the set of constraint variables corresponding to the arguments. | ||
const std::set<ConstraintVariable *> &getArgumentConstraints() const; | ||
|
||
ConstraintVariable *getCopy(Constraints &CS) override; | ||
PointerVariableConstraint *getCopy(Constraints &CS) override; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So in C++ you can override a method whose return type is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wasn't sure of this myself, but it does seem to be the case. The |
||
|
||
// Retrieve the atom at the specified index. This function includes special | ||
// handling for generic constraint variables to create deeper pointers as | ||
|
@@ -408,10 +404,10 @@ class FunctionVariableConstraint : public ConstraintVariable { | |
FunctionVariableConstraint(FunctionVariableConstraint *Ot, | ||
Constraints &CS); | ||
// N constraints on the return value of the function. | ||
ConstraintVariable *ReturnVar; | ||
PVConstraint *ReturnVar; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Nice. I recall thinking in the past that this was always true and we should refactor. |
||
// A vector of K sets of N constraints on the parameter values, for | ||
// K parameters accepted by the function. | ||
std::vector<ConstraintVariable *> ParamVars; | ||
std::vector<PVConstraint *> ParamVars; | ||
// Storing of parameters in the case of untyped prototypes | ||
std::vector<ParamDeferment> deferredParams; | ||
// File name in which this declaration is found. | ||
|
@@ -438,7 +434,7 @@ class FunctionVariableConstraint : public ConstraintVariable { | |
clang::DeclaratorDecl *D, std::string N, | ||
ProgramInfo &I, const clang::ASTContext &C); | ||
|
||
ConstraintVariable *getReturnVar() const { | ||
PVConstraint *getReturnVar() const { | ||
return ReturnVar; | ||
} | ||
|
||
|
@@ -462,7 +458,7 @@ class FunctionVariableConstraint : public ConstraintVariable { | |
void brainTransplant(ConstraintVariable *From, ProgramInfo &I) override; | ||
void mergeDeclaration(ConstraintVariable *FromCV, ProgramInfo &I) override; | ||
|
||
ConstraintVariable *getParamVar(unsigned i) const { | ||
PVConstraint *getParamVar(unsigned i) const { | ||
assert(i < ParamVars.size()); | ||
return ParamVars.at(i); | ||
} | ||
|
@@ -488,7 +484,7 @@ class FunctionVariableConstraint : public ConstraintVariable { | |
|
||
void equateArgumentConstraints(ProgramInfo &P) override; | ||
|
||
ConstraintVariable *getCopy(Constraints &CS) override; | ||
FunctionVariableConstraint *getCopy(Constraints &CS) override; | ||
|
||
bool getIsOriginallyChecked() const override; | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -340,15 +340,14 @@ bool ProgramInfo::link() { | |
// If there was a checked type on a variable in the input program, it | ||
// should stay that way. Otherwise, we shouldn't be adding a checked type | ||
// to an extern function. | ||
if (!G->getReturnVar()->getIsOriginallyChecked()) { | ||
std::string Rsn = "Return value of an external function:" + FuncName; | ||
std::string Rsn = | ||
"Unchecked pointer in parameter or return of external function " + | ||
FuncName; | ||
if (!G->getReturnVar()->getIsGeneric()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why this exception? I guess if it's generic, we are assuming the underlying pointer, even if |
||
G->getReturnVar()->constrainToWild(CS, Rsn); | ||
} | ||
|
||
std::string rsn = "Inner pointer of a parameter to external function."; | ||
for (unsigned i = 0; i < G->numParams(); i++) | ||
if (!G->getParamVar(i)->getIsOriginallyChecked()) | ||
G->getParamVar(i)->constrainToWild(CS, rsn); | ||
for (unsigned I = 0; I < G->numParams(); I++) | ||
if (!G->getParamVar(I)->getIsGeneric()) | ||
G->getParamVar(I)->constrainToWild(CS, Rsn); | ||
} | ||
} | ||
|
||
|
Uh oh!
There was an error while loading. Please reload this page.