@@ -348,25 +348,24 @@ void TypeInDeclRule::registerMatcher(MatchFinder &MF) {
348348 " cudaGraphicsRegisterFlags" , " cudaExternalMemoryHandleType" ,
349349 " cudaExternalSemaphoreHandleType" , " CUstreamCallback" ,
350350 " cudaHostFn_t" , " __nv_half2" , " __nv_half" , " cudaGraphNodeType" ,
351- " CUsurfref" , " CUdevice_P2PAttribute" , " cudaIpcMemHandle_t" ,
352- " cudaGraphExecUpdateResultInfo" ))))))
351+ " CUsurfref" , " CUdevice_P2PAttribute" , " cudaIpcMemHandle_t" ))))))
353352 .bind (" cudaTypeDef" ),
354353 this );
355354
356355 MF .addMatcher (
357- typeLoc (
358- loc ( qualType ( hasDeclaration ( namedDecl ( hasAnyName (
359- " cooperative_groups::__v1::coalesced_group " ,
360- " cooperative_groups::__v1::grid_group " ,
361- " cooperative_groups::__v1::thread_block_tile " , " cudaGraph_t " ,
362- " cudaGraphExec_t " , " cudaGraphNode_t " , " cudaGraphicsResource " ,
363- " cudaGraphicsResource_t " , " CUgraphicsResource " ,
364- " cudaExternalMemory_t " , " cudaExternalMemoryHandleDesc " ,
365- " cudaExternalMemoryMipmappedArrayDesc " ,
366- " cudaExternalMemoryBufferDesc " , " cudaExternalSemaphore_t " ,
367- " cudaExternalSemaphoreHandleDesc " ,
368- " cudaExternalSemaphoreSignalParams " ,
369- " cudaExternalSemaphoreWaitParams " , " cudaKernelNodeParams " ))))))
356+ typeLoc (loc ( qualType ( hasDeclaration ( namedDecl ( hasAnyName (
357+ " cooperative_groups::__v1::coalesced_group " ,
358+ " cooperative_groups::__v1::grid_group " ,
359+ " cooperative_groups::__v1::thread_block_tile " , " cudaGraph_t " ,
360+ " cudaGraphExec_t " , " cudaGraphNode_t " , " cudaGraphicsResource " ,
361+ " cudaGraphicsResource_t " , " CUgraphicsResource " ,
362+ " cudaExternalMemory_t " , " cudaExternalMemoryHandleDesc " ,
363+ " cudaExternalMemoryMipmappedArrayDesc " ,
364+ " cudaExternalMemoryBufferDesc " , " cudaExternalSemaphore_t " ,
365+ " cudaExternalSemaphoreHandleDesc " ,
366+ " cudaExternalSemaphoreSignalParams " ,
367+ " cudaExternalSemaphoreWaitParams " , " cudaKernelNodeParams " ,
368+ " cudaGraphExecUpdateResultInfo " ))))))
370369 .bind (" cudaTypeDefEA" ),
371370 this );
372371 MF .addMatcher (varDecl (hasType (classTemplateSpecializationDecl (
@@ -945,7 +944,7 @@ void TypeInDeclRule::runRule(const MatchFinder::MatchResult &Result) {
945944 " --use-experimental-features=graph" );
946945 }
947946 }
948-
947+
949948 if (CanonicalTypeStr == " cudaGraphicsRegisterFlags" ||
950949 CanonicalTypeStr == " cudaGraphicsMapFlags" ) {
951950 if (!DpctGlobalInfo::useExtBindlessImages ()) {
@@ -2738,6 +2737,48 @@ const VarDecl *getAssignTargetDecl(const Stmt *E) {
27382737 return nullptr ;
27392738}
27402739
2740+ const Expr *getParentAsAssignedBO (const Expr *E,
2741+ ASTContext &Context, MigrationRule *Rule) {
2742+ auto Parents = Context.getParents (*E);
2743+ if (Parents.size () > 0 )
2744+ return getAssignedBO (Parents[0 ].get <Expr>(), Context, Rule);
2745+ return nullptr ;
2746+ }
2747+
2748+ // Return the binary operator if E is the lhs of an assign expression,
2749+ // otherwise nullptr.
2750+ const Expr *getAssignedBO (const Expr *E, ASTContext &Context, MigrationRule *Rule) {
2751+ if (dyn_cast<MemberExpr>(E)) {
2752+ // Continue finding parents when E is MemberExpr.
2753+ return getParentAsAssignedBO (E, Context, Rule);
2754+ } else if (auto ICE = dyn_cast<ImplicitCastExpr>(E)) {
2755+ // Stop finding parents and return nullptr when E is ImplicitCastExpr,
2756+ // except for ArrayToPointerDecay cast.
2757+ if (ICE ->getCastKind () == CK_ArrayToPointerDecay) {
2758+ return getParentAsAssignedBO (E, Context, Rule);
2759+ }
2760+ } else if (auto ASE = dyn_cast<ArraySubscriptExpr>(E)) {
2761+ // Continue finding parents when E is ArraySubscriptExpr, and remove
2762+ // subscript operator anyway for texture object's member.
2763+ Rule->emplaceTransformation (new ReplaceToken (
2764+ Lexer::getLocForEndOfToken (ASE ->getLHS ()->getEndLoc (), 0 ,
2765+ Context.getSourceManager (),
2766+ Context.getLangOpts ()),
2767+ ASE ->getRBracketLoc (), " " ));
2768+ return getParentAsAssignedBO (E, Context, Rule);
2769+ } else if (auto BO = dyn_cast<BinaryOperator>(E)) {
2770+ // If E is BinaryOperator, return E only when it is assign expression,
2771+ // otherwise return nullptr.
2772+ if (BO ->getOpcode () == BO_Assign)
2773+ return BO ;
2774+ } else if (auto COCE = dyn_cast<CXXOperatorCallExpr>(E)) {
2775+ if (COCE ->getOperator () == OO_Equal) {
2776+ return COCE ;
2777+ }
2778+ }
2779+ return nullptr ;
2780+ }
2781+
27412782const VarDecl *EventQueryTraversal::getAssignTarget (const CallExpr *Call) {
27422783 auto ParentMap = Context.getParents (*Call);
27432784 if (ParentMap.size () == 0 )
0 commit comments