-
Notifications
You must be signed in to change notification settings - Fork 62
Return enum constant values as their int64_t bit pattern #1096
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -237,6 +237,10 @@ TYPED_TEST(CPPINTEROP_TEST_MODE, EnumReflection_GetEnumConstantValue) { | |
| MinusTen = -10, | ||
| MinusNine | ||
| }; | ||
| enum Huge : unsigned long long { | ||
| Big = ((unsigned long long)1) << 63, | ||
| Max = 0xFFFFFFFFFFFFFFFFULL | ||
| }; | ||
| int a = 10; | ||
| )"; | ||
|
|
||
|
|
@@ -250,7 +254,12 @@ TYPED_TEST(CPPINTEROP_TEST_MODE, EnumReflection_GetEnumConstantValue) { | |
| EXPECT_EQ(Cpp::GetEnumConstantValue(EnumConstants[4]), 54); | ||
| EXPECT_EQ(Cpp::GetEnumConstantValue(EnumConstants[5]), -10); | ||
| EXPECT_EQ(Cpp::GetEnumConstantValue(EnumConstants[6]), -9); | ||
| EXPECT_EQ(Cpp::GetEnumConstantValue(Decls[1]), 0); // Checking value of non enum constant | ||
| EXPECT_EQ(Cpp::GetEnumConstantValue(Decls[2]), 0); // Checking value of non enum constant | ||
|
|
||
| auto HugeConstants = Cpp::GetEnumConstants(Decls[1]); | ||
| EXPECT_EQ(Cpp::GetEnumConstantValue(HugeConstants[0]), | ||
| (int64_t)((uint64_t)1 << 63)); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "int64_t" is directly included [misc-include-cleaner] unittests/CppInterOp/EnumReflectionTest.cpp:7: + #include <cstdint>
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. warning: no header providing "uint64_t" is directly included [misc-include-cleaner] (int64_t)((uint64_t)1 << 63));
^ |
||
| EXPECT_EQ(Cpp::GetEnumConstantValue(HugeConstants[1]), (int64_t)-1); | ||
| } | ||
|
|
||
| TYPED_TEST(CPPINTEROP_TEST_MODE, EnumReflection_GetEnums) { | ||
|
|
||
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.
Is that a platform-independent typedef?
Uh oh!
There was an error while loading. Please reload this page.
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.
Yes, int64_t is available on all platforms from
<cstdint>. We already have API's using typedefs from cstdint: GetBaseClassOffset returnsint64_t, and InsertOrReplaceJitSymbol acceptsuint64_tparam, which matchesAPSInt::getExtValue()