Skip to content

Commit

Permalink
Restore the TUScope only when we are not in incremental processing mode.
Browse files Browse the repository at this point in the history
The TUScope is set to nullptr in Sema::ActOnEndOfTranslationUnit onlu when
incremental processing mode in off. This makes the state of Sema more consistent
when Clad is on/off.
  • Loading branch information
vgvassilev committed May 5, 2024
1 parent d32154c commit a8cbd5f
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tools/ClangPlugin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,8 @@ namespace clad {
void CladPlugin::HandleTranslationUnit(ASTContext& C) {
Sema& S = m_CI.getSema();
// Restore the TUScope that became a 0 in Sema::ActOnEndOfTranslationUnit.
S.TUScope = m_StoredTUScope;
if (!m_CI.getPreprocessor().isIncrementalProcessingEnabled())
S.TUScope = m_StoredTUScope;
constexpr bool Enabled = true;
Sema::GlobalEagerInstantiationScope GlobalInstantiations(S, Enabled);
Sema::LocalEagerInstantiationScope LocalInstantiations(S);
Expand All @@ -409,8 +410,11 @@ namespace clad {
m_DiffRequestGraph.markCurrentNodeProcessed();
request = m_DiffRequestGraph.getNextToProcessNode();
}

// Put the TUScope in a consistent state after clad is done.
S.TUScope = nullptr;
if (!m_CI.getPreprocessor().isIncrementalProcessingEnabled())
S.TUScope = nullptr;

// Force emission of the produced pending template instantiations.
LocalInstantiations.perform();
GlobalInstantiations.perform();
Expand Down

0 comments on commit a8cbd5f

Please sign in to comment.