From ed3dd07cb909c91c9234ba850688ef8c8ac5d6cf Mon Sep 17 00:00:00 2001 From: l00672356 Date: Sat, 20 Jan 2024 18:42:35 +0800 Subject: [PATCH] [BSC] bugfix async function of currect loc --- clang/lib/Sema/BSC/SemaBSCCoroutine.cpp | 26 +++++++++---------- .../recursive-async-call.cbs | 8 +++--- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/clang/lib/Sema/BSC/SemaBSCCoroutine.cpp b/clang/lib/Sema/BSC/SemaBSCCoroutine.cpp index 9f4ca32c5c60..e3e5d00ba468 100644 --- a/clang/lib/Sema/BSC/SemaBSCCoroutine.cpp +++ b/clang/lib/Sema/BSC/SemaBSCCoroutine.cpp @@ -674,7 +674,7 @@ static FunctionDecl *buildFutureInitFunctionDefinition(Sema &S, RecordDecl *RD, FunctionDecl *FDecl) { FunctionDecl *NewFD = nullptr; SourceLocation SLoc = FD->getBeginLoc(); - SourceLocation NLoc = FD->getNameInfo().getLoc(); + SourceLocation NLoc = FD->getEndLoc(); FunctionDecl::param_const_iterator pi; if (isa(FD)) { @@ -923,7 +923,7 @@ static FunctionDecl *buildFutureInitFunctionDefinition(Sema &S, RecordDecl *RD, static FunctionDecl *buildFutureInitFunctionDeclaration(Sema &S, FunctionDecl *FD, RecordDecl *FatPointerRD) { SourceLocation SLoc = FD->getBeginLoc(); - SourceLocation NLoc = FD->getNameInfo().getLoc(); + SourceLocation NLoc = FD->getEndLoc(); DeclarationName funcName = FD->getDeclName(); QualType FuncRetType = S.Context.getRecordType(FatPointerRD); SmallVector ParamTys; @@ -964,7 +964,7 @@ static FunctionDecl * buildFutureStructInitFunctionDefinition(Sema &S, RecordDecl *RD, FunctionDecl *OriginFD) { SourceLocation SLoc = OriginFD->getBeginLoc(); - SourceLocation NLoc = OriginFD->getNameInfo().getLoc(); + SourceLocation NLoc = OriginFD->getEndLoc(); QualType FuncRetType = S.Context.getRecordType(RD); SmallVector ParamTys; FunctionDecl::param_const_iterator pi; @@ -1790,8 +1790,8 @@ class TransformToHasSingleState std::vector Stmts; Stmts.push_back(Body); Sema::CompoundScopeRAII CompoundScope(SemaRef); - Body = BaseTransform::RebuildCompoundStmt(SourceLocation(), Stmts, - SourceLocation(), false) + Body = BaseTransform::RebuildCompoundStmt(Body->getBeginLoc(), Stmts, + Body->getEndLoc(), false) .getAs(); FS->setBody(Body); } @@ -1853,8 +1853,8 @@ class TransformToHasSingleState } Sema::CompoundScopeRAII CompoundScope(SemaRef); CompoundStmt *CS = - BaseTransform::RebuildCompoundStmt(SourceLocation(), Statements, - SourceLocation(), false) + BaseTransform::RebuildCompoundStmt(S->getLBracLoc(), Statements, + S->getRBracLoc(), false) .getAs(); return CS; } @@ -2048,8 +2048,8 @@ class TransformARToCS : public TreeTransform { } Sema::CompoundScopeRAII CompoundScope(SemaRef); CompoundStmt *CS = - BaseTransform::RebuildCompoundStmt(SourceLocation(), Statements, - SourceLocation(), false) + BaseTransform::RebuildCompoundStmt(S->getLBracLoc(), Statements, + S->getRBracLoc(), false) .getAs(); return CS; } @@ -2488,8 +2488,8 @@ class TransformAEToCS : public TreeTransform { } Sema::CompoundScopeRAII CompoundScope(SemaRef); CompoundStmt *CS = - BaseTransform::RebuildCompoundStmt(SourceLocation(), Statements, - SourceLocation(), false) + BaseTransform::RebuildCompoundStmt(S->getLBracLoc(), Statements, + S->getRBracLoc(), false) .getAs(); return CS; } @@ -2515,7 +2515,7 @@ class TransformAEToCS : public TreeTransform { static BSCMethodDecl *buildFreeFunction(Sema &S, RecordDecl *RD, FunctionDecl *FD, bool IsOptimization) { SourceLocation SLoc = FD->getBeginLoc(); - SourceLocation NLoc = FD->getNameInfo().getLoc(); + SourceLocation NLoc = FD->getEndLoc(); std::string FName = "free"; QualType FuncRetType = S.Context.VoidTy; @@ -2674,7 +2674,7 @@ static BSCMethodDecl *buildPollFunction(Sema &S, RecordDecl *RD, RecordDecl *FatPointerRD, int FutureStateNumber) { SourceLocation SLoc = FD->getBeginLoc(); - SourceLocation NLoc = FD->getNameInfo().getLoc(); + SourceLocation NLoc = FD->getEndLoc(); QualType Ty = FD->getDeclaredReturnType(); std::string FName = "poll"; diff --git a/clang/test/BSC/Positive/Coroutine/Other/RecursiveCall/recursive-async-call/recursive-async-call.cbs b/clang/test/BSC/Positive/Coroutine/Other/RecursiveCall/recursive-async-call/recursive-async-call.cbs index 9624bbd44b91..42b962784faf 100644 --- a/clang/test/BSC/Positive/Coroutine/Other/RecursiveCall/recursive-async-call/recursive-async-call.cbs +++ b/clang/test/BSC/Positive/Coroutine/Other/RecursiveCall/recursive-async-call/recursive-async-call.cbs @@ -32,12 +32,12 @@ async int f() { // Declaration -// CHECK: |-FunctionDecl {{.*}} col:11 used __f 'struct __Trait_Future (void)' +// CHECK: |-FunctionDecl {{.*}} col:1 used __f 'struct __Trait_Future (void)' // Make sure that function `__f` has body. -// CHECK: |-FunctionDecl {{.*}} col:11 used __f 'struct __Trait_Future (void)' -// CHECK-NEXT: | `-CompoundStmt {{.*}} -// CHECK-NEXT: | |-DeclStmt {{.*}} +// CHECK: |-FunctionDecl {{.*}} col:1 used __f 'struct __Trait_Future (void)' +// CHECK-NEXT: | `-CompoundStmt {{.*}} +// CHECK-NEXT: | |-DeclStmt {{.*}} int main() { trait Future* this = f(); -- Gitee