From 30bf3ae03f2edd9474d1ad69e7af64613367fed2 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 3 Aug 2007 17:51:03 +0000 Subject: [PATCH] implement codegen support for __builtin_types_compatible_p git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40788 91177308-0d34-0410-b5e6-96231b3b80d8 --- CodeGen/CGExpr.cpp | 8 ++++++++ CodeGen/CodeGenFunction.h | 3 +++ 2 files changed, 11 insertions(+) diff --git a/CodeGen/CGExpr.cpp b/CodeGen/CGExpr.cpp index 3cae677cd0..9697686b1a 100644 --- a/CodeGen/CGExpr.cpp +++ b/CodeGen/CGExpr.cpp @@ -614,6 +614,8 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) { return EmitFloatingLiteral(cast(E)); case Expr::CharacterLiteralClass: return EmitCharacterLiteral(cast(E)); + case Expr::TypesCompatibleExprClass: + return EmitTypesCompatibleExpr(cast(E)); // Operators. case Expr::ParenExprClass: @@ -651,6 +653,12 @@ RValue CodeGenFunction::EmitCharacterLiteral(const CharacterLiteral *E) { E->getValue())); } +RValue CodeGenFunction::EmitTypesCompatibleExpr(const TypesCompatibleExpr *E) { + return RValue::get(llvm::ConstantInt::get(ConvertType(E->getType()), + E->typesAreCompatible())); +} + + RValue CodeGenFunction::EmitArraySubscriptExprRV(const ArraySubscriptExpr *E) { // Emit subscript expressions in rvalue context's. For most cases, this just // loads the lvalue formed by the subscript expr. However, we have to be diff --git a/CodeGen/CodeGenFunction.h b/CodeGen/CodeGenFunction.h index 3235034a0b..4c79498c46 100644 --- a/CodeGen/CodeGenFunction.h +++ b/CodeGen/CodeGenFunction.h @@ -48,6 +48,8 @@ namespace clang { class IntegerLiteral; class FloatingLiteral; class CharacterLiteral; + class TypesCompatibleExpr; + class CastExpr; class CallExpr; class UnaryOperator; @@ -351,6 +353,7 @@ public: RValue EmitIntegerLiteral(const IntegerLiteral *E); RValue EmitFloatingLiteral(const FloatingLiteral *E); RValue EmitCharacterLiteral(const CharacterLiteral *E); + RValue EmitTypesCompatibleExpr(const TypesCompatibleExpr *E); RValue EmitCastExpr(const Expr *Op, QualType DestTy); RValue EmitCallExpr(const CallExpr *E); -- 2.40.0