diff options
| author | Douglas Gregor <dgregor@apple.com> | 2010-08-12 20:50:39 +0000 |
|---|---|---|
| committer | Douglas Gregor <dgregor@apple.com> | 2010-08-12 20:50:39 +0000 |
| commit | ad814e224f916f0960ab748380f4ac73c50185ac (patch) | |
| tree | 68a1ecc0c9f8a92ec18c5865dbae612a08f99a6a /clang/lib/Sema/Sema.cpp | |
| parent | 8e8f1c133a50b21ab35e04762ade3eacd44db48d (diff) | |
| download | bcm5719-llvm-ad814e224f916f0960ab748380f4ac73c50185ac.tar.gz bcm5719-llvm-ad814e224f916f0960ab748380f4ac73c50185ac.zip | |
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.
llvm-svn: 110952
Diffstat (limited to 'clang/lib/Sema/Sema.cpp')
| -rw-r--r-- | clang/lib/Sema/Sema.cpp | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/lib/Sema/Sema.cpp b/clang/lib/Sema/Sema.cpp index e7f5bb4317f..a504ae69a2c 100644 --- a/clang/lib/Sema/Sema.cpp +++ b/clang/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. |

