[clang] [clang][dataflow] Expose simple access to child StorageLocation presence. (PR #145520)

via cfe-commits cfe-commits at lists.llvm.org
Tue Jun 24 07:37:13 PDT 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang-analysis

@llvm/pr-subscribers-clang

Author: Samira Bakon (bazuzi)

<details>
<summary>Changes</summary>

`getChild` does not offer this knowledge, and a map lookup is significantly cheaper than iteration over `children()`.

---
Full diff: https://github.com/llvm/llvm-project/pull/145520.diff


1 Files Affected:

- (modified) clang/include/clang/Analysis/FlowSensitive/StorageLocation.h (+2) 


``````````diff
diff --git a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h b/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
index 8fcc6a44027a0..8b263b16d5b1e 100644
--- a/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
+++ b/clang/include/clang/Analysis/FlowSensitive/StorageLocation.h
@@ -168,6 +168,8 @@ class RecordStorageLocation final : public StorageLocation {
     return {Children.begin(), Children.end()};
   }
 
+  bool hasChild(const ValueDecl &D) const { return Children.contains(&D); }
+
 private:
   FieldToLoc Children;
   SyntheticFieldMap SyntheticFields;

``````````

</details>


https://github.com/llvm/llvm-project/pull/145520


More information about the cfe-commits mailing list