[cfe-commits] r138959 - in /cfe/trunk: include/clang/AST/ASTContext.h include/clang/Frontend/ASTUnit.h include/clang/Lex/Preprocessor.h include/clang/Serialization/ASTReader.h lib/AST/ASTContext.cpp lib/Frontend/ASTUnit.cpp lib/Lex/Preprocessor.cpp

Douglas Gregor dgregor at apple.com
Thu Sep 1 13:23:19 PDT 2011


Author: dgregor
Date: Thu Sep  1 15:23:19 2011
New Revision: 138959

URL: http://llvm.org/viewvc/llvm-project?rev=138959&view=rev
Log:
Teach ASTContext and Preprocessor to hold on to references to the same
LangOptions, rather than making distinct copies of
LangOptions. Granted, LangOptions doesn't actually get modified, but
this will eventually make it easier to construct ASTContext and
Preprocessor before we know all of the LangOptions.



Modified:
    cfe/trunk/include/clang/AST/ASTContext.h
    cfe/trunk/include/clang/Frontend/ASTUnit.h
    cfe/trunk/include/clang/Lex/Preprocessor.h
    cfe/trunk/include/clang/Serialization/ASTReader.h
    cfe/trunk/lib/AST/ASTContext.cpp
    cfe/trunk/lib/Frontend/ASTUnit.cpp
    cfe/trunk/lib/Lex/Preprocessor.cpp

Modified: cfe/trunk/include/clang/AST/ASTContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/ASTContext.h?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/ASTContext.h (original)
+++ cfe/trunk/include/clang/AST/ASTContext.h Thu Sep  1 15:23:19 2011
@@ -316,7 +316,7 @@
 
   /// LangOpts - The language options used to create the AST associated with
   ///  this ASTContext object.
-  LangOptions LangOpts;
+  LangOptions &LangOpts;
 
   /// \brief The allocator used to create AST objects.
   ///
@@ -478,7 +478,7 @@
   mutable QualType AutoDeductTy;     // Deduction against 'auto'.
   mutable QualType AutoRRefDeductTy; // Deduction against 'auto &&'.
 
-  ASTContext(const LangOptions& LOpts, SourceManager &SM, const TargetInfo &t,
+  ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo &t,
              IdentifierTable &idents, SelectorTable &sels,
              Builtin::Context &builtins,
              unsigned size_reserve);

Modified: cfe/trunk/include/clang/Frontend/ASTUnit.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Frontend/ASTUnit.h?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/include/clang/Frontend/ASTUnit.h (original)
+++ cfe/trunk/include/clang/Frontend/ASTUnit.h Thu Sep  1 15:23:19 2011
@@ -249,7 +249,10 @@
   /// \brief Whether we want to include nested macro expansions in the
   /// detailed preprocessing record.
   bool NestedMacroExpansions;
-  
+ 
+  /// \brief The language options used when we load an AST file.
+  LangOptions ASTFileLangOpts;
+
   static void ConfigureDiags(llvm::IntrusiveRefCntPtr<Diagnostic> &Diags,
                              const char **ArgBegin, const char **ArgEnd,
                              ASTUnit &AST, bool CaptureDiagnostics);

Modified: cfe/trunk/include/clang/Lex/Preprocessor.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Lex/Preprocessor.h?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/include/clang/Lex/Preprocessor.h (original)
+++ cfe/trunk/include/clang/Lex/Preprocessor.h Thu Sep  1 15:23:19 2011
@@ -58,7 +58,7 @@
 ///
 class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
   Diagnostic        *Diags;
-  LangOptions        Features;
+  LangOptions       &Features;
   const TargetInfo  &Target;
   FileManager       &FileMgr;
   SourceManager     &SourceMgr;
@@ -298,7 +298,7 @@
   MacroInfo *getInfoForMacro(IdentifierInfo *II) const;
   
 public:
