Skip to content

Commit

Permalink
Fix detecting scalar accesses in binary operator statements
Browse files Browse the repository at this point in the history
  • Loading branch information
riftEmber committed Nov 25, 2021
1 parent 72eebb5 commit 63b493d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
5 changes: 1 addition & 4 deletions src/ComputationBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,7 @@ void ComputationBuilder::addStmt(clang::Stmt *clangStmt) {
dataAccesses.processWriteToScalarName(varName);
}
} else if (auto *asBinOper = dyn_cast<BinaryOperator>(clangStmt)) {
if (auto *lhsAsArrayAccess =
dyn_cast<ArraySubscriptExpr>(asBinOper->getLHS())) {
dataAccesses.processExprAsWrite(lhsAsArrayAccess);
}
dataAccesses.processExprAsWrite(asBinOper->getLHS());
if (asBinOper->isCompoundAssignmentOp()) {
dataAccesses.processComplexExprAsReads(asBinOper->getLHS());
}
Expand Down
7 changes: 4 additions & 3 deletions src/DataAccessHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,11 @@ std::vector<DataAccess> DataAccessHandler::makeDataAccessesFromExpr(
if (auto *asArraySubscriptExpr =
dyn_cast<ArraySubscriptExpr>(fullExpr)) {
doBuildArrayAccessWork(asArraySubscriptExpr, isRead, accesses);
} else {
std::string varName = Utils::stmtToString(fullExpr);
} else if (auto *asDeclRefExpr = dyn_cast<DeclRefExpr>(fullExpr)) {
std::string varName = Utils::stmtToString(asDeclRefExpr);
if (!ComputationBuilder::positionContext->isIteratorName(varName)) {
accesses.emplace_back(DataAccess(varName, fullExpr->getID(*Context), isRead, false, {}));
accesses.emplace_back(
DataAccess(varName, asDeclRefExpr->getID(*Context), isRead, false, {}));
}
}
return accesses;
Expand Down

0 comments on commit 63b493d

Please sign in to comment.