Make values of call_expr_args_objects_ and call_expr_this_pointers_ pointers. PiperOrigin-RevId: 458414211
diff --git a/lifetime_analysis/object_repository.cc b/lifetime_analysis/object_repository.cc index 33d6bdd..70ade1c 100644 --- a/lifetime_analysis/object_repository.cc +++ b/lifetime_analysis/object_repository.cc
@@ -171,11 +171,11 @@ return true; } - Object CreateLocalObject(clang::QualType type) { - Object object = - *object_repository_.CreateObject(Lifetime::CreateLocal(), type); + const Object* CreateLocalObject(clang::QualType type) { + const Object* object = + object_repository_.CreateObject(Lifetime::CreateLocal(), type); object_repository_.CreateObjects( - object, type, + *object, type, [](const clang::Expr*) { return Lifetime::CreateVariable(); }, /*transitive=*/false); return object; @@ -496,10 +496,10 @@ for (const auto& [expr_i, object] : call_expr_args_objects_) { const auto& [expr, i] = expr_i; os << "Call " << expr << " (arg " << i - << ") object: " << object.DebugString() << "\n"; + << ") object: " << object->DebugString() << "\n"; } for (const auto& [expr, object] : call_expr_this_pointers_) { - os << "Call " << expr << " (this) pointer: " << object.DebugString() + os << "Call " << expr << " (this) pointer: " << object->DebugString() << "\n"; } os << "InitialPointsToMap:\n" << initial_points_to_map_.DebugString() << "\n"; @@ -569,7 +569,7 @@ llvm::errs() << "\n" << DebugString(); llvm::report_fatal_error("Didn't find object for argument"); } - return iter->second; + return *iter->second; } Object ObjectRepository::GetCallExprThisPointer( @@ -581,7 +581,7 @@ llvm::errs() << "\n" << DebugString(); llvm::report_fatal_error("Didn't find `this` object for call"); } - return iter->second; + return *iter->second; } Object ObjectRepository::GetCXXConstructExprArgumentObject( @@ -595,7 +595,7 @@ llvm::report_fatal_error( "Didn't find object for argument of constructor call"); } - return iter->second; + return *iter->second; } Object ObjectRepository::GetCXXConstructExprThisPointer( @@ -607,7 +607,7 @@ llvm::errs() << "\n" << DebugString(); llvm::report_fatal_error("Didn't find `this` object for constructor"); } - return iter->second; + return *iter->second; } Object ObjectRepository::GetInitializedObject(
diff --git a/lifetime_analysis/object_repository.h b/lifetime_analysis/object_repository.h index d869c6a..615dae9 100644 --- a/lifetime_analysis/object_repository.h +++ b/lifetime_analysis/object_repository.h
@@ -245,10 +245,10 @@ FieldObjects field_object_map_; BaseObjects base_object_map_; - llvm::DenseMap<std::pair<const clang::Expr*, size_t>, Object> + llvm::DenseMap<std::pair<const clang::Expr*, size_t>, const Object*> call_expr_args_objects_; - llvm::DenseMap<const clang::Expr*, Object> call_expr_this_pointers_; + llvm::DenseMap<const clang::Expr*, const Object*> call_expr_this_pointers_; llvm::DenseMap<clang::QualType, Object> static_objects_; };