Skip to content

Commit 71ba070

Browse files
Sisyphmacurtis-amd
authored andcommitted
[Sema] Fix bug in builtin AS override (llvm#138141)
Fix the logic in rewriteBuiltinFunctionDecl to work when the builtin has a pointer parameter with an address space and one without a fixed address space. A builtin fitting these criteria was recently added. Change the attribute string to perform type checking on it, so without the sema change compilation would fail with a wrong number of arguments error.
1 parent de32634 commit 71ba070

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6247,7 +6247,8 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
62476247
return nullptr;
62486248
Expr *Arg = ArgRes.get();
62496249
QualType ArgType = Arg->getType();
6250-
if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6250+
if (!ParamType->isPointerType() ||
6251+
ParamType->getPointeeType().hasAddressSpace() ||
62516252
!ArgType->isPointerType() ||
62526253
!ArgType->getPointeeType().hasAddressSpace() ||
62536254
isPtrSizeAddressSpace(ArgType->getPointeeType().getAddressSpace())) {
@@ -6256,9 +6257,6 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
62566257
}
62576258

62586259
QualType PointeeType = ParamType->getPointeeType();
6259-
if (PointeeType.hasAddressSpace())
6260-
continue;
6261-
62626260
NeedsNewDecl = true;
62636261
LangAS AS = ArgType->getPointeeType().getAddressSpace();
62646262

0 commit comments

Comments
 (0)