diff --git a/include/cling/Interpreter/CompilationOptions.h b/include/cling/Interpreter/CompilationOptions.h index 289ef58f..2edfb7c6 100644 --- a/include/cling/Interpreter/CompilationOptions.h +++ b/include/cling/Interpreter/CompilationOptions.h @@ -58,6 +58,10 @@ namespace cling { /// is wrapped. unsigned IgnorePromptDiags : 1; + ///\brief Pointer validity check can be enabled/disabled. + /// + unsigned CheckPointerValidity : 1; + CompilationOptions() { DeclarationExtraction = 0; ValuePrinting = VPDisabled; @@ -67,6 +71,7 @@ namespace cling { CodeGeneration = 1; CodeGenerationForModule = 0; IgnorePromptDiags = 0; + CheckPointerValidity = 1; } bool operator==(CompilationOptions Other) const { @@ -78,7 +83,8 @@ namespace cling { Debug == Other.Debug && CodeGeneration == Other.CodeGeneration && CodeGenerationForModule == Other.CodeGenerationForModule && - IgnorePromptDiags == Other.IgnorePromptDiags; + IgnorePromptDiags == Other.IgnorePromptDiags && + CheckPointerValidity == Other.CheckPointerValidity; } bool operator!=(CompilationOptions Other) const { @@ -90,7 +96,8 @@ namespace cling { Debug != Other.Debug || CodeGeneration != Other.CodeGeneration || CodeGenerationForModule != Other.CodeGenerationForModule || - IgnorePromptDiags != Other.IgnorePromptDiags; + IgnorePromptDiags != Other.IgnorePromptDiags || + CheckPointerValidity != Other.CheckPointerValidity; } }; } // end namespace cling diff --git a/lib/Interpreter/ASTTransformer.h b/lib/Interpreter/ASTTransformer.h index bb3c6baa..e472dfb6 100644 --- a/lib/Interpreter/ASTTransformer.h +++ b/lib/Interpreter/ASTTransformer.h @@ -94,7 +94,9 @@ namespace cling { /// Result Transform(clang::Decl* D, Transaction* T) { m_Transaction = T; - return Transform(D); + if (getCompilationOpts().CheckPointerValidity) + return Transform(D); + return Result(D, true); } protected: diff --git a/lib/Interpreter/Interpreter.cpp b/lib/Interpreter/Interpreter.cpp index e087b5ee..b6acda82 100644 --- a/lib/Interpreter/Interpreter.cpp +++ b/lib/Interpreter/Interpreter.cpp @@ -633,6 +633,7 @@ namespace cling { CO.ResultEvaluation = 0; CO.DynamicScoping = isDynamicLookupEnabled(); CO.Debug = isPrintingDebug(); + CO.CheckPointerValidity = 0; return DeclareInternal(input, CO, T); }