[CUDA] Ignore implicit target attributes during function template instantiation.
authorArtem Belevich <tra@google.com>
Thu, 8 Dec 2016 19:38:13 +0000 (19:38 +0000)
committerArtem Belevich <tra@google.com>
Thu, 8 Dec 2016 19:38:13 +0000 (19:38 +0000)
commit64135c35f771c4d0fb9f01e05d167df0d0445710
tree3332e28bd1b82f1dd9b322f35827e888d4f64010
parent6eead19ce488d8d4bdb227bade182f8c5667327a
[CUDA] Ignore implicit target attributes during function template instantiation.

Some functions and templates are treated as __host__ __device__ even
when they don't have explicitly specified target attributes.
What's worse, this treatment may change depending on command line
options (-fno-cuda-host-device-constexpr) or
#pragma clang force_cuda_host_device.

Combined with strict checking for matching function target that comes
with D25809(r288962), it makes it hard to write code which would
explicitly instantiate or specialize some functions regardless of
pragmas or command line options in effect.

This patch changes the way we match target attributes of base template
vs attributes used in explicit instantiation or specialization so that
only explicitly specified attributes are considered. This makes base
template selection behave consistently regardless of pragma of command
line options that may affect CUDA target.

Differential Revision: https://reviews.llvm.org/D25845

llvm-svn: 289091
clang/include/clang/Sema/Sema.h
clang/lib/Sema/SemaCUDA.cpp
clang/lib/Sema/SemaDecl.cpp
clang/lib/Sema/SemaTemplate.cpp
clang/test/SemaCUDA/function-template-overload.cu