[clang] [clang][dataflow] Expose simple access to child StorageLocation presence. (PR #145520)
Samira Bakon via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 24 07:36:46 PDT 2025
https://github.com/bazuzi created https://github.com/llvm/llvm-project/pull/145520
`getChild` does not offer this knowledge, and a map lookup is significantly cheaper than iteration over `children()`.
>From 9b8f866a5102dbe23b671760bf35549b30a30a74 Mon Sep 17 00:00:00 2001
From: Samira Bakon <bazuzi at google.com>
Date: Tue, 24 Jun 2025 10:23:11 -0400
Subject: [PATCH] [clang][dataflow] Expose simple access to whether a child
StorageLocation is present.
`getChild` does not offer this knowledge, and a map lookup is significantly cheaper than iteration over `children()`.
---
clang/include/clang/Analysis/FlowSensitive/StorageLocation.h | 2 ++
1 file changed, 2 insertions(+)
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;
More information about the cfe-commits
mailing list