[cfe-dev] [PATCH] Automatic detection of compatibility macros for non-portable diagnostics

Douglas Gregor dgregor at apple.com
Wed Aug 1 10:51:03 PDT 2012


On Aug 1, 2012, at 10:28 AM, Matthieu Monrocq <matthieu.monrocq at gmail.com> wrote:
> I suppose that performance wise it may not be acceptable... but would it make sense to maintain a reverse mapping tokens => macro ?
> 
> We already have the macro => tokens mapping (and it survives even when Sema is running since it's used by diagnosis), so if we could simply maintain another index alongside it then we would be "golden" would not we ?

Well, it hinges on performance. 

It does seem plausible to me that we could have the preprocessor keep a hold of macros after they have been #undef'd, so that we could look back in time and answer the question "which macros were defined when we were at the given source location." That would actually make a lot of sense for Clang, because it's the way the AST works (e.g., we keep all declarations of a function) and would actually benefit some features, such as code completion. But we'd have to carefully measure the performance and memory impact.

	- Doug



More information about the cfe-dev mailing list