[clang] [clang][dataflow] Add `Environment::get<>()`. (PR #76027)

via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 20 23:54:03 PST 2023


================
@@ -489,8 +489,7 @@ Environment Environment::pushCall(const CallExpr *Call) const {
   if (const auto *MethodCall = dyn_cast<CXXMemberCallExpr>(Call)) {
     if (const Expr *Arg = MethodCall->getImplicitObjectArgument()) {
       if (!isa<CXXThisExpr>(Arg))
-          Env.ThisPointeeLoc =
-              cast<RecordStorageLocation>(getStorageLocation(*Arg));
+        Env.ThisPointeeLoc = get<RecordStorageLocation>(*Arg);
----------------
martinboehme wrote:

PS Just an additional note: I think the default behavior (i.e. `get` with default argument / without a suffix such as `MustExist`) should be to allow null because it's almost always the right choice in production code (i.e. production code should be prepared to handle situations where we don't have a `Value` or `StorageLocation`).

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


More information about the cfe-commits mailing list