Disable DefinitionShadower by default; manually enable it from TCling

As requested by vgvassilev, DefinitionShadower is disabled by default in ClinG
and enabled manually in TCling, i.e. usable from the ROOT prompt and Jupyter
notebooks.
This commit is contained in:
Javier Lopez-Gomez 2019-09-18 16:08:13 +02:00 committed by SFT
parent 15e67afef2
commit e48a3bc179
2 changed files with 9 additions and 1 deletions

View File

@ -187,6 +187,10 @@ namespace cling {
///
bool m_RawInputEnabled;
///\brief Whether to allow decl redefinition, i.e. enable the DefinitionShadower.
///
bool m_RedefinitionAllowed;
///\brief Flag toggling the optimization level to be used.
///
int m_OptLevel;
@ -667,6 +671,9 @@ namespace cling {
bool isRawInputEnabled() const { return m_RawInputEnabled; }
void enableRawInput(bool raw = true) { m_RawInputEnabled = raw; }
bool isRedefinitionAllowed() const { return m_RedefinitionAllowed; }
void allowRedefinition(bool b = true) { m_RedefinitionAllowed = b; }
int getDefaultOptLevel() const { return m_OptLevel; }
void setDefaultOptLevel(int optLevel) { m_OptLevel = optLevel; }

View File

@ -224,6 +224,7 @@ namespace cling {
m_UniqueCounter(parentInterp ? parentInterp->m_UniqueCounter + 1 : 0),
m_PrintDebug(false), m_DynamicLookupDeclared(false),
m_DynamicLookupEnabled(false), m_RawInputEnabled(false),
m_RedefinitionAllowed(false),
m_OptLevel(parentInterp ? parentInterp->m_OptLevel : -1) {
if (handleSimpleOptions(m_Opts))
@ -781,7 +782,7 @@ namespace cling {
wrapPoint = utils::getWrapPoint(wrapReadySource, getCI()->getLangOpts());
CompilationOptions CO = makeDefaultCompilationOpts();
CO.EnableShadowing = !isRawInputEnabled();
CO.EnableShadowing = m_RedefinitionAllowed && !isRawInputEnabled();
if (isRawInputEnabled() || wrapPoint == std::string::npos) {
CO.DeclarationExtraction = 0;