[clang] [clang-tools-extra] [clang] Hide the `TargetOptions` pointer from `CompilerInvocation` (PR #106271)
kadir çetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Aug 30 06:13:18 PDT 2024
================
@@ -216,7 +216,7 @@ enum OpenCLTypeKind : uint8_t {
///
class TargetInfo : public TransferrableTargetInfo,
public RefCountedBase<TargetInfo> {
- std::shared_ptr<TargetOptions> TargetOpts;
+ TargetOptions *TargetOpts;
----------------
kadircet wrote:
this is making me a little anxious. previously a `TargetInfo` was valid even if `TargetOptions` used during construction went away.
now we're breaking that contract, any code pattern that keeps `TargetInfo`s alive, now needs to make sure underlying options are outliving it. AFAICT, you ensured usages upstream are updated accordingly (and are safe), but I am afraid this might break downstream projects. This is fine, but it would be nice to prevent it if we can.
I do understand we need to hide `TargetOptions` from `CompilerInvocation`, but do we have a reason to make this reference non-owning ? (this should also ensure we don't create a new unique_ptr for AuxTargetOpts in `CompilerInstance.h`.
https://github.com/llvm/llvm-project/pull/106271
More information about the cfe-commits
mailing list