Prepone callback initialization in cling.
We should setup our callbacks for ExternalASTSource/ExternalSemaSource before we parse *any* code to prevent that any part of the code stores a reference to a non-cling external sources. If this happens, then the clang data structures such redecl chain could go out of sync if they reference different sources and produce errors like failing to merge declarations correctly or creating invalid redecl chains. To fix this, we move this initalization before the initalization of the incremental parser which is the first part that can generate any AST nodes.
This commit is contained in:
parent
0f16f1ac15
commit
1ebf53715c
@ -226,6 +226,17 @@ namespace cling {
|
||||
DiagnosticConsumer& DClient = getCI()->getDiagnosticClient();
|
||||
DClient.BeginSourceFile(getCI()->getLangOpts(), &PP);
|
||||
|
||||
// Disable suggestions for ROOT
|
||||
bool showSuggestions =
|
||||
!llvm::StringRef(ClingStringify(CLING_VERSION)).startswith("ROOT");
|
||||
|
||||
// We need InterpreterCallbacks only if it is a parent Interpreter.
|
||||
if (!parentInterp) {
|
||||
std::unique_ptr<InterpreterCallbacks> AutoLoadCB(
|
||||
new AutoloadCallback(this, showSuggestions));
|
||||
setCallbacks(std::move(AutoLoadCB));
|
||||
}
|
||||
|
||||
llvm::SmallVector<IncrementalParser::ParseResultTransaction, 2>
|
||||
IncrParserTransactions;
|
||||
if (!m_IncrParser->Initialize(IncrParserTransactions, parentInterp)) {
|
||||
@ -269,16 +280,6 @@ namespace cling {
|
||||
}
|
||||
}
|
||||
|
||||
// Disable suggestions for ROOT
|
||||
bool showSuggestions = !llvm::StringRef(ClingStringify(CLING_VERSION)).startswith("ROOT");
|
||||
|
||||
// We need InterpreterCallbacks only if it is a parent Interpreter.
|
||||
if (!parentInterp) {
|
||||
std::unique_ptr<InterpreterCallbacks>
|
||||
AutoLoadCB(new AutoloadCallback(this, showSuggestions));
|
||||
setCallbacks(std::move(AutoLoadCB));
|
||||
}
|
||||
|
||||
m_IncrParser->SetTransformers(parentInterp);
|
||||
|
||||
if (!m_LLVMContext) {
|
||||
|
Loading…
Reference in New Issue
Block a user