[cfe-dev] -rewrite-objc and typeof (Was: -rewrite-objc, C and blocks)
jahanian
fjahanian at apple.com
Fri Oct 1 14:14:09 PDT 2010
On Oct 1, 2010, at 1:42 PM, Pierre Habouzit wrote:
>
> While I'm at it, the objc rewriter tries hard to rewrite typeof() for a
> reason that eludes me. Given that typeof() is often used inside macros,
> and that rewriting inside macros may not work (that I can understand
> ;p), this is really painful.
We needed to support rewriting of __typeof because of our requirements.
There is a test case under Rewrite/rewrite-typeof.mm which specifically
tests this.
This is one other reason to have a separate rewriter without baggage associated
with our specific needs.
- Fariborz
>
> So could someone explain why the RewriteObjC::RewriteTypeOfDecl()
> function is needed at all so that I can work on a fix or at least a
> relaxed rule (for example, I assume that the problem arises if the
> type of the expression inside typeof really is some block type or some
> variable with a __block storage ? or something block related at least,
> so probably the fix is to check if the type is something of that kind,
> right ?)
>
> The use case is code using stuff like:
>
> #define shared_write(p, v) ({ typeof(v) __v = (v); \
> access_once(p) = __v; wmc(); __v; })
>
> clang -rewrite-objc yields tons of warnings like:
>
> thr-job.c:198:5: warning: rewriting sub-expression within a macro (may not be correct)
> shared_write(self_g.bot_, new_bot);
> ^
> [...]
> ../lib-common/core-atomic-x86.h:80:32: note: instantiated from:
> #define shared_write(p, v) ({ typeof(v) __v = (v); \
> ^
>
> Given that in the previous code self_g.bot is an unsigned, I really fail
> to see why clang believes it has to rewrite the typeof() expression at
> all.
> --
> ·O· Pierre Habouzit
> ··O madcoder at debian.org
> OOO http://www.madism.org
> _______________________________________________
> 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