Skip to content

Commit f47cc03

Browse files
apply changes from code review
1 parent 971ac0a commit f47cc03

File tree

1 file changed

+8
-17
lines changed

1 file changed

+8
-17
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 8 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3078,27 +3078,18 @@ namespace Cpp {
30783078
}
30793079

30803080
void GetEnums(TCppScope_t scope, std::vector<std::string>& Result) {
3081-
auto *D = (clang::Decl *)scope;
3082-
clang::DeclContext *DC;
3083-
clang::DeclContext::decl_iterator decl;
3084-
3085-
llvm::SmallVector<clang::DeclContext*, 4> DCs;
3081+
auto* D = (clang::Decl*)scope;
30863082

3087-
if (auto *TD = dyn_cast_or_null<TagDecl>(D)) {
3088-
DC = clang::TagDecl::castToDeclContext(TD);
3089-
DCs.push_back(DC);
3090-
} else if (auto *ND = dyn_cast_or_null<NamespaceDecl>(D)) {
3091-
DC = clang::NamespaceDecl::castToDeclContext(ND);
3092-
DC->collectAllContexts(DCs);
3093-
} else if (auto *TUD = dyn_cast_or_null<TranslationUnitDecl>(D)) {
3094-
DC = clang::TranslationUnitDecl::castToDeclContext(TUD);
3095-
DC->collectAllContexts(DCs);
3096-
} else {
3083+
if (!llvm::isa_and_nonnull<clang::DeclContext>(D))
30973084
return;
3098-
}
3085+
3086+
clang::DeclContext* DC = llvm::dyn_cast<clang::DeclContext>(D);
3087+
3088+
llvm::SmallVector<clang::DeclContext*, 4> DCs;
3089+
DC->collectAllContexts(DCs);
30993090

31003091
for (auto* DC : DCs) {
3101-
for (decl = DC->decls_begin(); decl != DC->decls_end(); decl++) {
3092+
for (auto decl = DC->decls_begin(); decl != DC->decls_end(); decl++) {
31023093
if (auto* ND = llvm::dyn_cast_or_null<EnumDecl>(*decl)) {
31033094
Result.push_back(ND->getNameAsString());
31043095
}

0 commit comments

Comments
 (0)