[cfe-commits] r64780 - in /cfe/trunk: lib/CodeGen/CGDecl.cpp lib/CodeGen/CGExprConstant.cpp lib/CodeGen/CodeGenModule.h test/CodeGen/staticinit.c

Daniel Dunbar daniel at zuster.org
Tue Feb 17 14:22:49 PST 2009


On Tue, Feb 17, 2009 at 2:03 PM, Eli Friedman <eli.friedman at gmail.com> wrote:
> On Tue, Feb 17, 2009 at 10:43 AM, Daniel Dunbar <daniel at zuster.org> wrote:
>> IRgen no longer relies on isConstantInitializer, instead we just try
>> to emit the constant. If that fails then in C we emit an error
>> unsupported (this occurs when Sema accepted something that it doesn't
>> know how to fold, and IRgen doesn't know how to emit) and in C++ we
>> emit a guarded initializer.
>
> Any such cases are bugs in isConstantInitializer/Evaluate, IMO.  As I
> said in PR3398, the only interesting case I know of here is pointers
> cast to integers, which Evaluate doesn't handle.

Agreed. However, IRgen should have this structure anyway since we want
to try and emit C++ initializers as constants; and there is no reason
to do two traversals of the expression (one for isConstantInitializer
and another to actually emit it). The error unsupported should be
replaced with an assert when Evaluate takes everything, I think.

Really, there is no need for isConstantInitializer, since it should
return true for C, and is irrelevant for C++, right?

 - Daniel



More information about the cfe-commits mailing list