Make Object non-copyable as well as non-moveable.
I previously deleted the move operations but forgot that the copy operations
were still defaulted.
PiperOrigin-RevId: 458533038
diff --git a/lifetime_analysis/analyze.cc b/lifetime_analysis/analyze.cc
index d4480d1..d6d23ed 100644
--- a/lifetime_analysis/analyze.cc
+++ b/lifetime_analysis/analyze.cc
@@ -130,9 +130,9 @@
return escaped;
}
-std::string VariableLabel(absl::string_view name, Object object) {
+std::string VariableLabel(absl::string_view name, const Object* object) {
return absl::StrFormat("<<b>%s</b> (%s)>", EscapeHtmlChars(name),
- EscapeHtmlChars(object.DebugString()));
+ EscapeHtmlChars(object->DebugString()));
}
std::string PointsToEdgesDot(const ObjectRepository& object_repository,
@@ -172,21 +172,21 @@
lines.push_back(absl::StrFormat(
"\"%s%s\"[label=%s]", name_prefix,
(*object_repository.GetThisObject())->DebugString(),
- VariableLabel("this", **object_repository.GetThisObject())));
+ VariableLabel("this", *object_repository.GetThisObject())));
}
for (auto [decl, object] : object_repository) {
var_objects.insert(object);
lines.push_back(absl::StrFormat(
"\"%s%s\"[label=%s]", name_prefix, object->DebugString(),
- VariableLabel(decl->getNameAsString(), *object)));
+ VariableLabel(decl->getNameAsString(), object)));
}
var_objects.insert(object_repository.GetReturnObject());
lines.push_back(absl::StrFormat(
"\"%s%s\"[label=%s]", name_prefix,
object_repository.GetReturnObject()->DebugString(),
- VariableLabel("return", *object_repository.GetReturnObject())));
+ VariableLabel("return", object_repository.GetReturnObject())));
for (const Object* object : all_objects) {
if (!var_objects.contains(object)) {
@@ -206,7 +206,7 @@
if (!var_objects.contains(object)) {
lines.push_back(absl::StrFormat(R"("%1$s%2$s"[label="%2$s"])",
name_prefix,
- VariableLabel("this", *object)));
+ VariableLabel("this", object)));
}
}
diff --git a/lifetime_analysis/object.h b/lifetime_analysis/object.h
index 57685e2..15ac390 100644
--- a/lifetime_analysis/object.h
+++ b/lifetime_analysis/object.h
@@ -22,7 +22,9 @@
// lifetime, but two equal objects always have the same lifetime.
class Object {
public:
+ Object(const Object&) = delete;
Object(Object&&) = delete;
+ Object& operator=(const Object&) = delete;
Object& operator=(Object&&) = delete;
// Creates an object with the given lifetime and type.
@@ -35,9 +37,6 @@
// one of the ObjectRepository::CreateObject...() functions.
Object(const clang::FunctionDecl& func);
- Object(const Object&) = default;
- Object& operator=(const Object&) = default;
-
// Returns the lifetime of the object.
Lifetime GetLifetime() const { return lifetime_; }