clang

Hi,

if I build the ast from a C++ Code, some Nodes are not in the ast. Is it
possible that clang can´t read every Element from a C++ Code?

Could you show some complete examples of the issue you're discussing?
(a simple, but complete, piece of code as well as the command(s) you
ran (you might want to try clang -cc1 -ast-dump as discussed here:
http://clang.llvm.org/docs/IntroductionToTheClangAST.html ) & the
output you got & the output you expected)

[+cfe-dev]

Hi,

I use LibClang and if I read the ast, the following Example are in the ast
or not in the ast.

This Example is in the ast:
static STSRET StatusFktWert
   (
      VTYP A,
      STATUS16 B , /* aktueller Status der PV
*/
      STATUS16 C , /* aktueller Status der PV 2
*/
      STATUS32 D , /* Statusmaske mit abzufragenden Bits
*/
      INFO32 *E /* Zg-> Ergebnis
*/
   );

This Example is not in the ast:
static STSRET StatusFktWert
   (
      VTYP aVtype, // PV type
      STATUS16 aPvState, // aktueller Status der PV
      STATUS16 aPvState2, // aktueller Status der PV 2
      STATUS32 aStateMask, // Statusmaske mit abzufragenden Bits
      INFO32* aResult, // Zg-> Ergebnis
      GETWERT GetWertAME, // Pointer to GetWertSM or SimGetWert
      SATZNR aRecnum // Record number
   );
        If I Use clang -cc1 -ast-dump this one is not there, too.

This IF-Else Condition is not in the ast:
   if (ameld->status1.bit.TYP == ZWEI_BIT_ABME)
      *zustand = AUSSTELLUNG;
   else
      *zustand = 0;

        My speculation is, that the If-Condition is FAlSE, if I write
if(1==1)..... the whole IF-Else Condition is in the ast.

If I use clang -cc1 -ast-dump the If-Else Condition is there.

Sorry, I'm still having trouble following your examples as they are
incomplete (& I'm not terribly familiar with libclang's behavior - but
I would be surprised if it differs so wildly from -ast-dump as you
describe). It would be helpful if you could provide complete examples
(the entire source files - reduced to the simplest complete example -
that you're using as input, and possibly a reduced (but
standalone/complete) example of the libclang program you're using to
navigate the AST).

Perhaps you are navigating the CFG? (I don't know if libclang exposes
this - if it does, then you'll find that things that are trivially
compile-time unreachable won't appear in the CFG, this is by design)

- David

Kicking this back to the ML because I'm not as familiar with the c API
or python binding on top of it (& don't have the time to dig into it
further right now).