[LLVMdev] Evaluation of offsetof() macro
Vadim Chugunov
vadimcn at gmail.com
Fri Jan 2 17:26:42 PST 2015
>
>> So it handles all const expression evaluation in the front-end?
>>
>>
> Yes, clang has it's own constant expression evaluator which understands
> the rules of C++.
>
> Let's take an example.
> The expression (long)&x/(long)&y divides two globals by each other. This
> expression is lowered to the following LLVM IR Constant:
> i64 sdiv (i64 ptrtoint (i32* @x to i64), i64 ptrtoint (i32* @y to i64))
>
> This Constant is a ConstantExpr but certainly not indicative of something
> that would be 'constexpr' in C++.
>
My goal is to be able to use the result in constexpr contexts (like
declaring an array, whose size expression involves offsetof()). Please
correct me if this is wrong, but I think this means that the expression
must be evaluated before any IR is emitted.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20150102/2549b787/attachment.html>
More information about the llvm-dev
mailing list