This revision was automatically updated to reflect the committed changes. Closed by commit rG7b00eeb53de0: [lldb] Fix another crash in covariant type handling (authored by labath).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D76840/new/ https://reviews.llvm.org/D76840 Files: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py lldb/test/API/lang/cpp/covariant-return-types/main.cpp Index: lldb/test/API/lang/cpp/covariant-return-types/main.cpp =================================================================== --- lldb/test/API/lang/cpp/covariant-return-types/main.cpp +++ lldb/test/API/lang/cpp/covariant-return-types/main.cpp @@ -28,6 +28,23 @@ OtherDerived& getOtherRef() override { return other_derived; } }; +// A regression test for a class with at least two members containing a +// covariant function, which is referenced through another covariant function. +struct BaseWithMembers { + int a = 42; + int b = 47; + virtual BaseWithMembers *get() { return this; } +}; +struct DerivedWithMembers: BaseWithMembers { + DerivedWithMembers *get() override { return this; } +}; +struct ReferencingBase { + virtual BaseWithMembers *getOther() { return new BaseWithMembers(); } +}; +struct ReferencingDerived: ReferencingBase { + DerivedWithMembers *getOther() { return new DerivedWithMembers(); } +}; + int main() { Derived derived; Base base; @@ -36,5 +53,7 @@ (void)base_ptr_to_derived->getRef(); (void)base_ptr_to_derived->getOtherPtr(); (void)base_ptr_to_derived->getOtherRef(); + + ReferencingDerived referencing_derived; return 0; // break here } Index: lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py =================================================================== --- lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py +++ lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py @@ -38,3 +38,5 @@ self.expect_expr("derived.getOtherRef().value()", result_summary='"derived"') self.expect_expr("base_ptr_to_derived->getOtherRef().value()", result_summary='"derived"') self.expect_expr("base.getOtherRef().value()", result_summary='"base"') + + self.expect_expr("referencing_derived.getOther()->get()->a", result_value='42') Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -997,6 +997,8 @@ clang::RecordDecl *rd = return_type->getPointeeType()->getAsRecordDecl(); if (!rd) return; + if (rd->getDefinition()) + return; importer.CompleteTagDecl(rd); }
Index: lldb/test/API/lang/cpp/covariant-return-types/main.cpp =================================================================== --- lldb/test/API/lang/cpp/covariant-return-types/main.cpp +++ lldb/test/API/lang/cpp/covariant-return-types/main.cpp @@ -28,6 +28,23 @@ OtherDerived& getOtherRef() override { return other_derived; } }; +// A regression test for a class with at least two members containing a +// covariant function, which is referenced through another covariant function. +struct BaseWithMembers { + int a = 42; + int b = 47; + virtual BaseWithMembers *get() { return this; } +}; +struct DerivedWithMembers: BaseWithMembers { + DerivedWithMembers *get() override { return this; } +}; +struct ReferencingBase { + virtual BaseWithMembers *getOther() { return new BaseWithMembers(); } +}; +struct ReferencingDerived: ReferencingBase { + DerivedWithMembers *getOther() { return new DerivedWithMembers(); } +}; + int main() { Derived derived; Base base; @@ -36,5 +53,7 @@ (void)base_ptr_to_derived->getRef(); (void)base_ptr_to_derived->getOtherPtr(); (void)base_ptr_to_derived->getOtherRef(); + + ReferencingDerived referencing_derived; return 0; // break here } Index: lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py =================================================================== --- lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py +++ lldb/test/API/lang/cpp/covariant-return-types/TestCovariantReturnTypes.py @@ -38,3 +38,5 @@ self.expect_expr("derived.getOtherRef().value()", result_summary='"derived"') self.expect_expr("base_ptr_to_derived->getOtherRef().value()", result_summary='"derived"') self.expect_expr("base.getOtherRef().value()", result_summary='"base"') + + self.expect_expr("referencing_derived.getOther()->get()->a", result_value='42') Index: lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp =================================================================== --- lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp +++ lldb/source/Plugins/ExpressionParser/Clang/ClangASTImporter.cpp @@ -997,6 +997,8 @@ clang::RecordDecl *rd = return_type->getPointeeType()->getAsRecordDecl(); if (!rd) return; + if (rd->getDefinition()) + return; importer.CompleteTagDecl(rd); }
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits