-
Notifications
You must be signed in to change notification settings - Fork 36
Add GetEnumConstantDatamembers function
#499
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 |
|---|---|---|
|
|
@@ -36,6 +36,8 @@ | |
| #include "llvm/Support/Debug.h" | ||
| #include "llvm/Support/raw_os_ostream.h" | ||
|
|
||
| #include <algorithm> | ||
| #include <iterator> | ||
| #include <map> | ||
| #include <set> | ||
| #include <sstream> | ||
|
|
@@ -1223,6 +1225,23 @@ namespace Cpp { | |
| GetClassDecls<VarDecl>(scope, datamembers); | ||
| } | ||
|
|
||
| void GetEnumConstantDatamembers(TCppScope_t scope, | ||
| std::vector<TCppScope_t>& datamembers, | ||
| bool include_enum_class) { | ||
| std::vector<TCppScope_t> EDs; | ||
| GetClassDecls<EnumDecl>(scope, EDs); | ||
| for (TCppScope_t i : EDs) { | ||
| auto* ED = static_cast<EnumDecl*>(i); | ||
|
|
||
| bool is_class_tagged = ED->isScopedUsingClassTag(); | ||
| if (is_class_tagged && !include_enum_class) | ||
| continue; | ||
|
|
||
| std::copy(ED->enumerator_begin(), ED->enumerator_end(), | ||
| std::back_inserter(datamembers)); | ||
|
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 "std::back_inserter" is directly included [misc-include-cleaner] lib/Interpreter/CppInterOp.cpp:26: - #if CLANG_VERSION_MAJOR >= 19
+ #include <iterator>
+ #if CLANG_VERSION_MAJOR >= 19
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. These are good suggestions...
Collaborator
Author
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. resolved. |
||
| } | ||
| } | ||
|
|
||
| TCppScope_t LookupDatamember(const std::string& name, TCppScope_t parent) { | ||
| clang::DeclContext *Within = 0; | ||
| if (parent) { | ||
|
|
@@ -1256,6 +1275,9 @@ namespace Cpp { | |
| return QT.getAsOpaquePtr(); | ||
| } | ||
|
|
||
| if (auto* ECD = llvm::dyn_cast_or_null<EnumConstantDecl>(D)) | ||
| return ECD->getType().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.
warning: no header providing "std::copy" is directly included [misc-include-cleaner]
lib/Interpreter/CppInterOp.cpp:26: