[cfe-dev] Should we build semantically invalid nodes?
steve naroff
snaroff at apple.com
Sat Oct 25 05:28:26 PDT 2008
Hey Argiris,
Since clang supports multiple "Action" modules, why not have an
ASTBuilder class?
My intuition says simply passing in a flag to Sema won't be rich
enough. Over time, you would probably need several flags to get Sema
to do what you actually want. It just doesn't feel right to me.
On the other hand, AST's produced by an ASTBuilder class could be
segregated and managed differently. It gives you much more flexibility
to meet the needs of a more "fuzzy" environment (like an IDE),
including replacing some of the AST nodes (if the one's were using in
Sema aren't ideal). For example, the ASTBuilder class might choose to
have "real" (i.e. non-unique types) types (something we've discussed
before). Having the ability to get the actual source location for type
specifiers seems like a "must have" feature for non-compiler clients.
I believe my suggestion is fairly easy to implement for Stmts/Exprs.
It is more difficult to implement for Decls/Types (since
Sema::ActOnDeclarator() does some "heavy lifting" to transform a
Declarator into a Decl/Type). If this were the only obstacle, we could
refactor the code into a Declarator library that both Action modules
could share. Since Declarators in C/C++ are very complex, adding a
layer might actually improve the maintenance of the code.
I think your desire for more fuzzy AST's is spot on. My only concern
is identifying clients for them and choosing an implementation
strategy that doesn't disrupt our most central/complex Action module
(i.e. Sema). We knew this day would come, which is why the Action
interface doesn't force you to use a particular data structure (or any
at all).
Thoughts?
snaroff
On Oct 25, 2008, at 4:21 AM, Argiris Kirtzidis wrote:
> Here's an alternative idea:
> How about we pass a flag at Sema to indicate that Sema should just
> build
> the AST without semantic checks ?
>
> The meaning of this flag is not that it guarantees that *absolutely
> no*
> semantic checks are done, just that the focus is less on semantics and
> more on getting a complete AST.
> The Action methods could be modified gradually to check this flag, eg.
> on Sebastian's patch, if this flag is on, Sema::ActOnCXXCasts will
> skip
> the CheckXXXCast call and go to creating the CXXCastExpr directly.
>
> This addresses Doug's concerns about allowing invalid nodes while also
> enabling clients that only care about a full AST.
>
> Any thoughts ?
>
> -Argiris
> _______________________________________________
> cfe-dev mailing list
> cfe-dev at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev
More information about the cfe-dev
mailing list