[LLVMdev] Preprocessor: output only definedness testing macro's

gorny gorny at santarago.org
Mon Jul 2 14:34:31 PDT 2012


Hi all,

I'm looking for some guidance on how to implement the following GCC behavior
using the Clang libaries. For a simple input file I want to get all the macro's
which are actually being tested against in that specific file. The following
reproduces the behavior:

$ cat > test.c << EOF

#ifdef AA
  #define BLABLA
#else
  #define WUTWUT
#endif

#ifdef WUTWUT
#endif

#define X 2

#if X == 2
  #define WOT
#elif X == 3
  #define WOT
#else
  #define FLOP
#endif
EOF


$ cpp -E -dU  - < hello.c | egrep "(#undef|#define)"
#undef AA
#define WUTWUT
#define X 2

The -dU option is not implemented in Clang and I'm struggling a bit to get
through all the doxygen documentation of the Preprocessor libraries. Any
suggestions would be greatly appreciated.

Thanks!



More information about the llvm-dev mailing list