]> granicus.if.org Git - clang/commit
Derive builtin return type from its definition
authorMarco Antognini <marco.antognini@arm.com>
Tue, 27 Nov 2018 14:54:58 +0000 (14:54 +0000)
committerMarco Antognini <marco.antognini@arm.com>
Tue, 27 Nov 2018 14:54:58 +0000 (14:54 +0000)
commit838922fb5574aa17e63b07b84c11c957e4a5ea1e
treeb34ff496a8c2c23bb6dd7590f62e3876a9eb6b7a
parente44c638ccfb9c020561219a3bfc76ce41a99cf4b
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
lib/Sema/SemaChecking.cpp
lib/Sema/SemaExpr.cpp
test/CodeGenOpenCL/builtins.cl [new file with mode: 0644]
test/CodeGenOpenCL/pipe_builtin.cl