prettyprint statement

Hi,
   When using prettyPrint (or Rewriter::ConverToString()) to print a
statement, clang prints some statements with ";" and some without it. The
statement "int a,b;" is printed as it is while the statement "a--;" is
printed as "a--" omitting the ";" at the end. How can I tell which
statements retain ";" and which statements omit it. Is there any special
reason for not including ";" in some statements?

Regards,
Adil

Hi,
  When using prettyPrint (or Rewriter::ConverToString()) to print a
statement, clang prints some statements with ";" and some without it. The
statement "int a,b;" is printed as it is while the statement "a--;" is
printed as "a--" omitting the ";" at the end. How can I tell which
statements retain ";" and which statements omit it. Is there any special
reason for not including ";" in some statements?

I consider this a bug. All statements that need a semicolon should print one. Can I interest you in submitting a patch to fix this?

  - Doug

Hi,
I believe that the problem comes when the stmtprinter handles expressions. All statements which are not expressions are printed fine while statements which are also expressions (a = 1;) do not have a semicolon(:wink: at the end. Please tell me the procedure to submit a patch fix? I will be very happy to contribute.

Regards,
Adil

Make changes (don't forget to add tests), create a patch with 'svn
diff' and submit the patch to cfe-commits for review.

This section in the docs
http://llvm.org/docs/DeveloperPolicy.html#one-off-patches (and the
whole page, too) might be helpful.

Dmitri

Hi,
I believe that the problem comes when the stmtprinter handles expressions. All statements which are not expressions are printed fine while statements which are also expressions (a = 1;) do not have a semicolon(:wink: at the end.

Right. You’ll likely need to add some context to the pretty printer so that it will add the ; to expressions in a statement context.

Please tell me the procedure to submit a patch fix? I will be very happy to contribute.

There is some documentation here:

http://llvm.org/docs/DeveloperPolicy.html#making-a-patch

Clang patches should go to cfe-commits. Thanks!

  • Doug