Skip to content

Commit 971ac0a

Browse files
fix: GetEnums now resolves by looking through the chain of DeclContext
1 parent e2c1844 commit 971ac0a

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

lib/Interpreter/CppInterOp.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3082,23 +3082,26 @@ namespace Cpp {
30823082
clang::DeclContext *DC;
30833083
clang::DeclContext::decl_iterator decl;
30843084

3085+
llvm::SmallVector<clang::DeclContext*, 4> DCs;
3086+
30853087
if (auto *TD = dyn_cast_or_null<TagDecl>(D)) {
30863088
DC = clang::TagDecl::castToDeclContext(TD);
3087-
decl = DC->decls_begin();
3088-
decl++;
3089+
DCs.push_back(DC);
30893090
} else if (auto *ND = dyn_cast_or_null<NamespaceDecl>(D)) {
30903091
DC = clang::NamespaceDecl::castToDeclContext(ND);
3091-
decl = DC->decls_begin();
3092+
DC->collectAllContexts(DCs);
30923093
} else if (auto *TUD = dyn_cast_or_null<TranslationUnitDecl>(D)) {
30933094
DC = clang::TranslationUnitDecl::castToDeclContext(TUD);
3094-
decl = DC->decls_begin();
3095+
DC->collectAllContexts(DCs);
30953096
} else {
30963097
return;
30973098
}
30983099

3099-
for (/* decl set above */; decl != DC->decls_end(); decl++) {
3100-
if (auto *ND = llvm::dyn_cast_or_null<EnumDecl>(*decl)) {
3101-
Result.push_back(ND->getNameAsString());
3100+
for (auto* DC : DCs) {
3101+
for (decl = DC->decls_begin(); decl != DC->decls_end(); decl++) {
3102+
if (auto* ND = llvm::dyn_cast_or_null<EnumDecl>(*decl)) {
3103+
Result.push_back(ND->getNameAsString());
3104+
}
31023105
}
31033106
}
31043107
}

0 commit comments

Comments
 (0)