[Qt-creator] Clang based code model

Konstantin Tokarev annulen at yandex.ru
Sat Feb 15 09:02:11 CET 2014



14.02.2014, 23:57, "Pawel" <pawelfaron87 at wp.pl>:
> Hello,
>
> I've tried the Clang code model and unfortunately found out that it
> doesn't support the old K&R style function parameter declarations like
> this:
>
> int func(a, b, c)
>     int a;
>     int b;
>     int c;
> {
>    return a + b + c;
> }
>
> You may not believe there are still people who use it... and almost every
> IDE is at lost with it :) Do you think that there is anything that can be
> done with it?

clang compiler parses this code just fine, so it should be possible to fix.

$ clang -cc1 -ast-dump knr_params.c
TranslationUnitDecl 0x200cf70 <<invalid sloc>>
|-TypedefDecl 0x200d240 <<invalid sloc>> __builtin_va_list 'char *'
`-FunctionDecl 0x200d380 <knr_params.c:1:1, line:7:1> func 'int (int, int, int)'
  |-ParmVarDecl 0x200d280 <line:2:5, col:9> a 'int'
  |-ParmVarDecl 0x200d2c0 <line:3:5, col:9> b 'int'
  |-ParmVarDecl 0x200d300 <line:4:5, col:9> c 'int'
  `-CompoundStmt 0x200d4a8 <line:5:1, line:7:1>
    `-ReturnStmt 0x200d498 <line:6:4, col:19>
      `-BinaryOperator 0x200d480 <col:11, col:19> 'int' '+'
        |-BinaryOperator 0x200d440 <col:11, col:15> 'int' '+'
        | |-ImplicitCastExpr 0x200d420 <col:11> 'int' <LValueToRValue>
        | | `-DeclRefExpr 0x200d3ec <col:11> 'int' lvalue ParmVar 0x200d280 'a' 'int'
        | `-ImplicitCastExpr 0x200d430 <col:15> 'int' <LValueToRValue>
        |   `-DeclRefExpr 0x200d404 <col:15> 'int' lvalue ParmVar 0x200d2c0 'b' 'int'
        `-ImplicitCastExpr 0x200d470 <col:19> 'int' <LValueToRValue>
          `-DeclRefExpr 0x200d458 <col:19> 'int' lvalue ParmVar 0x200d300 'c' 'int'


Regards,
Konstantin



More information about the Qt-creator mailing list