[PATCH] D33305: [ubsan] Add a check for pointer overflow UB

Filipe Cabecinhas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu May 18 08:34:23 PDT 2017


filcab added inline comments.


================
Comment at: lib/CodeGen/CGExprScalar.cpp:3854
+                                               const Twine &Name) {
+  Value *GEPVal = Builder.CreateInBoundsGEP(Ptr, IdxList, Name);
+
----------------
You're creating the GEP first (possibly triggering UB), and then checking ("after" UB). Shouldn't you put the checking instructions before the GEP?


================
Comment at: lib/CodeGen/CGExprScalar.cpp:3948
+    return GEPVal;
+
+  // Now that we've computed the total offset, add it to the base pointer (with
----------------
Do we want an extra test for `TotalOffset` being a constant + not overflowing? (Not strictly need, but you've been working on avoiding __ubsan() calls :-) )


https://reviews.llvm.org/D33305





More information about the cfe-commits mailing list