[clang] [clang][dataflow] Use smart pointer caching in unchecked optional accessor (PR #120249)
Jan Voung via cfe-commits
cfe-commits at lists.llvm.org
Mon Dec 23 11:27:52 PST 2024
================
@@ -555,24 +557,26 @@ void handleConstMemberCall(const CallExpr *CE,
LatticeTransferState &State) {
// If the const method returns an optional or reference to an optional.
if (RecordLoc != nullptr && isSupportedOptionalType(CE->getType())) {
- StorageLocation *Loc =
+ const FunctionDecl *DirectCallee = CE->getDirectCallee();
+ if (DirectCallee == nullptr)
+ return;
+ StorageLocation &Loc =
State.Lattice.getOrCreateConstMethodReturnStorageLocation(
- *RecordLoc, CE, State.Env, [&](StorageLocation &Loc) {
+ *RecordLoc, DirectCallee, CE->getType(), State.Env,
----------------
jvoung wrote:
Thanks! You're right that there is a difference when the function returns a reference type. It seems the `CE->getType` loses the reference type information (part of CE isGLValue), so the `FunctionDecl` type would have more information. Updated!
https://github.com/llvm/llvm-project/pull/120249
More information about the cfe-commits
mailing list