/// GenerateConstantCast - Generates a constant cast to convert the Expression
/// into the Target type.
static llvm::Constant *GenerateConstantCast(const Expr *Expression,
- QualType Target,
- CodeGenModule &CGM) {
+ QualType Target,
+ CodeGenModule &CGM) {
CodeGenTypes& Types = CGM.getTypes();
QualType Source = Expression->getType().getCanonicalType();
Target = Target.getCanonicalType();
}
switch (Expression->getStmtClass()) {
+ default: break; // default emits a warning and returns bogus value.
+ case Stmt::DeclRefExprClass: {
+ const ValueDecl *Decl = cast<DeclRefExpr>(Expression)->getDecl();
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(Decl))
+ return CGM.GetAddrOfFunctionDecl(FD, false);
+ break;
+ }
+
// Generate constant for floating point literal values.
case Stmt::FloatingLiteralClass: {
const FloatingLiteral *FLiteral = cast<FloatingLiteral>(Expression);
// an array or struct.
case Stmt::InitListExprClass:
return GenerateAggregateInit(cast<InitListExpr>(Expression), CGM);
-
- default:
- CGM.WarnUnsupported(Expression, "initializer");
- return llvm::UndefValue::get(Types.ConvertType(type));
}
+
+ CGM.WarnUnsupported(Expression, "initializer");
+ return llvm::UndefValue::get(Types.ConvertType(type));
}
llvm::Constant *CodeGenModule::EmitGlobalInit(const Expr *Expression) {