[cfe-dev] Keeping AST data for includes

Douglas Gregor dgregor at apple.com
Tue Nov 2 10:34:39 PDT 2010


On Nov 2, 2010, at 10:33 AM, Vladimir Kirillov wrote:

> Hi Douglas!
> 
> On 08:26 Tue 02 Nov, Douglas Gregor wrote:
>> On Nov 2, 2010, at 6:52 AM, Vladimir Kirillov wrote:
>> 
>>> Hello, cfe-dev!
>>> 
>>> While processing big source code trees with ASTFrontendAction and custom
>>> ASTConsumer, same include files are getting hit and parsed all over and
>>> over again.
>>> Is there any technique (except precompiled header) to prevent such
>>> actions? Like keeping header-related AST data and referencing it within
>>> next files' AST?
>> 
>> That's what precompiled headers do. 
>> 
>> If you want each header to have an independent, stored AST, then
>> you're in trouble, since every #include can affect every #include
>> that follows it, and the dependencies between those #includes are
>> very fine-grained.
> 
> Yes, I am aware of that.
> 
> However I thought about some declaration cache, which can be referenced
> if the same SourceLocation is hit while the same preprocessor state
> conditions are met.. Is it possible atm?


No, it isn't. You'd still have to manage dependencies:

a.h:
struct Foo { };

b.h:
#include "a.h"

c.h:
#define Foo Bar
#include "a.h"



	- Doug



More information about the cfe-dev mailing list