[clang] 277ab85 - [clang] Make `PreprocessorOptions` reference const

Jan Svoboda via cfe-commits cfe-commits at lists.llvm.org
Fri Mar 28 09:34:24 PDT 2025


Author: Jan Svoboda
Date: 2025-03-28T09:34:19-07:00
New Revision: 277ab85d1ccf80750f5193495c0665808c2863de

URL: https://github.com/llvm/llvm-project/commit/277ab85d1ccf80750f5193495c0665808c2863de
DIFF: https://github.com/llvm/llvm-project/commit/277ab85d1ccf80750f5193495c0665808c2863de.diff

LOG: [clang] Make `PreprocessorOptions` reference const

Added: 
    

Modified: 
    clang/include/clang/Lex/Preprocessor.h
    clang/lib/Lex/Preprocessor.cpp

Removed: 
    


################################################################################
diff  --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 313da0033cb04..4fdc4e0439125 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -140,7 +140,7 @@ class Preprocessor {
   friend class VariadicMacroScopeGuard;
 
   llvm::unique_function<void(const clang::Token &)> OnToken;
-  std::shared_ptr<PreprocessorOptions> PPOpts;
+  std::shared_ptr<const PreprocessorOptions> PPOpts;
   DiagnosticsEngine        *Diags;
   const LangOptions &LangOpts;
   const TargetInfo *Target = nullptr;
@@ -1165,7 +1165,7 @@ class Preprocessor {
   void updateOutOfDateIdentifier(const IdentifierInfo &II) const;
 
 public:
-  Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
+  Preprocessor(std::shared_ptr<const PreprocessorOptions> PPOpts,
                DiagnosticsEngine &diags, const LangOptions &LangOpts,
                SourceManager &SM, HeaderSearch &Headers,
                ModuleLoader &TheModuleLoader,
@@ -1197,7 +1197,7 @@ class Preprocessor {
 
   /// Retrieve the preprocessor options used to initialize this
   /// preprocessor.
-  PreprocessorOptions &getPreprocessorOpts() const { return *PPOpts; }
+  const PreprocessorOptions &getPreprocessorOpts() const { return *PPOpts; }
 
   DiagnosticsEngine &getDiagnostics() const { return *Diags; }
   void setDiagnostics(DiagnosticsEngine &D) { Diags = &D; }

diff  --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index 7256473d54ed2..ff99575dc611b 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -77,7 +77,7 @@ LLVM_INSTANTIATE_REGISTRY(PragmaHandlerRegistry)
 
 ExternalPreprocessorSource::~ExternalPreprocessorSource() = default;
 
-Preprocessor::Preprocessor(std::shared_ptr<PreprocessorOptions> PPOpts,
+Preprocessor::Preprocessor(std::shared_ptr<const PreprocessorOptions> PPOpts,
                            DiagnosticsEngine &diags, const LangOptions &opts,
                            SourceManager &SM, HeaderSearch &Headers,
                            ModuleLoader &TheModuleLoader,


        


More information about the cfe-commits mailing list