DefinitionShadower: added `DefinitionShadowed' interpreter callback
This commit is contained in:
parent
2fb847c438
commit
93ae61f704
@ -154,6 +154,11 @@ namespace cling {
|
||||
///
|
||||
virtual void TransactionRollback(const Transaction&) {}
|
||||
|
||||
/// \brief This callback is invoked if a previous definition has been shadowed.
|
||||
///
|
||||
///\param[in] - The declaration that has been shadowed.
|
||||
virtual void DefinitionShadowed(const clang::NamedDecl*) {}
|
||||
|
||||
/// \brief Used to inform client about a new decl read by the ASTReader.
|
||||
///
|
||||
///\param[in] - The Decl read by the ASTReader.
|
||||
|
@ -42,7 +42,7 @@ namespace cling {
|
||||
return true;
|
||||
}
|
||||
|
||||
DefinitionShadower::DefinitionShadower(Sema& S, Interpreter& I)
|
||||
DefinitionShadower::DefinitionShadower(Sema& S, Interpreter& I)
|
||||
: ASTTransformer(&S), m_Interp(I), m_Context(S.getASTContext()),
|
||||
m_TU(S.getASTContext().getTranslationUnitDecl()),
|
||||
m_UniqueNameCounter(0)
|
||||
@ -67,6 +67,9 @@ namespace cling {
|
||||
clang::StoredDeclsList &SDL = (*m_TU->getLookupPtr())[D->getDeclName()];
|
||||
if (SDL.getAsVector() || SDL.getAsDecl() == D)
|
||||
SDL.remove(D);
|
||||
|
||||
if (InterpreterCallbacks *IC = m_Interp.getCallbacks())
|
||||
IC->DefinitionShadowed(D);
|
||||
}
|
||||
|
||||
void DefinitionShadower::invalidatePreviousDefinitions(NamedDecl *D) const {
|
||||
@ -124,7 +127,6 @@ namespace cling {
|
||||
auto DS = dyn_cast<DeclStmt>(I);
|
||||
if (!DS)
|
||||
continue;
|
||||
|
||||
for (auto &J : DS->decls())
|
||||
if (auto ND = dyn_cast<NamedDecl>(J))
|
||||
invalidatePreviousDefinitions(ND);
|
||||
|
@ -104,6 +104,12 @@ namespace cling {
|
||||
}
|
||||
}
|
||||
|
||||
void DefinitionShadowed(const clang::NamedDecl* D) override {
|
||||
for (auto&& cb : m_Callbacks) {
|
||||
cb->DefinitionShadowed(D);
|
||||
}
|
||||
}
|
||||
|
||||
void DeclDeserialized(const clang::Decl* D) override {
|
||||
for (auto&& cb : m_Callbacks) {
|
||||
cb->DeclDeserialized(D);
|
||||
|
Loading…
x
Reference in New Issue
Block a user