Skip to content

Commit

Permalink
Merge pull request ROCm#1268 from emankov/HIPIFY
Browse files Browse the repository at this point in the history
[HIPIFY][ROCm#1267][ROCm#1266][fix] Correctly delete the last argument from the function call for `e_remove_argument` transformation
  • Loading branch information
emankov authored Jan 7, 2024
2 parents 47fcba0 + c6dc157 commit 559c59d
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 559c59d

Please sign in to comment.