summaryrefslogtreecommitdiffstats
path: root/clang
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2011-09-01 20:23:19 +0000
committerDouglas Gregor <dgregor@apple.com>2011-09-01 20:23:19 +0000
commit7018d5bcfb48502c5ab7d9bc89eb3d41dd8fb76d (patch)
tree8beb4c56592139275ffe69042526045cd0c85b50 /clang
parent415e47dd6e51565fbddcc4974fd77e6f3b2aeabc (diff)
downloadbcm5719-llvm-7018d5bcfb48502c5ab7d9bc89eb3d41dd8fb76d.tar.gz
bcm5719-llvm-7018d5bcfb48502c5ab7d9bc89eb3d41dd8fb76d.zip
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. llvm-svn: 138959
Diffstat (limited to 'clang')
-rw-r--r--clang/include/clang/AST/ASTContext.h4
-rw-r--r--clang/include/clang/Frontend/ASTUnit.h5
-rw-r--r--clang/include/clang/Lex/Preprocessor.h4
-rw-r--r--clang/include/clang/Serialization/ASTReader.h2
-rw-r--r--clang/lib/AST/ASTContext.cpp2
-rw-r--r--clang/lib/Frontend/ASTUnit.cpp12
-rw-r--r--clang/lib/Lex/Preprocessor.cpp2
7 files changed, 17 insertions, 14 deletions
diff --git a/clang/include/clang/AST/ASTContext.h b/clang/include/clang/AST/ASTContext.h
index ac32b1a526c..7d034478f3b 100644
--- a/clang/include/clang/AST/ASTContext.h
+++ b/clang/include/clang/AST/ASTContext.h
@@ -316,7 +316,7 @@ class ASTContext : public llvm::RefCountedBase<ASTContext> {
/// 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 @@ public:
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);
diff --git a/clang/include/clang/Frontend/ASTUnit.h b/clang/include/clang/Frontend/ASTUnit.h
index 731ce383fc7..2fc1491c1ad 100644
--- a/clang/include/clang/Frontend/ASTUnit.h
+++ b/clang/include/clang/Frontend/ASTUnit.h
@@ -249,7 +249,10 @@ private:
/// \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);
diff --git a/clang/include/clang/Lex/Preprocessor.h b/clang/include/clang/Lex/Preprocessor.h
index 2871c8f080a..c9e45d0c97e 100644
--- a/clang/include/clang/Lex/Preprocessor.h
+++ b/clang/include/clang/Lex/Preprocessor.h
@@ -58,7 +58,7 @@ class ModuleLoader;
///
class Preprocessor : public llvm::RefCountedBase<Preprocessor> {
Diagnostic *Diags;
- LangOptions Features;
+ LangOptions &Features;
const TargetInfo &Target;
FileManager &FileMgr;
SourceManager &SourceMgr;
@@ -298,7 +298,7 @@ private: // Cached tokens state.
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,
diff --git a/clang/include/clang/Serialization/ASTReader.h b/clang/include/clang/Serialization/ASTReader.h
index 0cec2f455b5..71a597f9a57 100644
--- a/clang/include/clang/Serialization/ASTReader.h
+++ b/clang/include/clang/Serialization/ASTReader.h
@@ -224,7 +224,7 @@ private:
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;
diff --git a/clang/lib/AST/ASTContext.cpp b/clang/lib/AST/ASTContext.cpp
index 75a573e301b..3406be552c7 100644
--- a/clang/lib/AST/ASTContext.cpp
+++ b/clang/lib/AST/ASTContext.cpp
@@ -212,7 +212,7 @@ static const LangAS::Map &getAddressSpaceMap(const TargetInfo &T,
}
}
-ASTContext::ASTContext(const LangOptions& LOpts, SourceManager &SM,
+ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
const TargetInfo &t,
IdentifierTable &idents, SelectorTable &sels,
Builtin::Context &builtins,
diff --git a/clang/lib/Frontend/ASTUnit.cpp b/clang/lib/Frontend/ASTUnit.cpp
index eee5b1a7cca..b09c435c8a0 100644
--- a/clang/lib/Frontend/ASTUnit.cpp
+++ b/clang/lib/Frontend/ASTUnit.cpp
@@ -572,7 +572,6 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
// Gather Info for preprocessor construction later on.
- LangOptions LangInfo;
HeaderSearch &HeaderInfo = *AST->HeaderInfo.get();
std::string TargetTriple;
std::string Predefines;
@@ -587,8 +586,8 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
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 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
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 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
// Create and initialize the ASTContext.
- AST->Ctx = new ASTContext(LangInfo,
+ AST->Ctx = new ASTContext(AST->ASTFileLangOpts,
AST->getSourceManager(),
*AST->Target,
PP.getIdentifierTable(),
diff --git a/clang/lib/Lex/Preprocessor.cpp b/clang/lib/Lex/Preprocessor.cpp
index b285660c085..f00349081cd 100644
--- a/clang/lib/Lex/Preprocessor.cpp
+++ b/clang/lib/Lex/Preprocessor.cpp
@@ -49,7 +49,7 @@ using namespace clang;
//===----------------------------------------------------------------------===//
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,
OpenPOWER on IntegriCloud