diff --git a/core/cont/inc/TRefArray.h b/core/cont/inc/TRefArray.h index 253abd12a2bfe..5c5a42ed051e5 100644 --- a/core/cont/inc/TRefArray.h +++ b/core/cont/inc/TRefArray.h @@ -161,33 +161,4 @@ inline Bool_t TRefArray::BoundsOk(const char *where, Int_t at) const : kTRUE; } -inline TObject *TRefArray::operator[](Int_t at) const -{ - int j = at-fLowerBound; - if (j >= 0 && j < fSize) { - if (!fPID) return nullptr; - if (!TProcessID::IsValid(fPID)) return nullptr; - TObject *obj = fPID->GetObjectWithID(fUIDs[j]); - if (!obj) obj = GetFromTable(j); - return obj; - } - BoundsOk("At", at); - return nullptr; -} - -inline TObject *TRefArray::At(Int_t at) const -{ - // Return the object at position i. Returns 0 if i is out of bounds. - int j = at-fLowerBound; - if (j >= 0 && j < fSize) { - if (!fPID) return nullptr; - if (!TProcessID::IsValid(fPID)) return nullptr; - TObject *obj = fPID->GetObjectWithID(fUIDs[j]); - if (!obj) obj = GetFromTable(j); - return obj; - } - BoundsOk("At", at); - return nullptr; -} - #endif diff --git a/core/cont/src/TRefArray.cxx b/core/cont/src/TRefArray.cxx index b154879aa9145..bdf8434a254e8 100644 --- a/core/cont/src/TRefArray.cxx +++ b/core/cont/src/TRefArray.cxx @@ -966,3 +966,31 @@ TObject *TRefArrayIter::operator*() const return (((fCurCursor >= 0) && (fCurCursor < fArray->Capacity())) ? fArray->At(fCurCursor) : nullptr); } + +TObject *TRefArray::operator[](Int_t at) const +{ + return At(at); +} + +TObject *TRefArray::At(Int_t at) const +{ + // Return the object at position i. Returns 0 if i is out of bounds. + int j = at - fLowerBound; + if (j >= 0 && j < fSize) { + + auto table = TRefTable::GetRefTable(); + table->Notify(); + + if (!fPID || !TProcessID::IsValid(fPID)) return nullptr; + + auto obj = fPID->GetObjectWithID(fUIDs[j]); + if (obj) return obj; + + if ((obj = GetFromTable(j))) return obj; + + return nullptr; + + } + BoundsOk("At", at); + return nullptr; +} \ No newline at end of file diff --git a/core/metacling/test/TClingTests.cxx b/core/metacling/test/TClingTests.cxx index 432de8616c5de..516971f0765da 100644 --- a/core/metacling/test/TClingTests.cxx +++ b/core/metacling/test/TClingTests.cxx @@ -274,3 +274,62 @@ TEST_F(TClingTests, ROOT10499) { EXPECT_EQ((void*)&errno, (void*)gInterpreter->Calc("&errno")); #endif } + +// ROOT-6913 +TEST_F(TClingTests, ClassInfoProperty) +{ + gInterpreter->Declare(R"cpp( +class ClassHasExplicitCtor{ + public: + ClassHasExplicitCtor(){}; +}; + +class ClassHasExplicitDtor{ + public: + ~ClassHasExplicitDtor(){}; +}; + +class ClassHasImplicitCtor { + ClassHasExplicitCtor c; +}; + +class ClassHasImplicitDtor{ + ClassHasExplicitDtor c; +}; + +class ClassHasDefaultCtor{ + ClassHasDefaultCtor(){}; +}; + +class ClassIsAbstract{ + virtual void PureVirtual() = 0; +}; + +class ClassHasVirtual{ + virtual void Virtual() {}; +}; + +class ClassHasAssignOpr{ + ClassHasAssignOpr& operator=(const ClassHasAssignOpr&); +}; + +// according to the C++ standard, being a POD implies being an aggregate +struct ClassIsAggregate { + int x; + double y; +}; + )cpp"); + + const std::vector> classNPPairs{ + {"ClassHasImplicitCtor", kClassHasImplicitCtor}, {"ClassHasExplicitCtor", kClassHasExplicitCtor}, + {"ClassHasExplicitDtor", kClassHasExplicitDtor}, {"ClassHasImplicitDtor", kClassHasImplicitDtor}, + {"ClassHasDefaultCtor", kClassHasDefaultCtor}, {"ClassHasDefaultCtor", kClassIsValid}, + {"ClassIsAbstract", kClassIsAbstract}, {"ClassHasVirtual", kClassHasVirtual}, + {"ClassHasAssignOpr", kClassHasAssignOpr}, {"ClassIsAggregate", kClassIsAggregate}}; + + for (auto &[clName, clPropRef] : classNPPairs) { + auto cl = TClass::GetClass(clName.c_str()); + const auto prop = gInterpreter->ClassInfo_ClassProperty(cl->GetClassInfo()); + EXPECT_TRUE(prop & clPropRef) << "Error checking property for class " << clName; + } +}