Skip to content

Handling of constant initializers needs cleaning #3893

@llvmbot

Description

@llvmbot
Bugzilla Link 3521
Resolution FIXED
Resolved on Mar 12, 2010 00:57
Version unspecified
OS All
Reporter LLVM Bugzilla Contributor
CC @DougGregor,@efriedma-quic

Extended Description

Sema currently has some extra code for accepting static initializers which is not present in Evaluate. As a consequence, isConstantInitializer returns false for things which Sema has accepted as constant initializers.

This causes problems for CodeGen, which should not have to replicate this code.

For example, replacing calls to CheckConstantInitializer with:

if (!CheckForConstantInitializer(Init, DclT))
assert(Init->isConstantInitializer(Context) && "Invalid CheckForConstantInitializer result.");

results in 10 assertions just when running the clang test suite.

We need a number of cleanups here:

  1. Decl's should distinguish between constant and non-constant initializers (C++).

  2. The special Sema code for accepting more things as constant initializers needs to be killed off and moved into Evaluate.

  3. CodeGen should stop doing any more work than is necessary to emit constant initializers. The constant emission should only worry about walking the initializer tree, but not about actually constructing values for things; it should rely on Evaluate for that.

This bug is a placeholder for this work.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugzillaIssues migrated from bugzillaclang:frontendLanguage frontend issues, e.g. anything involving "Sema"

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions