Skip to content

Add printer that prints CILs internal AST representation#15

Closed
michael-schwarz wants to merge 10 commits intogoblint:developfrom
keremc:develop
Closed

Add printer that prints CILs internal AST representation#15
michael-schwarz wants to merge 10 commits intogoblint:developfrom
keremc:develop

Conversation

@michael-schwarz
Copy link
Copy Markdown
Member

This can be helpful for understanding how C code is represented by Cil.

end (* class defaultCilPrinterClass *)

let defaultCilPrinter = new defaultCilPrinterClass
let defaultCilPrinter = new cilAstDumpClass
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Let's not change the default one to this, we should leave it as it as.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Just wanted to ask.
What's the difference to defaultCilPrinterClass? Does it just pretty print as valid C?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yes, it is e.g. the one we use for --enable justcil in Goblint.

@keremc
Copy link
Copy Markdown

keremc commented Sep 14, 2020

Hello. Please note that this AST printer is not yet complete. For example, at the moment, it fails for any expression that is not a PlusA or a Mult. I only wrote it to get a better understanding of how CIL models the following code, which contains a variably-modified type:

int main(void) {
  int n = 4;
  typedef int vla[n];
  n++;
  vla a;
  int i = sizeof(a);
}

@michael-schwarz
Copy link
Copy Markdown
Member Author

Do we want to merge this so people can use it if they want to understand details about the representation? Or should we just close it?
I'm fine with either - @sim642 Any opinions?

@sim642
Copy link
Copy Markdown
Member

sim642 commented Nov 25, 2024

There's plainCilPrinterClass, which is used by d_plainexp, d_plaintype, etc, which seems to be similar but based on a quick look has two differences:

  1. It doesn't handle statements.
  2. It takes some shortcuts and makes some omissions, e.g. BinOp(PlusA,e1,e2,t) is printed as PlusA(e1,e2).

I think we can just close it for now. There hasn't been need to have something more than the plain printers much.

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