Add CodeGen support for AddrOf in constant initializers

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

staticaddressfix.txt (5.12 KB)

addrtests.c (692 Bytes)