-
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
Conversation
Instead of considering a pointer "originally checked" if any one of the pointer levels in it is checked in the source, characterize each pointer level individually.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. One comment about the code change, and a suggestion for a few additional tests.
@@ -404,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 comment
The 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.
@@ -377,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 comment
The reason will be displayed to describe this comment to others. Learn more.
So in C++ you can override a method whose return type is T
with a method whose return type is S <: T
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The 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 override
annotation will trigger an error if try you an invalid override but, it doesn't complain here.
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 comment
The 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 void *
, should not be constrained to WILD?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes all look good. I didn't look at the test files beyond these new commits; assuming they are coming out the same, we can merge.
With this change
3C
is able to convert partially checked pointer types into fully checked pointer types.e.g.,
can be converted to
provided that
a
is used safely.More examples are in the test case
partial_checked.c
.A large number of test cases are modified as a side effect of this change. When converting the converted output from
3C
a second time to check for idempotence , we had to usediff
to check that no changes occurred in some cases.3C
will now not generate a converted output file in some of these cases.