aboutsummaryrefslogtreecommitdiff
path: root/lib/Sema/Sema.cpp
diff options
context:
space:
mode:
authorDouglas Gregor <dgregor@apple.com>2010-08-12 20:50:39 +0000
committerDouglas Gregor <dgregor@apple.com>2010-08-12 20:50:39 +0000
commit0eeb81baac6e82b065c0b03ad28ad1e580e78790 (patch)
treed022a83046c9dbd5b1c5c5df8c5bbd6152b28983 /lib/Sema/Sema.cpp
parent192b1464dce385ac1947eb8258c3a0cd4444c726 (diff)
Add a ParseAST overload that takes a Sema object, so that the caller
can create (and hold on to) the Sema object. Also, move Sema-related initialization/finalization with its various consumers and external sources into the Sema constructor and destructor, rather than placing it in ParseAST. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@110952 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/Sema.cpp')
-rw-r--r--lib/Sema/Sema.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/lib/Sema/Sema.cpp b/lib/Sema/Sema.cpp
index e7f5bb4317..a504ae69a2 100644
--- a/lib/Sema/Sema.cpp
+++ b/lib/Sema/Sema.cpp
@@ -143,6 +143,18 @@ Sema::Sema(Preprocessor &pp, ASTContext &ctxt, ASTConsumer &consumer,
ExprEvalContexts.push_back(
ExpressionEvaluationContextRecord(PotentiallyEvaluated, 0));
+
+ // Tell the AST consumer about this Sema object.
+ Consumer.Initialize(this);
+
+ // FIXME: Isn't this redundant with the initialization above?
+ if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
+ SC->InitializeSema(*this);
+
+ // Tell the external Sema source about this Sema object.
+ if (ExternalSemaSource *ExternalSema
+ = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
+ ExternalSema->InitializeSema(S)
}
Sema::~Sema() {
@@ -151,6 +163,15 @@ Sema::~Sema() {
delete TheTargetAttributesSema;
while (!FunctionScopes.empty())
PopFunctionOrBlockScope();
+
+ // Tell the SemaConsumer to forget about us; we're going out of scope.
+ if (SemaConsumer *SC = dyn_cast<SemaConsumer>(&Consumer))
+ SC->ForgetSema();
+
+ // Detach from the external Sema source.
+ if (ExternalSemaSource *ExternalSema
+ = dyn_cast_or_null<ExternalSemaSource>(Context.getExternalSource()))
+ ExternalSema->ForgetSema();
}
/// ImpCastExprToType - If Expr is not of type 'Type', insert an implicit cast.