http://llvm.org/bugs/show_bug.cgi?id=6971

           Summary: Code generation for non-constant __builtin_offsetof
           Product: clang
           Version: trunk
          Platform: PC
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P
         Component: LLVM Codegen
        AssignedTo: [email protected]
        ReportedBy: [email protected]
                CC: [email protected]


__builtin_offsetof is represented by an OffsetOfExpr in C++, and we would like
to use that representation in C as well to eliminate UnaryOperator::OffsetOf
(which is a hack). However, we need code generation support for non-constant
offsetof expressions, such as the one in this example:

  struct sockaddr_un {
   unsigned char sun_len;
   char sun_path[104];
  };

  int test(int len) {
    return __builtin_offsetof(struct sockaddr_un, sun_path[len+1]);
  }

The UnaryOperator::OffsetOf implementation handles this by creating an lvalue,
then applying various array-index and member-reference operations to that value
and subtracting the original lvalue's address from the resulting lvalue's
address. We'll likely need to do the same for OffsetOfExpr. Once implemented,
we can kill off UnaryOperator::OffsetOf.

-- 
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to