diff --git a/toolchain/base/canonical_value_store.h b/toolchain/base/canonical_value_store.h index 9fb8c33f5e94..966086196c2b 100644 --- a/toolchain/base/canonical_value_store.h +++ b/toolchain/base/canonical_value_store.h @@ -17,7 +17,9 @@ namespace Carbon { // A wrapper for accumulating immutable values with deduplication, providing IDs // to later retrieve the value. // -// `ValueT` represents the type being stored. +// `ValueT` represents the type being stored. Be careful storing non-owned +// values (e.g. `llvm::StringRef`), as the store will not prevent the +// underlying data from being freed. // // `KeyT` can optionally be different from `ValueT`, and if so is used for the // argument to `Lookup`. In this case, `ValueT` must provide a `GetAsKey` member diff --git a/toolchain/base/shared_value_stores.h b/toolchain/base/shared_value_stores.h index 328f4ef6ab42..9c52dbdd2446 100644 --- a/toolchain/base/shared_value_stores.h +++ b/toolchain/base/shared_value_stores.h @@ -25,6 +25,9 @@ class SharedValueStores : public Yaml::Printable { using IntStore = IntStore; using RealStore = ValueStore; using FloatStore = CanonicalValueStore; + // Note that this stores string references. The underlying string data must + // be stored somewhere more durable (e.g. a string literal or + // `clang::ASTContext::Idents`). using IdentifierStore = CanonicalValueStore; using StringLiteralStore = CanonicalValueStore;