From 829e1fb612b7517657d308ededc59b436a38c990 Mon Sep 17 00:00:00 2001 From: Varun Gandhi Date: Wed, 29 Jun 2022 22:48:24 +0200 Subject: [PATCH] test: Mark write accesses separately. --- scip_indexer/SCIPIndexer.cc | 4 ++++ test/scip/testdata/syntax.rb.snapshot | 4 ++-- test/scip_test_runner.cc | 8 +++++++- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/scip_indexer/SCIPIndexer.cc b/scip_indexer/SCIPIndexer.cc index f02bc7ca8b..e6da384bf3 100644 --- a/scip_indexer/SCIPIndexer.cc +++ b/scip_indexer/SCIPIndexer.cc @@ -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 diff --git a/test/scip/testdata/syntax.rb.snapshot b/test/scip/testdata/syntax.rb.snapshot index 5facedb36f..e404953c91 100644 --- a/test/scip/testdata/syntax.rb.snapshot +++ b/test/scip/testdata/syntax.rb.snapshot @@ -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 diff --git a/test/scip_test_runner.cc b/test/scip_test_runner.cc index 7a49786fcc..63c9614651 100644 --- a/test/scip_test_runner.cc +++ b/test/scip_test_runner.cc @@ -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++;