From ab704f917e1e044b721bf49b1e18069968dc766c Mon Sep 17 00:00:00 2001 From: Vincenzo Eduardo Padulano Date: Mon, 19 Jan 2026 09:12:25 +0100 Subject: [PATCH 1/2] [cling] Do not suppress all diagnostics during function lookup This is the first part of https://github.com/root-project/root/pull/12449 Co-authored-by: Josh Bendavid --- .../cling/lib/Interpreter/LookupHelper.cpp | 58 ++++++++++--------- 1 file changed, 32 insertions(+), 26 deletions(-) diff --git a/interpreter/cling/lib/Interpreter/LookupHelper.cpp b/interpreter/cling/lib/Interpreter/LookupHelper.cpp index 66fed6c29fa10..863946a27a898 100644 --- a/interpreter/cling/lib/Interpreter/LookupHelper.cpp +++ b/interpreter/cling/lib/Interpreter/LookupHelper.cpp @@ -13,6 +13,7 @@ #include "DeclUnloader.h" #include "cling/Interpreter/Interpreter.h" #include "cling/Utils/AST.h" +#include "cling/Utils/Diagnostics.h" #include "cling/Utils/ParserStateRAII.h" #include "clang/AST/ASTContext.h" @@ -1112,23 +1113,6 @@ namespace cling { ObjExprClassification = ObjExpr.Classify(Context); } - // - // Tell the diagnostic engine to ignore all diagnostics. - // - bool OldSuppressAllDiagnostics - = S.getDiagnostics().getSuppressAllDiagnostics(); - S.getDiagnostics().setSuppressAllDiagnostics( - diagOnOff == LookupHelper::NoDiagnostics); - - struct ResetDiagSuppression { - bool _Old; - Sema& _S; - ResetDiagSuppression(Sema &S, bool Old): _Old(Old), _S(S) {} - ~ResetDiagSuppression() { - _S.getDiagnostics().setSuppressAllDiagnostics(_Old); - } - } DiagSuppressionRAII(S, OldSuppressAllDiagnostics); - // // Construct the overload candidate set. // @@ -1216,8 +1200,11 @@ namespace cling { S.InstantiateFunctionDefinition(SourceLocation(), TheDecl, true /*recursive instantiation*/); } - if (TheDecl->isInvalidDecl()) { - // if the decl is invalid try to clean up + if (TheDecl->isInvalidDecl() && + !S.getDiagnostics().hasErrorOccurred()) { + // if the decl is invalid try to clean up (unless an error occurred, + // in which case this will be handled instead by the failed + // transaction) UnloadDecl(&S, const_cast(TheDecl)); return 0; } @@ -1538,11 +1525,27 @@ namespace cling { // Lookup failed. return 0; } - return functionSelector(foundDC,objectIsConst,GivenArgs, - Result, - FuncNameInfo, - FuncTemplateArgs, - Context, P, S, diagOnOff); + + // Suppress printing of diagnostics (we cannot simply ignore them + // since then it would not be possible to check for errors programmatically + // either) + + utils::DiagnosticsStore ds(S.getDiagnostics(), false, /*Own*/ + diagOnOff == + LookupHelper::WithDiagnostics /*Report*/); + + auto res = functionSelector(foundDC, objectIsConst, GivenArgs, Result, + FuncNameInfo, FuncTemplateArgs, Context, P, S, + diagOnOff); + + if (S.getDiagnostics().hasErrorOccurred()) { + auto* transaction = + const_cast(Interp->getCurrentTransaction()); + transaction->setIssuedDiags(Transaction::kErrors); + return 0; + } + + return res; } template @@ -1824,8 +1827,11 @@ namespace cling { if (!fdecl->isDefined()) S.InstantiateFunctionDefinition(loc, fdecl, true /*recursive instantiation*/); - if (fdecl->isInvalidDecl()) { - // if the decl is invalid try to clean up + if (fdecl->isInvalidDecl() && + !S.getDiagnostics().hasErrorOccurred()) { + // if the decl is invalid try to clean up (unless an error occurred, + // in which case this will be handled instead by the failed + // transaction) UnloadDecl(&S, fdecl); return 0; } From 25e1e2f45bc41e6223368207f7e02b3d8eb229b1 Mon Sep 17 00:00:00 2001 From: Vincenzo Eduardo Padulano Date: Mon, 19 Jan 2026 10:49:34 +0100 Subject: [PATCH 2/2] [rf] Allow zero column case for RooAbsDataHelper Use std::array to better handle the case of `sizeof(ColumnTypes)... == 0`. Previously, errors such as this one could be seen: ``` /Users/vpadulan/Programs/rootproject/rootbuild/bendavid-template-1-relwithdebinfo/include/RooAbsDataHelper.h:146:25: error: cannot deduce actual type for variable '__range2' with type 'auto &&' from initializer list for (auto &&val : {static_cast(values)...}) { ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /Users/vpadulan/Programs/rootproject/rootbuild/bendavid-template-1-relwithdebinfo/include/ROOT/RDF/RAction.hxx:117:85: note: in instantiation of function template specialization 'RooAbsDataHelper::Exec<>' requested here ROOT::Internal::RDF::CallGuaranteedOrder{[&](auto &&...args) { return fHelper.Exec(slot, args...); }, ^ [...] /Users/vpadulan/Programs/rootproject/rootbuild/bendavid-template-1-relwithdebinfo/include/ROOT/RDF/RVariedAction.hxx:160:24: error: no matching member function for call to 'Exec' fHelpers[varIdx].Exec(slot, GetValueChecked(slot, varIdx, ReaderIdxs, entry)...); ~~~~~~~~~~~~~~~~~^~~~ [...] /Users/vpadulan/Programs/rootproject/rootbuild/bendavid-template-1-relwithdebinfo/include/ROOT/RDF/RInterface.hxx:3579:14: note: in instantiation of function template specialization 'ROOT::RDF::RInterfaceBase::CreateAction, 0>' requested here return CreateAction(/*columns=*/{}, resPtr, hPtr, fProxiedPtr, 0u); ^ ``` Hinting at the fact that a `CreateAction` specialization would try to instantiate the helper to `Book` without columns. --- roofit/roofitcore/inc/RooAbsDataHelper.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/roofit/roofitcore/inc/RooAbsDataHelper.h b/roofit/roofitcore/inc/RooAbsDataHelper.h index 5347b3b862fb0..6b4bdeb51b686 100644 --- a/roofit/roofitcore/inc/RooAbsDataHelper.h +++ b/roofit/roofitcore/inc/RooAbsDataHelper.h @@ -143,9 +143,8 @@ class RooAbsDataHelper : public RooFit::Detail::RooAbsDataFiller, void Exec(unsigned int slot, ColumnTypes... values) { std::vector &vector = _events[slot]; - for (auto &&val : {static_cast(values)...}) { - vector.push_back(val); - } + std::array valuesArr{static_cast(values)...}; + vector.insert(vector.end(), valuesArr.begin(), valuesArr.end()); ExecImpl(sizeof...(values), vector); }