Implement autoloading of entities in unknown namespaces. Eg. MyNamespace::MyClass. The implementation is far from ideal, but for the timeline we have it is good enough. On a second iteration it could be improved a lot.
This commit is contained in:
parent
11c62f09b2
commit
88cc4a1ed2
@ -13,6 +13,7 @@
|
||||
|
||||
namespace clang {
|
||||
class Decl;
|
||||
class DeclContext;
|
||||
class LookupResult;
|
||||
class Scope;
|
||||
}
|
||||
@ -54,6 +55,15 @@ namespace cling {
|
||||
///\returns true if a suitable declaration is found.
|
||||
///
|
||||
virtual bool LookupUnqualified(clang::LookupResult& R, clang::Scope* S);
|
||||
|
||||
virtual bool FindExternalVisibleDeclsByName(const clang::DeclContext* DC,
|
||||
clang::DeclarationName Name);
|
||||
|
||||
void UpdateWithNewDecls(const clang::DeclContext *DC,
|
||||
clang::DeclarationName Name,
|
||||
llvm::ArrayRef<clang::NamedDecl*> Decls) {
|
||||
SetExternalVisibleDeclsForName(DC, Name, Decls);
|
||||
}
|
||||
};
|
||||
|
||||
/// \brief This interface provides a way to observe the actions of the
|
||||
@ -78,6 +88,13 @@ namespace cling {
|
||||
///\brief DynamicScopes only! Set to true only when evaluating dynamic expr.
|
||||
///
|
||||
bool m_IsRuntime;
|
||||
protected:
|
||||
void UpdateWithNewDecls(const clang::DeclContext *DC,
|
||||
clang::DeclarationName Name,
|
||||
llvm::ArrayRef<clang::NamedDecl*> Decls) {
|
||||
if (getInterpreterExternalSemaSource())
|
||||
getInterpreterExternalSemaSource()->UpdateWithNewDecls(DC, Name, Decls);
|
||||
}
|
||||
public:
|
||||
InterpreterCallbacks(Interpreter* interp,
|
||||
InterpreterExternalSemaSource* IESS = 0);
|
||||
@ -95,6 +112,7 @@ namespace cling {
|
||||
/// \returns true if lookup result is found and should be used.
|
||||
///
|
||||
virtual bool LookupObject(clang::LookupResult&, clang::Scope*);
|
||||
virtual bool LookupObject(const clang::DeclContext*, clang::DeclarationName);
|
||||
|
||||
///\brief This callback is invoked whenever interpreter has committed new
|
||||
/// portion of declarations.
|
||||
@ -157,6 +175,9 @@ namespace cling {
|
||||
~SymbolResolverCallback();
|
||||
|
||||
bool LookupObject(clang::LookupResult& R, clang::Scope* S);
|
||||
bool LookupObject(const clang::DeclContext*, clang::DeclarationName) {
|
||||
return false;
|
||||
}
|
||||
bool ShouldResolveAtRuntime(clang::LookupResult& R, clang::Scope* S);
|
||||
};
|
||||
} // end test
|
||||
|
@ -914,6 +914,15 @@ namespace cling {
|
||||
getCI()->getModuleManager()
|
||||
->setDeserializationListener(m_CallbackAdaptor);
|
||||
}
|
||||
|
||||
// FIXME: We should add a multiplexer in the ASTContext, too.
|
||||
llvm::OwningPtr<ExternalASTSource> astContextExternalSource;
|
||||
astContextExternalSource.reset(getSema().getExternalSource());
|
||||
clang::ASTContext& Ctx = getSema().getASTContext();
|
||||
// FIXME: This is a gross hack. We must make multiplexer in the astcontext,
|
||||
// or a derived class that extends what we need.
|
||||
Ctx.ExternalSource.take(); // FIXME: make sure we delete it.
|
||||
Ctx.setExternalSource(astContextExternalSource);
|
||||
}
|
||||
|
||||
clang::ASTDeserializationListener*
|
||||
|
@ -25,6 +25,16 @@ namespace cling {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
InterpreterExternalSemaSource::FindExternalVisibleDeclsByName(
|
||||
const DeclContext* DC,
|
||||
DeclarationName Name) {
|
||||
if (m_Callbacks)
|
||||
return m_Callbacks->LookupObject(DC, Name);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
InterpreterCallbacks::InterpreterCallbacks(Interpreter* interp,
|
||||
InterpreterExternalSemaSource* IESS)
|
||||
: m_Interpreter(interp), m_SemaExternalSource(IESS), m_IsRuntime(false) {
|
||||
@ -45,6 +55,10 @@ namespace cling {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool InterpreterCallbacks::LookupObject(const DeclContext*, DeclarationName) {
|
||||
return false;
|
||||
}
|
||||
|
||||
} // end namespace cling
|
||||
|
||||
// TODO: Make the build system in the testsuite aware how to build that class
|
||||
|
Loading…
x
Reference in New Issue
Block a user