[PATCH] D150656: [clang][dataflow] Use `Strict` accessors in TypeErasedDataflowAnalysis.cpp.

Martin Böhme via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 17 07:14:55 PDT 2023


mboehme marked 2 inline comments as done.
mboehme added inline comments.


================
Comment at: clang/lib/Analysis/FlowSensitive/TypeErasedDataflowAnalysis.cpp:303
 
-  auto *InitStmtLoc = Env.getStorageLocation(*InitStmt, SkipPast::Reference);
-  if (InitStmtLoc == nullptr)
-    return;
-
-  auto *InitStmtVal = Env.getValue(*InitStmtLoc);
-  if (InitStmtVal == nullptr)
-    return;
-
   if (Member->getType()->isReferenceType()) {
+    auto *InitStmtLoc = Env.getStorageLocationStrict(*InitStmt);
----------------
xazax.hun wrote:
> I am wondering whether it is more robust to branch directly on the value category of `InitStmt`, although I cannot think of cases where this condition would go wrong. Feel free to ignore. 
I think it's actually more robust to branch on `isReferenceType()`, because `getStorageLocationStrict` contains an assertion that `InitStmt` is a value category -- so we're verifying that both of these conditions are met. If instead we branched on `InitStmt->isGLValue()`, we wouldn't be looking at `Member->getType()->isReferenceType()` at all, and we wouldn't be verifying that it matches our expectations (i.e. that it's a reference).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150656



More information about the cfe-commits mailing list