Skip to content

Commit

Permalink
[HIPIFY][ROCm#1267][ROCm#1266][fix] Correctly delete the last argumen…
Browse files Browse the repository at this point in the history
…t from the function call for `e_remove_argument` transformation

+ [TODO] Add a synthetic test for a single argument deletion
  • Loading branch information
emankov committed Jan 7, 2024
1 parent 47fcba0 commit c6dc157
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/HipifyAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1883,10 +1883,18 @@ bool HipifyAction::cudaHostFuncCall(const mat::MatchFinder::MatchResult &Result)
case e_remove_argument:
{
OS << "";
if (argNum < call->getNumArgs())
if (argNum < call->getNumArgs() - 1) {
e = call->getArg(argNum + 1)->getBeginLoc();
else
}
else {
e = call->getEndLoc();
if (call->getNumArgs() > 1) {
auto prevComma = clang::Lexer::findNextToken(call->getArg(argNum - 1)->getSourceRange().getEnd(), *SM, DefaultLangOptions);
if (!prevComma)
s = call->getEndLoc();
s = prevComma->getLocation();
}
}
length = SM->getCharacterData(e) - SM->getCharacterData(s);
break;
}
Expand Down

0 comments on commit c6dc157

Please sign in to comment.