Add attribute goblint_cil_nested
to local varinfo
s that are not declared at top scope
#155
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
CIL pulls up all declarations inside a function to the top-level scope of that function. This transformation turns code that has Undefined Behavior into code without any UB, which is of course perfectly ok for a compiler to do, but bad for tools who want to flag this type of UB despite working on the output of CIL.
An example of this is the following snippet:
After CIL,
j
is pulled to the top scope and there is no more UB.A rewrite to properly handle scopes seems tedious, and also of questionable value, since it would be a breaking change and would make using CIL more complicated.
This adds an option
addNestedScopeAttr
tocabs2cil
. When it is enabled, this adds an attributegoblint_cil_nested
to allvarinfos
for locals that occur inside a nested scope. This way, sound tools can overapproximate for which variables there may be issues.As the flag is off by default, this should not cause any changes in behavior for other users.
c.f. goblint/analyzer#1199