[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)

Jan Voung via cfe-commits cfe-commits at lists.llvm.org
Tue Jan 7 05:31:54 PST 2025


================
@@ -58,6 +63,106 @@ ast_matchers::StatementMatcher isSmartPointerLikeOperatorArrow();
 ast_matchers::StatementMatcher isSmartPointerLikeValueMethodCall();
 ast_matchers::StatementMatcher isSmartPointerLikeGetMethodCall();
 
+// Common transfer functions.
+
+/// Returns the "canonical" callee for smart pointer operators (`*` and `->`)
+/// as a key for caching.
+///
+/// We choose `*` as the canonical one, since it needs a
+/// StorageLocation anyway.
+///
+/// Note: there may be multiple `operator*` (one const, one non-const).
+/// We pick the const one, which the above provided matchers require to exist.
+const FunctionDecl *
+getCanonicalSmartPointerLikeOperatorCallee(const CallExpr *CE);
+
+/// A transfer function for `operator*` (and `value`) calls
+/// that can be cached.
----------------
jvoung wrote:

Thanks -- done!

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


More information about the cfe-commits mailing list