Skip to content

Commit

Permalink
#1: add checks for reapply to transformed code
Browse files Browse the repository at this point in the history
  • Loading branch information
lifflander committed Feb 16, 2021
1 parent ec2dd67 commit 9fef284
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions src/transform.cc
Original file line number Diff line number Diff line change
Expand Up @@ -276,6 +276,38 @@ struct ParallelForRewriter : MatchFinder::MatchCallback {
{ }

virtual void run(const MatchFinder::MatchResult &Result) {

CallExpr const *ce_outer = nullptr;
ce_outer = Result.Nodes.getNodeAs<clang::CallExpr>("fenceExpr");
if (!ce_outer) {
ce_outer = Result.Nodes.getNodeAs<clang::CallExpr>("callExpr");
}

if (!ce_outer) {
return;
}

auto file = rw.getSourceMgr().getFilename(getEnd(ce_outer));

fmt::print("considering filename={}, regex={}\n", file.str(), Matcher);

std::regex re(Matcher);
std::cmatch m;
if (std::regex_match(file.str().c_str(), m, re)) {
fmt::print("=== Invoking rewriter on matched result in {} ===\n", file.str());
// we need to process this match
} else {
// break out and ignore this file
return;
}

if (processed_files.find(file.str()) != processed_files.end()) {
fmt::print("already generated for filename={}\n", file.str());
return;
}

new_processed_files.insert(file.str());

if (CallExpr const *ce = Result.Nodes.getNodeAs<clang::CallExpr>("fenceExpr")) {
auto begin = getBegin(ce);

Expand Down

0 comments on commit 9fef284

Please sign in to comment.