diff options
author | Jan Svoboda <jan_svoboda@apple.com> | 2025-04-04 10:11:14 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-04 10:11:14 -0700 |
commit | 1688c3062a56b4fca1f8ad28f2865df0ed8ca940 (patch) | |
tree | 54a166397652bb5c96fdd30caabf46765eb06f6e /clang/lib/Lex/Preprocessor.cpp | |
parent | 90cf2e31abdee050b5811155c86605935046b07e (diff) | |
download | llvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.zip llvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.tar.gz llvm-1688c3062a56b4fca1f8ad28f2865df0ed8ca940.tar.bz2 |
[clang] Do not share ownership of `PreprocessorOptions` (#133467)
This PR makes it so that `CompilerInvocation` is the sole owner of the
`PreprocessorOptions` instance.
Diffstat (limited to 'clang/lib/Lex/Preprocessor.cpp')
-rw-r--r-- | clang/lib/Lex/Preprocessor.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp index ff99575..c25a3ef 100644 --- a/clang/lib/Lex/Preprocessor.cpp +++ b/clang/lib/Lex/Preprocessor.cpp @@ -77,13 +77,13 @@ LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry) ExternalPreprocessorSource::~ExternalPreprocessorSource() = default; -Preprocessor::Preprocessor(std::shared_ptr<const PreprocessorOptions> PPOpts, +Preprocessor::Preprocessor(const PreprocessorOptions &PPOpts, DiagnosticsEngine &diags, const LangOptions &opts, SourceManager &SM, HeaderSearch &Headers, ModuleLoader &TheModuleLoader, IdentifierInfoLookup *IILookup, bool OwnsHeaders, TranslationUnitKind TUKind) - : PPOpts(std::move(PPOpts)), Diags(&diags), LangOpts(opts), + : PPOpts(PPOpts), Diags(&diags), LangOpts(opts), FileMgr(Headers.getFileMgr()), SourceMgr(SM), ScratchBuf(new ScratchBuffer(SourceMgr)), HeaderInfo(Headers), TheModuleLoader(TheModuleLoader), ExternalSource(nullptr), @@ -156,11 +156,11 @@ Preprocessor::Preprocessor(std::shared_ptr<const PreprocessorOptions> PPOpts, SkippingUntilPragmaHdrStop = true; // If using a PCH with a through header, start skipping tokens. - if (!this->PPOpts->PCHThroughHeader.empty() && - !this->PPOpts->ImplicitPCHInclude.empty()) + if (!this->PPOpts.PCHThroughHeader.empty() && + !this->PPOpts.ImplicitPCHInclude.empty()) SkippingUntilPCHThroughHeader = true; - if (this->PPOpts->GeneratePreamble) + if (this->PPOpts.GeneratePreamble) PreambleConditionalStack.startRecording(); MaxTokens = LangOpts.MaxTokens; @@ -577,18 +577,18 @@ void Preprocessor::EnterMainSourceFile() { // Start parsing the predefines. EnterSourceFile(FID, nullptr, SourceLocation()); - if (!PPOpts->PCHThroughHeader.empty()) { + if (!PPOpts.PCHThroughHeader.empty()) { // Lookup and save the FileID for the through header. If it isn't found // in the search path, it's a fatal error. OptionalFileEntryRef File = LookupFile( - SourceLocation(), PPOpts->PCHThroughHeader, + SourceLocation(), PPOpts.PCHThroughHeader, /*isAngled=*/false, /*FromDir=*/nullptr, /*FromFile=*/nullptr, /*CurDir=*/nullptr, /*SearchPath=*/nullptr, /*RelativePath=*/nullptr, /*SuggestedModule=*/nullptr, /*IsMapped=*/nullptr, /*IsFrameworkFound=*/nullptr); if (!File) { Diag(SourceLocation(), diag::err_pp_through_header_not_found) - << PPOpts->PCHThroughHeader; + << PPOpts.PCHThroughHeader; return; } setPCHThroughHeaderFileID( @@ -614,21 +614,21 @@ bool Preprocessor::isPCHThroughHeader(const FileEntry *FE) { } bool Preprocessor::creatingPCHWithThroughHeader() { - return TUKind == TU_Prefix && !PPOpts->PCHThroughHeader.empty() && + return TUKind == TU_Prefix && !PPOpts.PCHThroughHeader.empty() && PCHThroughHeaderFileID.isValid(); } bool Preprocessor::usingPCHWithThroughHeader() { - return TUKind != TU_Prefix && !PPOpts->PCHThroughHeader.empty() && + return TUKind != TU_Prefix && !PPOpts.PCHThroughHeader.empty() && PCHThroughHeaderFileID.isValid(); } bool Preprocessor::creatingPCHWithPragmaHdrStop() { - return TUKind == TU_Prefix && PPOpts->PCHWithHdrStop; + return TUKind == TU_Prefix && PPOpts.PCHWithHdrStop; } bool Preprocessor::usingPCHWithPragmaHdrStop() { - return TUKind != TU_Prefix && PPOpts->PCHWithHdrStop; + return TUKind != TU_Prefix && PPOpts.PCHWithHdrStop; } /// Skip tokens until after the #include of the through header or @@ -657,8 +657,8 @@ void Preprocessor::SkipTokensWhileUsingPCH() { if (ReachedMainFileEOF) { if (UsingPCHThroughHeader) Diag(SourceLocation(), diag::err_pp_through_header_not_seen) - << PPOpts->PCHThroughHeader << 1; - else if (!PPOpts->PCHWithHdrStopCreate) + << PPOpts.PCHThroughHeader << 1; + else if (!PPOpts.PCHWithHdrStopCreate) Diag(SourceLocation(), diag::err_pp_pragma_hdrstop_not_seen); } } |