Code gen static initializer.

llvm-svn: 43386
This commit is contained in:
Devang Patel 2007-10-26 17:50:58 +00:00
parent 8717417b3b
commit ffdb07c939
2 changed files with 13 additions and 3 deletions

View File

@ -75,9 +75,14 @@ void CodeGenFunction::EmitStaticBlockVarDecl(const BlockVarDecl &D) {
llvm::Constant *Init = 0;
if (D.getInit() == 0) {
Init = llvm::Constant::getNullValue(LTy);
} else
assert(0 && "FIXME: Support initializers");
} else if (D.getType()->isIntegerType()) {
llvm::APSInt Value(static_cast<uint32_t>(
getContext().getTypeSize(D.getInit()->getType(), SourceLocation())));
if (D.getInit()->isIntegerConstantExpr(Value, getContext()))
Init = llvm::ConstantInt::get(Value);
}
assert(Init && "FIXME: Support initializers");
DMEntry =
new llvm::GlobalVariable(LTy, false,

View File

@ -0,0 +1,5 @@
// RUN: clang -emit-llvm %s
void f() {
static int i = 42;
}