[cfe-dev] Is is possible to use ParseAST() without adding the clang predefines?

Daniel Dunbar daniel at zuster.org
Sat Feb 21 12:13:10 PST 2009


On Sat, Feb 21, 2009 at 11:45 AM, Roberto Bagnara <bagnara at cs.unipr.it> wrote:
> Daniel Dunbar wrote:
>>
>> It isn't inconceivable that we would want clang to be able to mimic
>> other compilers as a general feature. Have you considered what would
>> be necessary for DefineBuiltinMacro to directly support compatibility
>> with whatever other compilers you are interested in?
>
> I am not sure I understand the question.  What we do now is to undefine
> (some of) the macros predefined by clang, and replace (some of) them with
> the predefined macros of the other compiler.  This works for macros,
> but we have a problem because of the  __builtin_va_list typedef:
> we would want this to go away.

What I meant by my comment was that instead of finding a way to
refactor things that ParseAST doesn't end up calling
InitializePredefinedMacros, it may make more sense to add support in
DefineBuiltinMacros for other compilers; this could benefit all
clients. For example, pulling out the compiler specific predefines
into separate classes just as we do for targets.

> We are wondering if clang could be generalized so as to allow the
> client application to decide what should be predefined and what not.

__builtin_va_list poses a problem because other parts of clang are
relying on it to be present, I don't know this code well enough to
comment on how easy it would be to break that dependency (or enough
about how va_list is handled in other compilers).

 - Daniel

> All the best,
>
>  Roberto
>
> --
> Prof. Roberto Bagnara
> Computer Science Group
> Department of Mathematics, University of Parma, Italy
> http://www.cs.unipr.it/~bagnara/
> mailto:bagnara at cs.unipr.it
>



More information about the cfe-dev mailing list