-
Notifications
You must be signed in to change notification settings - Fork 19
Description
This issue was copied from checkedc/checkedc-clang#8
This change extends the clang IR to represent Checked C bounds expressions and optional bounds expressions for variable declarations. It also adds support for parsing bounds expressions and modifies parsing of function parameter lists to parse optional bounds expressions.
Bounds expressions are represented in the IR by adding a new abstract class BoundsExpr and subclassing it for count bounds expressions (count(e1) and byte_count(e1)), range bounds expressions (bounds(e1, e2)), and nullary bounds expressions(bounds(none)). AST printing, serialization, traversal, and tree transformations are extended handle the new expressions.
Bounds expressions are attached to variable declarations by adding an additional member to VarDecls. Many VarDecls will not have bounds expressions, so this adds extra space overhead to the representation of VarDecls. We can revisit this later if it becomes an issue.
To test the new bounds expressions, we add parsing of bounds expressions for function parameter lists and attach the parsed bounds expressions to the VarDecls for the parameters.
Bounds expressions for parameters need to be processed in a scope with all the parameters available. They are currently being processed in a scope that contains the parameters seen so far. This is a little complicated to implement in clang. You have to delay parsing of the bounds expressions. I will come back to this after getting basic parsing of bounds expressions working. I've opened issue #7 to track this.
Testing:
- This passes the current test baseline for this snapshot of clang:
- Wrote new feature tests of parsing of parameters with bounds declarations. There will be a separate pull request to the Github CheckedC repo for these tests.
- Passes the existing Checked C tests.
Expected Passes : 8942
Expected Failures : 21
Unsupported Tests : 206
Unexpected Failures: 3
- We still need to test AST printing, serialization, traversal, and tree
transformations. I've opened issues test AST printing of clang IR with new checked C types and bounds expressions #4 , test serialization/deserialization of clang IR with new checked types and new bounds expressions #3, test traversal of ASTs with new checked types and bounds expressions #5, and test tree transformations of ASTs with new checked types and bounds expressions #6 to track this.