diff --git a/clang/CodeGen/CGExpr.cpp b/clang/CodeGen/CGExpr.cpp index a4323af1347f..3168f9070a9e 100644 --- a/clang/CodeGen/CGExpr.cpp +++ b/clang/CodeGen/CGExpr.cpp @@ -432,6 +432,8 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) { // Leaf expressions. case Expr::IntegerLiteralClass: return EmitIntegerLiteral(cast(E)); + case Expr::FloatingLiteralClass: + return EmitFloatingLiteral(cast(E)); // Operators. case Expr::ParenExprClass: @@ -451,6 +453,10 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) { RValue CodeGenFunction::EmitIntegerLiteral(const IntegerLiteral *E) { return RValue::get(llvm::ConstantInt::get(E->getValue())); } +RValue CodeGenFunction::EmitFloatingLiteral(const FloatingLiteral *E) { + return RValue::get(llvm::ConstantFP::get(ConvertType(E->getType()), + E->getValue())); +} RValue CodeGenFunction::EmitCastExpr(const CastExpr *E) { QualType SrcTy; diff --git a/clang/CodeGen/CodeGenFunction.h b/clang/CodeGen/CodeGenFunction.h index b49655f05c4f..184c7dcdb38d 100644 --- a/clang/CodeGen/CodeGenFunction.h +++ b/clang/CodeGen/CodeGenFunction.h @@ -45,6 +45,7 @@ namespace clang { class DeclRefExpr; class StringLiteral; class IntegerLiteral; + class FloatingLiteral; class CastExpr; class CallExpr; class UnaryOperator; @@ -280,6 +281,7 @@ public: RValue EmitExpr(const Expr *E); RValue EmitIntegerLiteral(const IntegerLiteral *E); + RValue EmitFloatingLiteral(const FloatingLiteral *E); RValue EmitCastExpr(const CastExpr *E); RValue EmitCallExpr(const CallExpr *E);