Skip to content
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

RecursiveASTVisitor: Traverse the child of a BoundsValueExpr #978

Closed
secure-sw-dev-bot opened this issue Jan 16, 2022 · 0 comments
Closed

Comments

@secure-sw-dev-bot
Copy link

This issue was copied from microsoft/checkedc-clang#978


Fixes #974
Fixes #977

This PR modifies RecursiveASTVisitor to traverse the child (E->getTemporaryBinding) of a BoundsValueExpr by default. This allows the CollectVarSetHelper in SemaBounds.cpp to determine the correct set of variables involved in expressions that contain a BoundsValueExpr. For example, in the expression BoundsValue(TempBinding(x)) + y, CollectVarSetHelper will return the set { x, y } rather than { y }.

Two other classes in SemaBounds.cpp that use RecursiveASTVisitor now override this behavior so that they do not traverse the temporary binding of a BoundsValueExpr:

  • NonModifyingExprSema: expressions within bounds values should not be considered modifying.
  • VariableCountHelper: variables within bounds values should not contribute to the variable occurrence count within an expression. The ReplaceVariable method ReplaceVariable(E, V, OriginalValue) returns the original expression E if VariableCountHelper returns 0 as the variable occurrence count of V in E. If V occurs within a BoundsValueExpr within E, then ReplaceVariable should return E without traversing it. Therefore, for an expression such as BoundsValue(TempBinding(x)), VariableCountHelper should return 0 as the occurrence count of x.

Testing:

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

No branches or pull requests

1 participant