Skip to content

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

Merged
merged 8 commits into from
Oct 28, 2020
Merged

293 convert partial #304

merged 8 commits into from
Oct 28, 2020

Conversation

john-h-kastner
Copy link
Collaborator

@john-h-kastner john-h-kastner commented Oct 26, 2020

With this change 3C is able to convert partially checked pointer types into fully checked pointer types.
e.g.,

_Ptr<int *> a;

can be converted to

_Ptr<_Ptr<int> a;

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 use diff to check that no changes occurred in some cases. 3C will now not generate a converted output file in some of these cases.

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.
Copy link
Member

@mwhicks1 mwhicks1 left a 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;
Copy link
Member

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;
Copy link
Member

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 ?

Copy link
Collaborator Author

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())
Copy link
Member

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?

Copy link
Member

@mwhicks1 mwhicks1 left a 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.

@john-h-kastner john-h-kastner merged commit 04ccde0 into master Oct 28, 2020
@mattmccutchen-cci mattmccutchen-cci mentioned this pull request Oct 28, 2020
2 tasks
@john-h-kastner john-h-kastner deleted the 293ConvertPartial branch March 26, 2021 03:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants