-
Notifications
You must be signed in to change notification settings - Fork 274
Fix Bison grammar issues preventing us from parsing CoreFoundation #5438
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
Fix Bison grammar issues preventing us from parsing CoreFoundation #5438
Conversation
Our previous attempt only worked with names like `short` or `unsigned`, but not with e.g. `unsigned short` or `uint32_t`. This patch rectifies that. Note that unlike clang we currently don't allow CV qualifiers for underlying types. Since these are ignored by clang anyway, we don't expect to see too much code in the wild making use of that feature however.
cefba9d
to
ee0d3e0
Compare
-- | ||
gcc doesn't support postfix attributes but clang does, and Apples CoreFoundation framework makes use of this for availability macros. | ||
|
||
Testing both the inline and non-inline variants because these are different cases in our parser. |
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.
⛏️ Missing newline.
@@ -1837,13 +1837,21 @@ enum_name: | |||
} | |||
; | |||
|
|||
basic_type_name_list: | |||
basic_type_name | |||
| basic_type_name_list basic_type_name |
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.
ℹ️ We probably want something like the following, in order to actually build the list -
| basic_type_name_list basic_type_name
{
$$=merge($1, $2);
}
;
I have added this ℹ️ comment as a note about future work which will likely be needed eventually. This is not a blocking comment.
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.
For onlookers: actually fully supporting this feature is in the pipeline, just getting this. to parse is higher priority though so it comes first.
c4840a3
to
712c221
Compare
With postfix attributes we mean something like int f() __attribute__((in this position)); This is used in Apple's CoreFoundation framework so our inability to parse this was limiting CBMC usability for code written for Apple operating systems.
712c221
to
7d2a23b
Compare
Codecov Report
@@ Coverage Diff @@
## develop #5438 +/- ##
============================================
- Coverage 68.21% 32.26% -35.96%
============================================
Files 1178 923 -255
Lines 97561 81128 -16433
============================================
- Hits 66554 26178 -40376
- Misses 31007 54950 +23943
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Codecov Report
@@ Coverage Diff @@
## develop #5438 +/- ##
========================================
Coverage 68.21% 68.21%
========================================
Files 1178 1178
Lines 97561 97561
========================================
Hits 66554 66554
Misses 31007 31007
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
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.
My Yacc skills are quite rusty.... but I think this looks OK to me.
There are currently two issues preventing us from parsing Apple's CoreFoundation framework: For one, we still don't quite parse underlying enum types correctly, so for example
and
would previously fail to parse, and we didn't allow gcc-style attributes after a functions parameter list:
which gcc itself doesn't permit either but is valid in Clang's C dialect, and used this way by Apple across their frameworks for their
API_AVAILABLE
andAPI_UNAVAILABLE
macros.This fixes both of these issues.