Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 2 additions & 19 deletions interpreter/cling/lib/Interpreter/EnterUserCodeRAII.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#define CLING_ENTERUSERCODERAII_H

#include "cling/Interpreter/Interpreter.h"
#include "cling/Interpreter/InterpreterAccessRAII.h"
#include "cling/Interpreter/InterpreterCallbacks.h"

namespace cling {
Expand All @@ -34,25 +35,7 @@ struct EnterUserCodeRAII {
}
};

struct LockCompilationDuringUserCodeExecutionRAII {
/// Callbacks used to un/lock.
InterpreterCallbacks* fCallbacks;
/// Info provided to UnlockCompilationDuringUserCodeExecution().
void* fStateInfo = nullptr;
LockCompilationDuringUserCodeExecutionRAII(InterpreterCallbacks* callbacks):
fCallbacks(callbacks) {
if (fCallbacks)
fStateInfo = fCallbacks->LockCompilationDuringUserCodeExecution();
}

LockCompilationDuringUserCodeExecutionRAII(Interpreter& interp):
LockCompilationDuringUserCodeExecutionRAII(interp.getCallbacks()) {}

~LockCompilationDuringUserCodeExecutionRAII() {
if (fCallbacks)
fCallbacks->UnlockCompilationDuringUserCodeExecution(fStateInfo);
}
};
using LockCompilationDuringUserCodeExecutionRAII = cling::InterpreterAccessRAII;
}

#endif // CLING_ENTERUSERCODERAII_H
9 changes: 9 additions & 0 deletions interpreter/cling/lib/Interpreter/LookupHelper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@
#include "clang/Sema/Template.h"
#include "clang/Sema/TemplateDeduction.h"

#include "EnterUserCodeRAII.h"

using namespace clang;

namespace cling {
Expand Down Expand Up @@ -465,6 +467,13 @@ namespace cling {

if (typeName.empty()) return TheQT;

// findType is called from TClingLookupHelper::GetPartiallyDesugaredNameWithScopeHandling
// which is called indirectly from TClassEdit::GetNormalizedName via
// the ResolvedTypedef code paths. Through that code path nothing is
// taking the ROOT/Interpreter lock and since this code can modify the
// interpreter, we do need to take lock.
InterpreterAccessRAII LockAccess(*m_Interpreter);

// Could trigger deserialization of decls.
Interpreter::PushTransactionRAII RAII(m_Interpreter);

Expand Down
Loading