[cfe-dev] decl/expr ambiguity

Chris Lattner clattner at apple.com
Sun Aug 24 15:23:24 PDT 2008

Okay, here's another crazy idea.  If you boil it down, my objections  
to preparsing are basically:

1. the perf cost of having to do the prepare in *every* decl case.
2. [minor] the perf cost for qualified expr cases (std::cout << ...)
3. [minor] the maintenance cost of the second parser.

I think that the "parse expr/decl with leading identifier" approach,  
when generalized to work with any qualified name would adequately  
solve #2.

Would it be possible to do a similar thing with entire type names?  If  
we had a "parse decl/expr with leading type" then we wouldn't have to  
decide whether something was a statement/decl until after we read the  
type.  I'm not sure, but if this would let us disambiguate the  
"definitely a decl" case with current or one token lookahead, then  
this would fix #1 as well.

Is it possible to determine that something is "definitely a decl"  
after reading the "int*" in this case?

   int *X = ...

If so, this would solve my primary two objects to the pre-parser.  It  
would mean that we only resolve the leading type once, and only invoke  
the preparser in extremely rare cases (not *every* decl).

What do you think?


More information about the cfe-dev mailing list