]> granicus.if.org Git - clang/commitdiff
implement codegen support for __builtin_types_compatible_p
authorChris Lattner <sabre@nondot.org>
Fri, 3 Aug 2007 17:51:03 +0000 (17:51 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 3 Aug 2007 17:51:03 +0000 (17:51 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@40788 91177308-0d34-0410-b5e6-96231b3b80d8

CodeGen/CGExpr.cpp
CodeGen/CodeGenFunction.h

index 3cae677cd0c74ac69ded567f222eb53f879d28c1..9697686b1a7ccbe507b16f14b6075df138d36eba 100644 (file)
@@ -614,6 +614,8 @@ RValue CodeGenFunction::EmitExpr(const Expr *E) {
     return EmitFloatingLiteral(cast<FloatingLiteral>(E));
   case Expr::CharacterLiteralClass:
     return EmitCharacterLiteral(cast<CharacterLiteral>(E));
+  case Expr::TypesCompatibleExprClass:
+    return EmitTypesCompatibleExpr(cast<TypesCompatibleExpr>(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
index 3235034a0bac96a78a391fd1339a63c3912bce3d..4c79498c4626cbfaea73f8e6fe02428e3ece527e 100644 (file)
@@ -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);