Skip to content

Commit af029fd

Browse files
authored
Merge pull request #1433 from swiftwasm/release/5.3
[pull] swiftwasm-release/5.3 from release/5.3
2 parents 3687d84 + 83b16cf commit af029fd

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

lib/IDE/CompletionInstance.cpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ template <typename Range> Decl *getElementAt(const Range &Decls, unsigned N) {
8989
/// config block, this function returns \c false.
9090
static DeclContext *getEquivalentDeclContextFromSourceFile(DeclContext *DC,
9191
SourceFile *SF) {
92+
PrettyStackTraceDeclContext trace("getting equivalent decl context for", DC);
9293
auto *newDC = DC;
9394
// NOTE: Shortcut for DC->getParentSourceFile() == SF case is not needed
9495
// because they should be always different.
@@ -115,13 +116,17 @@ static DeclContext *getEquivalentDeclContextFromSourceFile(DeclContext *DC,
115116
D = storage;
116117
}
117118

118-
if (auto parentSF = dyn_cast<SourceFile>(parentDC))
119+
if (auto parentSF = dyn_cast<SourceFile>(parentDC)) {
119120
N = findIndexInRange(D, parentSF->getTopLevelDecls());
120-
else if (auto parentIDC =
121-
dyn_cast<IterableDeclContext>(parentDC->getAsDecl()))
121+
} else if (auto parentIDC = dyn_cast_or_null<IterableDeclContext>(
122+
parentDC->getAsDecl())) {
122123
N = findIndexInRange(D, parentIDC->getMembers());
123-
else
124+
} else {
125+
#ifndef NDEBUG
124126
llvm_unreachable("invalid DC kind for finding equivalent DC (indexpath)");
127+
#endif
128+
return nullptr;
129+
}
125130

126131
// Not found in the decl context tree.
127132
// FIXME: Probably DC is in an inactive #if block.

0 commit comments

Comments
 (0)