Skip to content
Open
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
2 changes: 1 addition & 1 deletion bindings/pyroot/pythonizations/test/numbadeclare.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def test_cling(self):
@ROOT.Numba.Declare(["float"], "float")
def fn12(x):
return 2.0 * x
ROOT.gInterpreter.ProcessLine("y12 = Numba::fn12(42.0);")
ROOT.gInterpreter.ProcessLine("auto y12 = Numba::fn12(42.0);")
self.assertEqual(fn12(42.0), ROOT.y12)

# Test RDataFrame integration
Expand Down
93 changes: 0 additions & 93 deletions core/metacling/src/TClingCallbacks.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -395,18 +395,6 @@ bool TClingCallbacks::LookupObject(LookupResult &R, Scope *S) {
if (tryFindROOTSpecialInternal(R, S))
return true;

// For backward-compatibility with CINT we must support stmts like:
// x = 4; y = new MyClass();
// I.e we should "inject" a C++11 auto keyword in front of "x" and "y"
// This has to have higher precedence than the dynamic scopes. It is claimed
// that if one assigns to a name and the lookup of that name fails if *must*
// auto keyword must be injected and the stmt evaluation must not be delayed
// until runtime.
// For now supported only at the prompt.
if (tryInjectImplicitAutoKeyword(R, S)) {
return true;
}

if (fIsAutoLoadingRecursively)
return false;

Expand Down Expand Up @@ -926,87 +914,6 @@ bool TClingCallbacks::shouldResolveAtRuntime(LookupResult& R, Scope* S) {
return false;
}

bool TClingCallbacks::tryInjectImplicitAutoKeyword(LookupResult &R, Scope *S) {
if (!fROOTSpecialNamespace) {
// init error or rootcling
return false;
}

// Should be disabled with the dynamic scopes.
if (m_IsRuntime)
return false;

if (R.isForRedeclaration())
return false;

if (R.getLookupKind() != Sema::LookupOrdinaryName)
return false;

if (!isa<FunctionDecl>(R.getSema().CurContext))
return false;

{
// ROOT-8538: only top-most (function-level) scope is supported.
DeclContext* ScopeDC = S->getEntity();
if (!ScopeDC || !llvm::isa<FunctionDecl>(ScopeDC))
return false;

// Make sure that the failed lookup comes the prompt. Currently, we
// support only the prompt.
Scope* FnScope = S->getFnParent();
if (!FnScope)
return false;
auto FD = dyn_cast_or_null<FunctionDecl>(FnScope->getEntity());
if (!FD || !utils::Analyze::IsWrapper(FD))
return false;
}

Sema& SemaRef = R.getSema();
ASTContext& C = SemaRef.getASTContext();
DeclContext* DC = SemaRef.CurContext;
assert(DC && "Must not be null.");


Preprocessor& PP = R.getSema().getPreprocessor();
//Preprocessor::CleanupAndRestoreCacheRAII cleanupRAII(PP);
//PP.EnableBacktrackAtThisPos();
if (PP.LookAhead(0).isNot(tok::equal)) {
//PP.Backtrack();
return false;
}
//PP.CommitBacktrackedTokens();
//cleanupRAII.pop();
DeclarationName Name = R.getLookupName();
IdentifierInfo* II = Name.getAsIdentifierInfo();
SourceLocation Loc = R.getNameLoc();
VarDecl* Result = VarDecl::Create(C, DC, Loc, Loc, II,
C.getAutoType(QualType(),
clang::AutoTypeKeyword::Auto,
/*IsDependent*/false),
/*TypeSourceInfo*/nullptr, SC_None);

if (!Result) {
ROOT::TMetaUtils::Error("TClingCallbacks::tryInjectImplicitAutoKeyword",
"Cannot create VarDecl");
return false;
}

// Annotate the decl to give a hint in cling.
// FIXME: We should move this in cling, when we implement turning it on
// and off.
Result->addAttr(AnnotateAttr::CreateImplicit(C, "__Auto", nullptr, 0));

R.addDecl(Result);

// Raise a warning when trying to use implicit auto injection feature.
SemaRef.getDiagnostics().setSeverity(diag::warn_deprecated_message, diag::Severity::Warning, SourceLocation());
SemaRef.Diag(Loc, diag::warn_deprecated_message)
<< "declaration without the 'auto' keyword" << DC << Loc << FixItHint::CreateInsertion(Loc, "auto ");

// Say that we can handle the situation. Clang should try to recover
return true;
}

void TClingCallbacks::Initialize() {
// Replay existing decls from the AST.
if (fFirstRun) {
Expand Down
1 change: 0 additions & 1 deletion core/metacling/src/TClingCallbacks.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,5 @@ class TClingCallbacks : public cling::InterpreterCallbacks {
bool tryFindROOTSpecialInternal(clang::LookupResult &R, clang::Scope *S);
bool tryResolveAtRuntimeInternal(clang::LookupResult &R, clang::Scope *S);
bool shouldResolveAtRuntime(clang::LookupResult &R, clang::Scope *S);
bool tryInjectImplicitAutoKeyword(clang::LookupResult &R, clang::Scope *S);
bool findInGlobalModuleIndex(clang::DeclarationName Name, bool loadFirstMatchOnly = true);
};
31 changes: 0 additions & 31 deletions core/metacling/test/TClingTests.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -88,24 +88,6 @@ TEST_F(TClingTests, GetEnumWithSameVariableName)
EXPECT_TRUE(en != nullptr);
}

TEST_F(TClingTests, SuccessfulAutoInjection)
{
gInterpreter->ProcessLine("int SuccessfulAutoInjectionTest(int j) { return 0; }");
gInterpreter->ProcessLine("success = SuccessfulAutoInjectionTest(3)");

auto success = gInterpreter->GetDataMember(nullptr, "success");
EXPECT_TRUE(success != nullptr);
}

TEST_F(TClingTests, FailedAutoInjection)
{
gInterpreter->ProcessLine("int FailedAutoInjectionTest(int j) { return 0; }");
gInterpreter->ProcessLine("failed = FailedAutoInjectionTest(3, 6)");

auto failed = gInterpreter->GetDataMember(nullptr, "failed");
EXPECT_TRUE(failed == nullptr);
}

// Check if we can get the source code of function definitions.
TEST_F(TClingTests, MakeInterpreterValue)
{
Expand Down Expand Up @@ -239,19 +221,6 @@ TEST_F(TClingTests, GetSharedLibDeps)
}
#endif

// Check that a warning message is generated when using auto-injection.
TEST_F(TClingTests, WarningAutoInjection)
{
ROOT::TestSupport::CheckDiagsRAII diags;
diags.requiredDiag(kWarning, "cling", "declaration without the 'auto' keyword is deprecated",
/*matchFullMessage=*/false);

gInterpreter->ProcessLine("/* no auto */ t = new int;");

auto t = gInterpreter->GetDataMember(nullptr, "t");
EXPECT_TRUE(t != nullptr);
}

// Check the interface which interacts with the cling::LookupHelper.
TEST_F(TClingTests, ClingLookupHelper) {
// Exception spec evaluation.
Expand Down
125 changes: 0 additions & 125 deletions interpreter/cling/lib/Interpreter/AutoSynthesizer.cpp

This file was deleted.

43 changes: 0 additions & 43 deletions interpreter/cling/lib/Interpreter/AutoSynthesizer.h

This file was deleted.

1 change: 0 additions & 1 deletion interpreter/cling/lib/Interpreter/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,6 @@ endif()


add_cling_library(clingInterpreter OBJECT
AutoSynthesizer.cpp
AutoloadCallback.cpp
ASTTransformer.cpp
BackendPasses.cpp
Expand Down
2 changes: 0 additions & 2 deletions interpreter/cling/lib/Interpreter/IncrementalParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
#include "IncrementalParser.h"

#include "ASTTransformer.h"
#include "AutoSynthesizer.h"
#include "CheckEmptyTransactionTransformer.h"
#include "ClingPragmas.h"
#include "DeclCollector.h"
Expand Down Expand Up @@ -1023,7 +1022,6 @@ namespace cling {
// Register the AST Transformers
typedef std::unique_ptr<ASTTransformer> ASTTPtr_t;
std::vector<ASTTPtr_t> ASTTransformers;
ASTTransformers.emplace_back(new AutoSynthesizer(TheSema));
ASTTransformers.emplace_back(new EvaluateTSynthesizer(TheSema));
if (hasCodeGenerator() && !m_Interpreter->getOptions().NoRuntime) {
// Don't protect against crashes if we cannot run anything.
Expand Down
Loading
Loading