[cfe-dev] New guy trying to figure out where the parsing is happening

Richard Smith metafoo at gmail.com
Fri Jan 24 18:42:29 PST 2014


On Fri Jan 24 2014 at 5:38:42 PM, JB Feldman <jb.feldman at kyrus-tech.com>
wrote:

>  Hey guys,
>
> I'm a serious newbie at LLVMing. I've been trying to figure out how to
> solve
> http://llvm.org/bugs/show_bug.cgi?id=18443.
>
> I've discovered where the error is being triggered, and that is in
> TreeTransform<Derived>::TransformUnaryExprOrTypeTraitExpr(). However, I
> don't feel that this is the correct place to fix the problem, I think the
> correct place would be to make it so that
>
> sizeof(T::type);
> and
> sizeof(typename T::type);
>
>
> Parse to the same Expr.
>

That would break the case where T::type is an expression rather than a type:

struct S { static const int type = 0; };
template<typename T> struct X {
  int k = sizeof(T::type);
};
static_assert(X<S>().k == sizeof(int), "");

The right way to fix this is probably to detect the case of a ParenExpr
containing a "type-shaped" expression (maybe just a dependent-scoped decl
ref expr for now) in TransformUnaryExprOrTypeTrait, and to transform it
into the intended type if the name instantiates to a type.


> I've been debugging clang with VS trying to figure out where/when/how this
> thing is parsed, and all I ever see (in Lexer::Lex) are headers being
> parsed. Can anyone point me to the code that creates the Expr objects for
> this code? At the moment, I can't even identify what type of Expr "typename
> T::type" would parse to, let alone try to make "T::type" parse to the same
> thing.
>
> If you don't know the answer, is there a good place to start for diving
> into developing on clang? I'm still not sure I'm clear on the differences
> between parsing, AST, lexing, and sema transforms. I would very much
> appreciate any help on these topics, anywhere between someone saying, "hey,
> go read this readme/webpage" to someone actually pointing me to the correct
> piece of code. I feel like I've been spinning my wheels on this one.
>
> I really want to get involved in making clang more robust with Windows (at
> some point probably including diving into the SEH problem), I just seem to
> need some help getting started.
>
> Thanks,
> JB
>
>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140125/7e1af755/attachment.html>


More information about the cfe-dev mailing list