[cfe-dev] Getting final value of macros that is included in the IR

Arnamoy Bhattacharyya arnamoy at ualberta.ca
Tue Jan 28 05:11:01 PST 2014


Hello;

I want to write a Clang pass that let me do the following:

1. I have a list of names of macros of interest.
2. I want to get the final value of the macro that is included in the
IR after preprocessing.  For example:

#if CLASS == 'A'
#define  TOTAL_KEYS_LOG_2    23
#endif

#if CLASS == 'B'
#define  TOTAL_KEYS_LOG_2    25
#endif

If in the above example, I compile using definition of CLASS as B, I
want to collect the value 25 for TOTAL_KEYS_LOG_2.  Of course,
beforehand I know the name of the macro I am interested in
(TOTAL_KEYS_LOG_2).

I have fairly used LLVM middle end but very new to the front end.
Thus any pointer will be greatly appreciated.

Thanks a lot;

-- 
Arnamoy Bhattacharyya
Scalable Parallel Computing Laboratory
CAB E66, Department of Computing Science, ETH Zurich
8092, Zurich, Switzerland
+41788757073



More information about the cfe-dev mailing list