[LLVMbugs] [Bug 6971] New: Code generation for non-constant __builtin_offsetof
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Wed Apr 28 18:39:59 PDT 2010
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: unassignedclangbugs at nondot.org
ReportedBy: dgregor at apple.com
CC: llvmbugs at cs.uiuc.edu
__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.
More information about the llvm-bugs
mailing list