[PATCH] D156230: [clang][dataflow][NFC] Eliminate variable only used in assertion.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue Jul 25 04:57:45 PDT 2023


mboehme created this revision.
Herald added subscribers: martong, xazax.hun.
Herald added a reviewer: NoQ.
Herald added a project: All.
mboehme requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

This can break release builds that set `-Werror` because they will error out on
an unused variable.

Depends On D156229 <https://reviews.llvm.org/D156229>


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D156230

Files:
  clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp


Index: clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
===================================================================
--- clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
+++ clang/lib/Analysis/FlowSensitive/DataflowEnvironment.cpp
@@ -122,12 +122,11 @@
 
   Value *MergedVal = nullptr;
   if (auto *StructVal1 = dyn_cast<StructValue>(&Val1)) {
-    auto *StructVal2 = cast<StructValue>(&Val2);
-
     // Values to be merged are always associated with the same location in
     // `LocToVal`. The location stored in `StructVal` should therefore also
     // be the same.
-    assert(&StructVal1->getAggregateLoc() == &StructVal2->getAggregateLoc());
+    assert(&StructVal1->getAggregateLoc() ==
+           &cast<StructValue>(&Val2)->getAggregateLoc());
 
     // `StructVal1` and `StructVal2` may have different properties associated
     // with them. Create a new `StructValue` without any properties so that we


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D156230.543926.patch
Type: text/x-patch
Size: 938 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20230725/f44c4600/attachment.bin>


More information about the cfe-commits mailing list