diff options
author | Marco Antognini <marco.antognini@arm.com> | 2018-11-27 14:54:58 +0000 |
---|---|---|
committer | Marco Antognini <marco.antognini@arm.com> | 2018-11-27 14:54:58 +0000 |
commit | 838922fb5574aa17e63b07b84c11c957e4a5ea1e (patch) | |
tree | b34ff496a8c2c23bb6dd7590f62e3876a9eb6b7a /lib/Sema/SemaChecking.cpp | |
parent | e44c638ccfb9c020561219a3bfc76ce41a99cf4b (diff) | |
download | clang-838922fb5574aa17e63b07b84c11c957e4a5ea1e.tar.gz |
Derive builtin return type from its definition
Summary:
Prior to this patch, OpenCL code such as the following would attempt to create
a BranchInst with a non-bool argument:
if (enqueue_kernel(get_default_queue(), 0, nd, ^(void){})) /* ... */
This patch is a follow up on a similar issue with pipe builtin
operations. See commit r280800 and https://bugs.llvm.org/show_bug.cgi?id=30219.
This change, while being conservative on non-builtin functions,
should set the type of expressions invoking builtins to the
proper type, instead of defaulting to `bool` and requiring
manual overrides in Sema::CheckBuiltinFunctionCall.
In addition to tests for enqueue_kernel, the tests are extended to
check other OpenCL builtins.
Reviewers: Anastasia, spatel, rsmith
Reviewed By: Anastasia
Subscribers: kristina, cfe-commits, svenvh
Differential Revision: https://reviews.llvm.org/D52879
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@347658 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaChecking.cpp')
-rw-r--r-- | lib/Sema/SemaChecking.cpp | 2 |
1 files changed, 0 insertions, 2 deletions
diff --git a/lib/Sema/SemaChecking.cpp b/lib/Sema/SemaChecking.cpp index a45d4fdfd7..b74be1b30a 100644 --- a/lib/Sema/SemaChecking.cpp +++ b/lib/Sema/SemaChecking.cpp @@ -1308,7 +1308,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, // check for the argument. if (SemaBuiltinRWPipe(*this, TheCall)) return ExprError(); - TheCall->setType(Context.IntTy); break; case Builtin::BIreserve_read_pipe: case Builtin::BIreserve_write_pipe: @@ -1340,7 +1339,6 @@ Sema::CheckBuiltinFunctionCall(FunctionDecl *FDecl, unsigned BuiltinID, case Builtin::BIget_pipe_max_packets: if (SemaBuiltinPipePackets(*this, TheCall)) return ExprError(); - TheCall->setType(Context.UnsignedIntTy); break; case Builtin::BIto_global: case Builtin::BIto_local: |