[PATCH] D28749: Fix use-after-free bug in AffectedValueCallbackVH::allUsesReplacedWith

Sanjoy Das via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jan 15 15:32:21 PST 2017


sanjoy accepted this revision.
sanjoy added a reviewer: sanjoy.
sanjoy added a comment.
This revision is now accepted and ready to land.

The code lgtm, but

- Can you easily test this using a C++ unit test?  I'll settle for something that normally runs "fine", but trips asan if the build is using asan.
- `getAffectedValues` should be renamed to `getOrInsertAffectedValues`.



================
Comment at: lib/Analysis/AssumptionCache.cpp:121
+  for (auto &A : AVI->second)
+    if (std::find(NAVV.begin(), NAVV.end(), A) == NAVV.end())
+      NAVV.push_back(A);
----------------
Can you use `llvm::find` here (in a later change)?


================
Comment at: lib/Analysis/AssumptionCache.cpp:132
+  AC->copyAffectedValuesInCache(getValPtr(), NV);
+  // 'this' now might dangle!
 }
----------------
Please add why it may dangle.


https://reviews.llvm.org/D28749





More information about the llvm-commits mailing list