]> granicus.if.org Git - clang/commitdiff
Add a minor hack to avoid using isNullPointerConstant on a hot path. Fixes -O0 compi...
authorEli Friedman <eli.friedman@gmail.com>
Fri, 17 Jun 2011 20:52:22 +0000 (20:52 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Fri, 17 Jun 2011 20:52:22 +0000 (20:52 +0000)
rdar://9629775 .

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@133290 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaExpr.cpp

index 98bfe87aab1f342e4d2c613c2be201b43cd8e42e..d3b7b10145f7f5bda6e23b9c0a76347c223648dc 100644 (file)
@@ -8935,12 +8935,11 @@ ExprResult Sema::CreateBuiltinBinOp(SourceLocation OpLoc,
     rhs = move(resolvedRHS);
   }
 
-  bool LeftNull = Expr::NPCK_GNUNull ==
-      lhs.get()->isNullPointerConstant(Context,
-                                       Expr::NPC_ValueDependentIsNotNull);
-  bool RightNull = Expr::NPCK_GNUNull ==
-      rhs.get()->isNullPointerConstant(Context,
-                                       Expr::NPC_ValueDependentIsNotNull);
+  // The canonical way to check for a GNU null is with isNullPointerConstant,
+  // but we use a bit of a hack here for speed; this is a relatively
+  // hot path, and isNullPointerConstant is slow.
+  bool LeftNull = isa<GNUNullExpr>(lhs.get()->IgnoreParenImpCasts());
+  bool RightNull = isa<GNUNullExpr>(rhs.get()->IgnoreParenImpCasts());
 
   // Detect when a NULL constant is used improperly in an expression.  These
   // are mainly cases where the null pointer is used as an integer instead