Skip to content

test: Mark write accesses separately. #6

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions scip_indexer/SCIPIndexer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ class CFGTraversal final {
this->emitLocalOccurrence(cfg, bb, send->recv.occurrence(), ValueCategory::RValue);
}

// TODO:(varun) For arrays, hashes etc., try to identify if the function
// matches a known operator (e.g. []=), and emit an appropriate 'WriteAccess'
// symbol role for it.

// Emit reference for the method being called
if (send->fun.exists() && !isTemporary(gs, core::LocalVariable(send->fun, 1))) {
// HACK(varun): We should probably add a helper function to check
Expand Down
4 changes: 2 additions & 2 deletions test/scip/testdata/syntax.rb.snapshot
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@
if x == 2
# ^ reference local 1~#2634721084
z += y
# ^ reference local 3~#2634721084
# ^ reference (write) local 3~#2634721084
# ^ reference local 3~#2634721084
# ^ reference local 2~#2634721084
else
z += x
# ^ reference local 3~#2634721084
# ^ reference local 3~#2634721084
# ^ reference (write) local 3~#2634721084
# ^ reference local 1~#2634721084
end
z
Expand Down
8 changes: 7 additions & 1 deletion test/scip_test_runner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -188,8 +188,14 @@ void formatSnapshot(const scip::Document &document, std::ostream &out) {
}
bool isDefinition = ((unsigned(occ.symbol_roles()) & unsigned(scip::SymbolRole::Definition)) > 0);

string symbolRole = "";
if (!isDefinition && (occ.symbol_roles() & scip::SymbolRole::WriteAccess)) {
symbolRole = (occ.symbol_roles() & scip::SymbolRole::ReadAccess) ? "(read+write) " : "(write) ";
}

out << '#' << string(range.start.column - 1, ' ') << string(range.end.column - range.start.column, '^')
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << formatSymbol(occ.symbol());
<< ' ' << string(isDefinition ? "definition" : "reference") << ' ' << symbolRole
<< formatSymbol(occ.symbol());
if (!(isDefinition && symbolTable.contains(occ.symbol()))) {
out << '\n';
occ_i++;
Expand Down