summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlp Toker <alp@nuanti.com>2014-05-03 03:46:04 +0000
committerAlp Toker <alp@nuanti.com>2014-05-03 03:46:04 +0000
commit1e0ab3f294f3514ccfa915056cd31f2e8a4b7dbc (patch)
tree3d805245402395129ecf9551feebf7b45b96ee48
parenteba660f596a9acf8e0fa7f576ed8711ae71c7220 (diff)
downloadclang-1e0ab3f294f3514ccfa915056cd31f2e8a4b7dbc.tar.gz
clang-1e0ab3f294f3514ccfa915056cd31f2e8a4b7dbc.tar.bz2
clang-1e0ab3f294f3514ccfa915056cd31f2e8a4b7dbc.tar.xz
Eliminate ASTContext's DelayInitialization flag
Having various possible states of initialization following construction doesn't add value here. Also remove the unused size_reserve parameter. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207897 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/clang/AST/ASTContext.h11
-rw-r--r--lib/AST/ASTContext.cpp13
-rw-r--r--lib/Frontend/ASTUnit.cpp11
-rw-r--r--lib/Frontend/CompilerInstance.cpp6
-rw-r--r--unittests/Lex/PPCallbacksTest.cpp6
5 files changed, 15 insertions, 32 deletions
diff --git a/include/clang/AST/ASTContext.h b/include/clang/AST/ASTContext.h
index ca1a9067c5..21017fcb3d 100644
--- a/include/clang/AST/ASTContext.h
+++ b/include/clang/AST/ASTContext.h
@@ -799,11 +799,8 @@ public:
// The type is built when constructing 'BuiltinVaListDecl'.
mutable QualType VaListTagTy;
- ASTContext(LangOptions& LOpts, SourceManager &SM, const TargetInfo *t,
- IdentifierTable &idents, SelectorTable &sels,
- Builtin::Context &builtins,
- unsigned size_reserve,
- bool DelayInitialization = false);
+ ASTContext(LangOptions &LOpts, SourceManager &SM, IdentifierTable &idents,
+ SelectorTable &sels, Builtin::Context &builtins);
~ASTContext();
@@ -2246,9 +2243,7 @@ public:
/// \brief Initialize built-in types.
///
/// This routine may only be invoked once for a given ASTContext object.
- /// It is normally invoked by the ASTContext constructor. However, the
- /// constructor can be asked to delay initialization, which places the burden
- /// of calling this function on the user of that object.
+ /// It is normally invoked after ASTContext construction.
///
/// \param Target The target
void InitBuiltinTypes(const TargetInfo &Target);
diff --git a/lib/AST/ASTContext.cpp b/lib/AST/ASTContext.cpp
index c6f8e20a17..e46a6c024d 100644
--- a/lib/AST/ASTContext.cpp
+++ b/lib/AST/ASTContext.cpp
@@ -724,11 +724,8 @@ static bool isAddrSpaceMapManglingEnabled(const TargetInfo &TI,
}
ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
- const TargetInfo *t,
IdentifierTable &idents, SelectorTable &sels,
- Builtin::Context &builtins,
- unsigned size_reserve,
- bool DelayInitialization)
+ Builtin::Context &builtins)
: FunctionProtoTypes(this_()),
TemplateSpecializationTypes(this_()),
DependentTemplateSpecializationTypes(this_()),
@@ -746,7 +743,7 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
NullTypeSourceInfo(QualType()),
FirstLocalImport(), LastLocalImport(),
SourceMgr(SM), LangOpts(LOpts),
- AddrSpaceMap(0), Target(t), PrintingPolicy(LOpts),
+ AddrSpaceMap(0), Target(0), PrintingPolicy(LOpts),
Idents(idents), Selectors(sels),
BuiltinInfo(builtins),
DeclarationNames(*this),
@@ -755,13 +752,7 @@ ASTContext::ASTContext(LangOptions& LOpts, SourceManager &SM,
CommentCommandTraits(BumpAlloc, LOpts.CommentOpts),
LastSDM(0, 0)
{
- if (size_reserve > 0) Types.reserve(size_reserve);
TUDecl = TranslationUnitDecl::Create(*this);
-
- if (!DelayInitialization) {
- assert(t && "No target supplied for ASTContext initialization");
- InitBuiltinTypes(*t);
- }
}
ASTContext::~ASTContext() {
diff --git a/lib/Frontend/ASTUnit.cpp b/lib/Frontend/ASTUnit.cpp
index 8594571342..2532d26d6e 100644
--- a/lib/Frontend/ASTUnit.cpp
+++ b/lib/Frontend/ASTUnit.cpp
@@ -723,14 +723,9 @@ ASTUnit *ASTUnit::LoadFromASTFile(const std::string &Filename,
/*OwnsHeaderSearch=*/false);
Preprocessor &PP = *AST->PP;
- AST->Ctx = new ASTContext(AST->ASTFileLangOpts,
- AST->getSourceManager(),
- /*Target=*/0,
- PP.getIdentifierTable(),
- PP.getSelectorTable(),
- PP.getBuiltinInfo(),
- /* size_reserve = */0,
- /*DelayInitialization=*/true);
+ AST->Ctx = new ASTContext(AST->ASTFileLangOpts, AST->getSourceManager(),
+ PP.getIdentifierTable(), PP.getSelectorTable(),
+ PP.getBuiltinInfo());
ASTContext &Context = *AST->Ctx;
bool disableValid = false;
diff --git a/lib/Frontend/CompilerInstance.cpp b/lib/Frontend/CompilerInstance.cpp
index e9672c4426..76301f2a44 100644
--- a/lib/Frontend/CompilerInstance.cpp
+++ b/lib/Frontend/CompilerInstance.cpp
@@ -300,9 +300,9 @@ void CompilerInstance::createPreprocessor(TranslationUnitKind TUKind) {
void CompilerInstance::createASTContext() {
Preprocessor &PP = getPreprocessor();
Context = new ASTContext(getLangOpts(), PP.getSourceManager(),
- &getTarget(), PP.getIdentifierTable(),
- PP.getSelectorTable(), PP.getBuiltinInfo(),
- /*size_reserve=*/ 0);
+ PP.getIdentifierTable(), PP.getSelectorTable(),
+ PP.getBuiltinInfo());
+ Context->InitBuiltinTypes(getTarget());
}
// ExternalASTSource
diff --git a/unittests/Lex/PPCallbacksTest.cpp b/unittests/Lex/PPCallbacksTest.cpp
index 043c3003ce..d3138c0500 100644
--- a/unittests/Lex/PPCallbacksTest.cpp
+++ b/unittests/Lex/PPCallbacksTest.cpp
@@ -213,9 +213,11 @@ protected:
// parser actually sets correct pragma handlers for preprocessor
// according to LangOptions, so we init Parser to register opencl
// pragma handlers
- ASTContext Context(OpenCLLangOpts, SourceMgr, Target.getPtr(),
+ ASTContext Context(OpenCLLangOpts, SourceMgr,
PP.getIdentifierTable(), PP.getSelectorTable(),
- PP.getBuiltinInfo(), 0);
+ PP.getBuiltinInfo());
+ Context.InitBuiltinTypes(*Target);
+
ASTConsumer Consumer;
Sema S(PP, Context, Consumer);
Parser P(PP, S, false);