Skip to content

Commit

Permalink
[SYCLomatic] Fix a bug that type cast is removed incorrectly during m…
Browse files Browse the repository at this point in the history
…igration (#300)

Signed-off-by: Ziran Zhang <ziran.zhang@intel.com>
  • Loading branch information
ziranzha authored Oct 25, 2022
1 parent a72bb0a commit 8d4d0ee
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion clang/lib/DPCT/ASTTraversal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10887,7 +10887,7 @@ void MemoryMigrationRule::mallocMigration(
new ReplaceCalleeName(C, MapNames::getDpctNamespace() + "dpct_malloc"));
emplaceTransformation(removeArg(C, 0, *Result.SourceManager));
std::ostringstream OS2;
printDerefOp(OS2, C->getArg(1)->IgnoreCasts()->IgnoreParens());
printDerefOp(OS2, C->getArg(1));
if (Name == "cudaMallocPitch") {
emplaceTransformation(new ReplaceStmt(C->getArg(1), OS2.str()));
}
Expand Down
5 changes: 5 additions & 0 deletions clang/test/dpct/memory_management.cu
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,11 @@ void testCommas() {

// CHECK: d_A = (float *)dpct::dpct_malloc(size, size, size);
cudaMallocPitch((void **)&d_A, &size, size, size);
int sz;
// CHECK: d_A = (float *)dpct::dpct_malloc(*((size_t *)&size), size, size);
cudaMallocPitch((void **)&d_A, (size_t *)&size, size, size);
// CHECK: d_A = (float *)dpct::dpct_malloc(*((size_t *)&sz), size, size);
cudaMallocPitch((void **)&d_A, (size_t *)&sz, size, size);
// CHECK:/*
// CHECK-NEXT:DPCT1003:{{[0-9]+}}: Migrated API does not return error code. (*, 0) is inserted. You may need to rewrite this code.
// CHECK-NEXT:*/
Expand Down

0 comments on commit 8d4d0ee

Please sign in to comment.