[clang] [clang] Hide the `LangOptions` pointer from `CompilerInvocation` (PR #137675)

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Tue Apr 29 10:20:04 PDT 2025


jansvoboda11 wrote:

> > The `unique_ptr` in `ASTUnit` always stores a **copy** of the `shared_ptr` in `CompilerInvocation`.
> 
> And we need `unique_ptr` in `ASTUnit` instead of a direct value so we can change LangOpts in `ASTUnit::Parse`?

Not really, using `LangOptions` directly instead of `std::unique_ptr<LangOptions>` allows reassignment too. I chose `std::unique_ptr` to:
* prevent increase of `ASTUnit` size,
* avoid unconditional initialization of `ASTUnit:: LangOpts` in the constructor (which would be an unnecessary change in this PR I think).

https://github.com/llvm/llvm-project/pull/137675


More information about the cfe-commits mailing list