(copied from #19387 (comment) ):
There are a lot more cases in the codebase where a data type stores a reference or pointer to another object provided to the constructor exist. For example:
- In
src/stream.h:OverrideStream,CVectorReader,BitStreamReader,BitStreamWriter - In
src/script/sign.h:MutableTransactionSignatureCreator(#19426). - In
src/script/interpreter.h:GenericTransactionSignatureChecker - In
src/serialize.h:Wrapper,Using - In
src/wallet/rpcwallet.cpp:DescribeWalletAddressVisitor - In
src/key_io.cpp:DestinationEncoder - In
src/dbwrapper.h:CDBBatch,CDBIterator - In
src/flatfile.h:FlatFileSeq - In
src/hash.h:CHashVerifier - In
src/miner.h:CBlockAssembler - In
src/net_processing.h:PeerLogicValidation - In
src/scheduler.h:SingleThreadedSchedulerClient(#25040) - In
src/sync.h:CSemaphoreGrant - In
src/validation.h:CScriptCheck,ChainstateManager,CChainState
Several of these accept const lvalue references, and store them, and are at risk already. Others take in a mutable lvalue reference or pointers, but would make sense to support rvalue/universal references as input (so that temporaries can be passed to it). In all those cases, having a lifetimebound attribute would be useful.
So I think that means we should just put it in attributes.h. There is plenty of potential for it.