diff options
| author | Rafael Auler <rafaelauler@fb.com> | 2019-03-07 19:14:30 +0000 |
|---|---|---|
| committer | Rafael Auler <rafaelauler@fb.com> | 2019-03-07 19:14:30 +0000 |
| commit | 2ead8e899327807e63b668e65de6cb09c31bb667 (patch) | |
| tree | 28e5890a0d8424c9135dfcd6efef03a244c23bbd /clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp | |
| parent | 392c04498b288a1c460d212a476c50f08895a34c (diff) | |
| download | bcm5719-llvm-2ead8e899327807e63b668e65de6cb09c31bb667.tar.gz bcm5719-llvm-2ead8e899327807e63b668e65de6cb09c31bb667.zip | |
Recommit "Support attribute used in member funcs of class templates"
The patch originally broke code that was incompatible with GCC, but
we want to follow GCC behavior here according to the discussion in
https://reviews.llvm.org/D58216
Original commit message:
As PR17480 describes, clang does not support the used attribute
for member functions of class templates. This means that if the member
function is not used, its definition is never instantiated. This patch
changes clang to emit the definition if it has the used attribute.
Test Plan: Added a testcase
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D56928
llvm-svn: 355627
Diffstat (limited to 'clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp')
| -rw-r--r-- | clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp b/clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp new file mode 100644 index 00000000000..7d2062f989d --- /dev/null +++ b/clang/test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp @@ -0,0 +1,19 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-unknown -emit-llvm -o - %s | FileCheck %s + +// Check that PR17480 is fixed: __attribute__((used)) ignored in templated +// classes +namespace InstantiateUsedMemberDefinition { +template <typename T> +struct S { + int __attribute__((used)) f() { + return 0; + } +}; + +void test() { + // Check that InstantiateUsedMemberDefinition::S<int>::f() is defined + // as a result of the S class template implicit instantiation + // CHECK: define linkonce_odr i32 @_ZN31InstantiateUsedMemberDefinition1SIiE1fEv + S<int> inst; +} +} // namespace InstantiateUsedMemberDefinition |

