[cfe-dev] Using clang to reformat code.

James Courtier-Dutton james.dutton at gmail.com
Fri Jan 24 01:25:04 PST 2014


Example input source code:
int main() {
  int a,b,c;
  a = 1;
  b = a + 3;
  c = b * 4;
  printf("Result = %d\n", c);

Desired output source code:
int main() {
  int a;
  a = (1 + 3) * 4;
  printf("Result = %d\n", a);

I.e. Is there a way to automatically take multi-line basic
calculations and turn them into a single line of more complex
I know these sorts of optimizations are done during compiling, but I
would like the actual source code to be simplified and made easier to

Example use. The "input source code" is some auto-generated code. I
wish to process that code to make it easier to read, by producing the
desired "output source code".

Kind Regards


More information about the cfe-dev mailing list