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

Support for C11 #24

Open
wants to merge 17 commits into
base: develop
Choose a base branch
from
Open

Support for C11 #24

wants to merge 17 commits into from

Conversation

michael-schwarz
Copy link
Member

@michael-schwarz michael-schwarz commented Dec 4, 2020

Adds support for C11 to Goblint (see #13).

This is work done by @coslu for his Bachelor's thesis.


Cherry-picked

@michael-schwarz michael-schwarz mentioned this pull request Dec 4, 2020
22 tasks
@michael-schwarz
Copy link
Member Author

michael-schwarz commented Dec 8, 2020

Still to investigate: Does cpp actually produce code that contains __generic ?

It does and one would ideally like to compile it away in CIL such that Goblint does not need to handle it.

Copy link
Member

@sim642 sim642 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there some reason this PR hasn't been merged yet?

According to @vesalvojdani newer Linux kernels use _Generic so it would be good to support it, especially since those are fully type-based, so shouldn't be a problem to do in CIL.

let typ =
let rec get_typ lst = match lst with
| (TDefault, e) :: rest -> default_typ := typeOf e; get_typ rest
| (t, e) :: rest -> if t = exp_typ then typeOf e else get_typ rest
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This structural polymorphic type comparison is probably incorrect. The standard calls for lvalue conversions on expr and then the comparison is by compatible types.

make_cil_list lst []
in
let exp_typ = typeOf exp in
let default_typ = ref voidType in
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be ref None instead, unless somewhere the standard says default should be equivalent to void.

in
get_typ cil_list
in
finishExp empty (Generic(exp, (cil_list))) typ
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since the type switch case is already resolved there just to return the correct type, there's no need to keep the Generic expression, but we could also just return the expression for that particular case. Then Generic doesn't have to exist in CIL AST at all (it's resolved by type during the conversion here). Moreover, Goblint doesn't have to do anything extra to handle Generic everywhere as the logic would always be the same.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, generic should be compiled away!

@michael-schwarz
Copy link
Member Author

michael-schwarz commented Sep 9, 2021

Is there some reason this PR hasn't been merged yet?

Because no-one has added C11 support to Goblint yet (C11 threading, AST changes if required, handling of thread-local variables, ...). We wanted to bundle these into a BSc thesis at some point, but I guess we can do a minimal support first.

@sim642
Copy link
Member

sim642 commented Feb 17, 2022

I added a TODO list into the original PR description with a list of things we have already cherry-picked out of here. That should help us know when at one point we have cherry-picked everything from here.

@michael-schwarz
Copy link
Member Author

Is this useful in it's current (out-of-sync) state? Or should it be closed for now?

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.

4 participants