-
Notifications
You must be signed in to change notification settings - Fork 26
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Minimal example of a bug from cppyy #365
Minimal example of a bug from cppyy #365
Conversation
That needs to be fixed at CppInterOp reference: look at comments at compiler-research/cppyy-backend#116
EXPECT_EQ(Cpp::GetTypeAsString(Cpp::GetVariableType(datamembers[0])), | ||
"my_namespace::Container"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The assertion fails here with
"Container" != "my_namespace::Container"
I need the fully qualified type name.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Wouldn't GetQualifiedName
or GetQualifiedCompleteName
help?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well the following diff in GetVariableType
passed the above test for me. I may be wrong due to lack of context.
--- a/lib/Interpreter/CppInterOp.cpp
+++ b/lib/Interpreter/CppInterOp.cpp
@@ -1216,7 +1216,10 @@ namespace Cpp {
auto D = (Decl *) var;
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
- return DD->getType().getAsOpaquePtr();
+ QualType QT = DD->getType();
+
+ // Ensure the type includes the namespace.
+ QT = QT.getCanonicalType();
+ return QT.getAsOpaquePtr();
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the change makes the test pass that's a good sign.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, let me run all the tests and get back to you.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@vgvassilev I ran all the tests now, all tests pass but the typedef int I;
failed in TypeReflectionTest.cpp
, so changing the above diff makes all tests pass. What is your opinion here ?
TCppType_t GetVariableType(TCppScope_t var)
{
auto D = (Decl *) var;
if (auto DD = llvm::dyn_cast_or_null<DeclaratorDecl>(D)) {
QualType QT = DD->getType();
// Check if the type is a typedef type
if (QT->isTypedefNameType()) {
return QT.getAsOpaquePtr();
}
// Else, return the canonical type
QT = QT.getCanonicalType();
return QT.getAsOpaquePtr();
}
return 0;
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@faze-geek, I did not test your changes locally. But if all existing tests and the test from this PR pass, you can open a PR of this branch (create a new branch from this branch). I will take a look at it. We may extend the test with other combinations.
Thanks for looking into this. 😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure ! Will make the changes soon.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
clang-tidy made some suggestions
if (llvm::sys::RunningOnValgrind()) | ||
GTEST_SKIP() << "XFAIL due to Valgrind report"; | ||
|
||
std::string code = R"( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
warning: no header providing "std::string" is directly included [misc-include-cleaner]
unittests/CppInterOp/VariableReflectionTest.cpp:6:
+ #include <string>
@Vipul-Cariappa has this bug been fixed now? |
That needs to be fixed at CppInterOp
reference: look at comments at compiler-research/cppyy-backend#116
I have written a test case that is a minimal example of a failing test at cppyy (suspected).
I am not sure how to fix this. More experienced people here could take a look at it.