浏览代码

Revert "Recommit "Support attribute used in member funcs of class templates""

There is nontrivial bug caused in lld that I need to further
investigate. Meanwhile, I'll revert this.

This reverts commit 8297e93480c636dc90fd14653c5a66406193363f.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@355721 91177308-0d34-0410-b5e6-96231b3b80d8
Rafael Auler 6 年之前
父节点
当前提交
176c1186cd

+ 0 - 14
lib/Sema/SemaTemplateInstantiateDecl.cpp

@@ -2232,20 +2232,6 @@ TemplateDeclInstantiator::VisitCXXMethodDecl(CXXMethodDecl *D,
     Owner->addDecl(Method);
   }
 
-  // PR17480: Honor the used attribute to instantiate member function
-  // definitions
-  if (Method->hasAttr<UsedAttr>()) {
-    if (const auto *A = dyn_cast<CXXRecordDecl>(Owner)) {
-      SourceLocation Loc;
-      if (const MemberSpecializationInfo *MSInfo =
-              A->getMemberSpecializationInfo())
-        Loc = MSInfo->getPointOfInstantiation();
-      else if (const auto *Spec = dyn_cast<ClassTemplateSpecializationDecl>(A))
-        Loc = Spec->getPointOfInstantiation();
-      SemaRef.MarkFunctionReferenced(Loc, Method);
-    }
-  }
-
   return Method;
 }
 

+ 0 - 19
test/CodeGenCXX/attr-used-member-function-implicit-instantiation.cpp

@@ -1,19 +0,0 @@
-// 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