Skip to content

Commit

Permalink
fix: Short-circuit on empty locations for locals (#200)
Browse files Browse the repository at this point in the history
  • Loading branch information
varungandhi-src authored Jun 28, 2023
1 parent b52742e commit 212325a
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -807,6 +807,16 @@ class CFGTraversal final {
// The type should be provided if we have an lvalue.
bool emitLocalOccurrence(const cfg::CFG &cfg, const cfg::BasicBlock *bb, cfg::LocalOccurrence local,
ValueCategory category, core::TypePtr type) {
auto loc = local.loc;
if (!loc.exists() || loc.empty()) {
// Safeguard against incorrect merges from upstream Sorbet, where
// some changes cause empty source locations to propagate down here.
//
// FIXME: Investigate which code patterns trigger this; normally
// locals should carry non-empty locations, but this was
// triggered on some private code.
return false;
}
auto localRef = local.variable;
auto localVar = localRef.data(cfg);
auto symRef = this->aliasMap.try_consume(localRef);
Expand Down Expand Up @@ -848,7 +858,6 @@ class CFGTraversal final {
}
ENFORCE(this->functionLocals.contains(localRef), "should've added local earlier if it was missing");
absl::Status status;
auto loc = local.loc;
auto &gs = this->ctx.state;
auto file = this->ctx.file;
if (symRef.has_value()) {
Expand Down

0 comments on commit 212325a

Please sign in to comment.