[cfe-dev] Add CodeGen support for AddrOf in constant initializers

Eli Friedman eli.friedman at gmail.com
Fri Jan 25 16:18:57 PST 2008


Attached is a patch for CodeGen support for AddrOf in constant
initializers. Also attached are tests.

The patch is extremely unintrusive, so it should be easy to review.

Note that this helper should allow some simplifications to the
ImplicitCastExpr and StringLiteral handling in GenerateConstantExpr(),
which is currently a bit of a mess.

Codegen of the address of a string (e.g. &"asdf") will crash due to
inconsistent types without my patch to fix the type of strings;
however, it's a rare construct, and isConstantExpr() currently doesn't
let through such expressions anyway.

There are a few unimplemented cases; the ones I know of are __func__
and the address of a static local.  I left __func__ for later.

The case of the address of a static local is a bit tricky; it's not
possible to resolve correctly with the information available in
GenerateConstantExpr(), as far as I can tell.  It's probably worth
discussing how to fix it.

-Eli
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: staticaddressfix.txt
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080125/709e0eef/attachment.txt>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: addrtests.c
Type: text/x-csrc
Size: 692 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20080125/709e0eef/attachment.c>


More information about the cfe-dev mailing list