[cfe-commits] r133290 - /cfe/trunk/lib/Sema/SemaExpr.cpp

Eli Friedman eli.friedman at gmail.com
Fri Jun 17 13:52:22 PDT 2011


Author: efriedma
Date: Fri Jun 17 15:52:22 2011
New Revision: 133290

URL: http://llvm.org/viewvc/llvm-project?rev=133290&view=rev
Log:
Add a minor hack to avoid using isNullPointerConstant on a hot path.  Fixes -O0 compile-time regressions from r133196.

rdar://9629775 .


Modified:
    cfe/trunk/lib/Sema/SemaExpr.cpp

Modified: cfe/trunk/lib/Sema/SemaExpr.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaExpr.cpp?rev=133290&r1=133289&r2=133290&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaExpr.cpp (original)
+++ cfe/trunk/lib/Sema/SemaExpr.cpp Fri Jun 17 15:52:22 2011
@@ -8935,12 +8935,11 @@
     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





More information about the cfe-commits mailing list