[PATCH] D131532: [Sema] Avoid isNullPointerConstant invocation

Richard Trieu via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Aug 10 21:00:23 PDT 2022


rtrieu accepted this revision.
rtrieu added a comment.
This revision is now accepted and ready to land.

I think this is a reasonable step for improving compile times.  I put some suggestions for more descriptive names below (he said, after suggesting those names in the first place).

The description of this change should mention that expensive part is because `isNullPointerConstant` makes calls to a constant evaluator which we don't need.



================
Comment at: clang/lib/Sema/SemaChecking.cpp:13343
+  const Expr *NewE = E->IgnoreParenImpCasts();
+  bool GNUNull = isa<GNUNullExpr>(NewE);
+  bool NullPtr = NewE->getType()->isNullPtrType();
----------------
Let's call this `IsGNUNullExpr`


================
Comment at: clang/lib/Sema/SemaChecking.cpp:13344
+  bool GNUNull = isa<GNUNullExpr>(NewE);
+  bool NullPtr = NewE->getType()->isNullPtrType();
+  if (!GNUNull && !NullPtr) return;
----------------
And let's call this `HasNullPtrType`


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D131532/new/

https://reviews.llvm.org/D131532



More information about the cfe-commits mailing list