-
Notifications
You must be signed in to change notification settings - Fork 36
resolve static constexpr class attribute #351
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
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #351 +/- ##
==========================================
+ Coverage 74.45% 74.57% +0.12%
==========================================
Files 8 8
Lines 3206 3214 +8
==========================================
+ Hits 2387 2397 +10
+ Misses 819 817 -2
... and 1 file with indirect coverage changes
|
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
| (VD->isConstexpr() || VD->getType().isConstQualified())) { | ||
| if (const APValue* val = VD->evaluateValue()) { | ||
| if (VD->getType()->isIntegralType(C)) { | ||
| return (intptr_t)val->getInt().getRawData(); |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
return (intptr_t)val->getInt().getRawData();
^24c82c5 to
e4cec60
Compare
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
64b70fd to
a99f1a0
Compare
|
Hi @vgvassilev, please look at the new changes. I am now using I see some failing tests, that are due to the OSX dependency thing, rerunning them should fix it. I do not have the necessary permissions to rerun them. |
Can you accept the invite and retry? |
lib/Interpreter/CppInterOp.cpp
Outdated
| llvm::logAllUnhandledErrors(VDAorErr.takeError(), llvm::errs(), | ||
| "Failed to GetVariableOffset:"); | ||
|
|
||
| if (VD->isConstexpr() && !VD->hasInit()) |
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.
Shouldn’t here the check be if the VD is a template, implicitly instantiated with no init?
Looks like we don’t have test coverage for this case though…
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.
Shouldn’t here the check be if the VD is a template, implicitly instantiated with no init?
!VD->hasInit() satisfies the "no init" part. Checking for template may not be required.
Looks like we don’t have test coverage for this case though…
Yes. The test case does not cover it. Running the cppyy test suit, it gets covered there. But I am not able to reproduce that here.
a99f1a0 to
e034eab
Compare
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
|
Looks like cppyy-cling backend fails. |
lib/Interpreter/CppInterOp.cpp
Outdated
| llvm::logAllUnhandledErrors(VDAorErr.takeError(), llvm::errs(), | ||
| "Failed to GetVariableOffset:"); | ||
| return 0; | ||
| if (VDAorErr) |
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.
This inversion seems wrong. Later, unconditionally we call logAllUnhandledErrors.
lib/Interpreter/CppInterOp.cpp
Outdated
| getSema().InstantiateVariableDefinition(SourceLocation(), VD); | ||
| if (VD->hasInit() && | ||
| (VD->isConstexpr() || VD->getType().isConstQualified())) { | ||
| if (const APValue* val = VD->evaluateValue()) { |
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.
These operations are cheaper and probably should go before the heavy getSymbolAddress?
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.
I did the same with 24c82c5 commit.
This change happened to resolve things sooner and getSymbolAddress was never executed. Please look at the code coverage results of the same commit.
Sorry for the force pushes
e034eab to
97a9b6c
Compare
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
| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| intptr_t offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(3, *(int*)offset); |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
EXPECT_EQ(3, *(int*)offset);
^| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| intptr_t offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(3, *(int*)offset); |
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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
EXPECT_EQ(3, *(int*)offset);
^| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(5, *(int*)offset); |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
EXPECT_EQ(5, *(int*)offset);
^| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(5, *(int*)offset); |
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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
EXPECT_EQ(5, *(int*)offset);
^| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(2, *(int*)offset); |
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: do not use C-style cast to convert between unrelated types [cppcoreguidelines-pro-type-cstyle-cast]
EXPECT_EQ(2, *(int*)offset);
^| EXPECT_EQ(datamembers.size(), 1); | ||
|
|
||
| offset = Cpp::GetVariableOffset(datamembers[0]); | ||
| EXPECT_EQ(2, *(int*)offset); |
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: integer to pointer cast pessimizes optimization opportunities [performance-no-int-to-ptr]
EXPECT_EQ(2, *(int*)offset);
^by explicitly initializing constexpr with `Sema::InstantiateVariableDefinition`
97a9b6c to
94a59b8
Compare
fix for the osx dependency issue
affdf00 to
35346a7
Compare
95bde80 to
1d4a678
Compare
vgvassilev
left a comment
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.
LGTM!
No description provided.