Skip to content

Commit 083a266

Browse files
committed
[clang][Interp][NFC] Return a valid SourceInfo for Function PCs
We already assert that the given PC is in range and that the function has a body, so the SrcMap should generally never be empty. However, when generating destructors, we create quite a few instructions for which we have no source information, which may cause the previous assertion to fail. Return the end of the source map in this case.
1 parent b7b8d02 commit 083a266

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

clang/lib/AST/Interp/Function.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ SourceInfo Function::getSource(CodePtr PC) const {
4040
unsigned Offset = PC - getCodeBegin();
4141
using Elem = std::pair<unsigned, SourceInfo>;
4242
auto It = llvm::lower_bound(SrcMap, Elem{Offset, {}}, llvm::less_first());
43-
assert(It != SrcMap.end());
43+
if (It == SrcMap.end())
44+
return SrcMap.back().second;
4445
return It->second;
4546
}
4647

0 commit comments

Comments
 (0)