From 5c4f91fff188b3d075e7eb16bbad408594f4c3ca Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 26 Jul 2023 18:22:45 +0200 Subject: [PATCH 1/3] rootclingIO: Fix splitting of enum namespaces find_last_of finds "the last character equal to one of characters" in the search string, what we want is rfind to check for two colons. --- io/rootpcm/src/rootclingIO.cxx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/io/rootpcm/src/rootclingIO.cxx b/io/rootpcm/src/rootclingIO.cxx index 9e470646f4089..cd24918a66bb0 100644 --- a/io/rootpcm/src/rootclingIO.cxx +++ b/io/rootpcm/src/rootclingIO.cxx @@ -241,9 +241,9 @@ bool CloseStreamerInfoROOTFile(bool writeEmptyRootPCM) TObjArray enums(gEnumsToStore.size()); for (const auto & enumname : gEnumsToStore) { TEnum *en = nullptr; - const size_t lastSepPos = enumname.find_last_of("::"); + const size_t lastSepPos = enumname.rfind("::"); if (lastSepPos != std::string::npos) { - const std::string nsName = enumname.substr(0, lastSepPos - 1); + const std::string nsName = enumname.substr(0, lastSepPos); TClass *tclassInstance = TClass::GetClass(nsName.c_str()); if (!tclassInstance) { Error("CloseStreamerInfoROOTFile", "Cannot find TClass instance for namespace %s.", nsName.c_str()); @@ -256,7 +256,7 @@ bool CloseStreamerInfoROOTFile(bool writeEmptyRootPCM) Error("CloseStreamerInfoROOTFile", "TClass instance for namespace %s does not have any enum associated. This is an inconsistency.", nsName.c_str()); return false; } - const std::string unqualifiedEnumName = enumname.substr(lastSepPos + 1); + const std::string unqualifiedEnumName = enumname.substr(lastSepPos + 2); en = (TEnum *)enumListPtr->FindObject(unqualifiedEnumName.c_str()); if (en) en->SetTitle(nsName.c_str()); } else { From 9c4e17d9a8f42879489169dae277d9cf20fa03aa Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 26 Jul 2023 18:24:16 +0200 Subject: [PATCH 2/3] SelectionRules: Collapse two if branches --- core/dictgen/src/SelectionRules.cxx | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/dictgen/src/SelectionRules.cxx b/core/dictgen/src/SelectionRules.cxx index dcff2cf5fbbad..018d304e72752 100644 --- a/core/dictgen/src/SelectionRules.cxx +++ b/core/dictgen/src/SelectionRules.cxx @@ -430,12 +430,9 @@ bool SelectionRules::GetDeclName(const clang::Decl* D, std::string& name, std::s return false; // the identifier is NULL for some special methods like constructors, destructors and operators - if (N->getIdentifier()) { + if (N->getIdentifier() || N->isCXXClassMember()) { name = N->getNameAsString(); } - else if (N->isCXXClassMember()) { // for constructors, destructors, operator=, etc. methods - name = N->getNameAsString(); // we use this (unefficient) method to Get the name in that case - } llvm::raw_string_ostream stream(qual_name); N->getNameForDiagnostic(stream,N->getASTContext().getPrintingPolicy(),true); return true; From ffbd964bc7c0e5df24ba594ff9855025ee4f4802 Mon Sep 17 00:00:00 2001 From: Jonas Hahnfeld Date: Wed, 26 Jul 2023 18:24:48 +0200 Subject: [PATCH 3/3] SelectionRules: Only generate qualified name if there is one For example in case of unnamed enums, getNameForDiagnostic might still return a human-readable name that confuses the selection rule patterns. --- core/dictgen/src/SelectionRules.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/dictgen/src/SelectionRules.cxx b/core/dictgen/src/SelectionRules.cxx index 018d304e72752..5880979021408 100644 --- a/core/dictgen/src/SelectionRules.cxx +++ b/core/dictgen/src/SelectionRules.cxx @@ -432,9 +432,9 @@ bool SelectionRules::GetDeclName(const clang::Decl* D, std::string& name, std::s // the identifier is NULL for some special methods like constructors, destructors and operators if (N->getIdentifier() || N->isCXXClassMember()) { name = N->getNameAsString(); + llvm::raw_string_ostream stream(qual_name); + N->getNameForDiagnostic(stream,N->getASTContext().getPrintingPolicy(),true); } - llvm::raw_string_ostream stream(qual_name); - N->getNameForDiagnostic(stream,N->getASTContext().getPrintingPolicy(),true); return true; }