-  Preprocessor(Diagnostic &diags, const LangOptions &opts,
+  Preprocessor(Diagnostic &diags, LangOptions &opts,
                const TargetInfo &target,
                SourceManager &SM, HeaderSearch &Headers,
                ModuleLoader &TheModuleLoader,

Modified: cfe/trunk/include/clang/Serialization/ASTReader.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Serialization/ASTReader.h?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/include/clang/Serialization/ASTReader.h (original)
+++ cfe/trunk/include/clang/Serialization/ASTReader.h Thu Sep  1 15:23:19 2011
@@ -224,7 +224,7 @@
   SourceManager &SourceMgr;
   FileManager &FileMgr;
   Diagnostic &Diags;
-
+  
   /// \brief The semantic analysis object that will be processing the
   /// AST files and the translation unit that uses it.
   Sema *SemaObj;

Modified: cfe/trunk/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/AST/ASTContext.cpp?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/lib/AST/ASTContext.cpp (original)
+++ cfe/trunk/lib/AST/ASTContext.cpp Thu Sep  1 15:23:19 2011
@@ -212,7 +212,7 @@
   }
 }
 
-ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
+ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
                        const TargetInfo &t,
                        IdentifierTable &idents, SelectorTable &sels,
                        Builtin::Context &builtins,

Modified: cfe/trunk/lib/Frontend/ASTUnit.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Frontend/ASTUnit.cpp?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/lib/Frontend/ASTUnit.cpp (original)
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp Thu Sep  1 15:23:19 2011
@@ -572,7 +572,6 @@
   
   // Gather Info for preprocessor construction later on.
 
-  LangOptions LangInfo;
   HeaderSearch &HeaderInfo = *AST->HeaderInfo.get();
   std::string TargetTriple;
   std::string Predefines;
@@ -587,8 +586,8 @@
   llvm::CrashRecoveryContextCleanupRegistrar<ASTReader>
     ReaderCleanup(Reader.get());
 
-  Reader->setListener(new ASTInfoCollector(LangInfo, HeaderInfo, TargetTriple,
-                                           Predefines, Counter));
+  Reader->setListener(new ASTInfoCollector(AST->ASTFileLangOpts, HeaderInfo, 
+                                           TargetTriple, Predefines, Counter));
 
   switch (Reader->ReadAST(Filename, serialization::MK_MainFile)) {
   case ASTReader::Success:
@@ -615,8 +614,9 @@
   TargetOpts.Triple = TargetTriple;
   AST->Target = TargetInfo::CreateTargetInfo(AST->getDiagnostics(),
                                              TargetOpts);
-  AST->PP = new Preprocessor(AST->getDiagnostics(), LangInfo, *AST->Target,
-                             AST->getSourceManager(), HeaderInfo, *AST);
+  AST->PP = new Preprocessor(AST->getDiagnostics(), AST->ASTFileLangOpts, 
+                             *AST->Target, AST->getSourceManager(), HeaderInfo, 
+                             *AST);
   Preprocessor &PP = *AST->PP;
 
   PP.setPredefines(Reader->getSuggestedPredefines());
@@ -625,7 +625,7 @@
 
   // Create and initialize the ASTContext.
 
-  AST->Ctx = new ASTContext(LangInfo,
+  AST->Ctx = new ASTContext(AST->ASTFileLangOpts,
                             AST->getSourceManager(),
                             *AST->Target,
                             PP.getIdentifierTable(),

Modified: cfe/trunk/lib/Lex/Preprocessor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Lex/Preprocessor.cpp?rev=138959&r1=138958&r2=138959&view=diff
==============================================================================
--- cfe/trunk/lib/Lex/Preprocessor.cpp (original)
+++ cfe/trunk/lib/Lex/Preprocessor.cpp Thu Sep  1 15:23:19 2011
@@ -49,7 +49,7 @@
 //===----------------------------------------------------------------------===//
 ExternalPreprocessorSource::~ExternalPreprocessorSource() { }
 
-Preprocessor::Preprocessor(Diagnostic &diags, const LangOptions &opts,
+Preprocessor::Preprocessor(Diagnostic &diags, LangOptions &opts,
                            const TargetInfo &target, SourceManager &SM,
                            HeaderSearch &Headers, ModuleLoader &TheModuleLoader,
                            IdentifierInfoLookup* IILookup,





More information about the cfe-commits mailing list