r234355 - Revert "Mark instantiated function decls as inline specified if any pattern is"
Reid Kleckner
reid at kleckner.net
Tue Apr 7 13:46:51 PDT 2015
Author: rnk
Date: Tue Apr 7 15:46:51 2015
New Revision: 234355
URL: http://llvm.org/viewvc/llvm-project?rev=234355&view=rev
Log:
Revert "Mark instantiated function decls as inline specified if any pattern is"
It breaks down on this test case:
void foo();
template <typename T> class C {
friend void foo();
};
inline void foo() {}
C<int> c;
We shouldn't be marking the instantiation of the friend decl of foo as
inline-specified. It may be possible to fix this by determining if the
full definition is part of the current template, but it seems better to
rever tot green until we come up with a full solution.
This reverts commit r233817, as well as follow-ups r233820 and r233821.
Removed:
cfe/trunk/test/CodeGenCXX/inlinehint.cpp
Modified:
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=234355&r1=234354&r2=234355&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Tue Apr 7 15:46:51 2015
@@ -1304,15 +1304,6 @@ static QualType adjustFunctionTypeForIns
NewFunc->getParamTypes(), NewEPI);
}
-/// Return true if any redeclaration of FD was inline specified. Useful for
-/// propagating the 'inline' specifier onto function template instantiations.
-static bool isAnyRedeclInlineSpecified(const FunctionDecl *FD) {
- for (const auto *R : FD->redecls())
- if (R->isInlineSpecified())
- return true;
- return false;
-}
-
/// Normal class members are of more specific types and therefore
/// don't make it here. This function serves two purposes:
/// 1) instantiating function templates
@@ -1381,8 +1372,7 @@ Decl *TemplateDeclInstantiator::VisitFun
FunctionDecl::Create(SemaRef.Context, DC, D->getInnerLocStart(),
D->getNameInfo(), T, TInfo,
D->getCanonicalDecl()->getStorageClass(),
- isAnyRedeclInlineSpecified(D),
- D->hasWrittenPrototype(),
+ D->isInlineSpecified(), D->hasWrittenPrototype(),
D->isConstexpr());
Function->setRangeEnd(D->getSourceRange().getEnd());
@@ -1679,7 +1669,7 @@ TemplateDeclInstantiator::VisitCXXMethod
Method = CXXConstructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
Constructor->isExplicit(),
- isAnyRedeclInlineSpecified(Constructor),
+ Constructor->isInlineSpecified(),
false, Constructor->isConstexpr());
// Claim that the instantiation of a constructor or constructor template
@@ -1714,12 +1704,12 @@ TemplateDeclInstantiator::VisitCXXMethod
} else if (CXXDestructorDecl *Destructor = dyn_cast<CXXDestructorDecl>(D)) {
Method = CXXDestructorDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
- isAnyRedeclInlineSpecified(Destructor),
+ Destructor->isInlineSpecified(),
false);
} else if (CXXConversionDecl *Conversion = dyn_cast<CXXConversionDecl>(D)) {
Method = CXXConversionDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
- isAnyRedeclInlineSpecified(Conversion),
+ Conversion->isInlineSpecified(),
Conversion->isExplicit(),
Conversion->isConstexpr(),
Conversion->getLocEnd());
@@ -1727,7 +1717,7 @@ TemplateDeclInstantiator::VisitCXXMethod
StorageClass SC = D->isStatic() ? SC_Static : SC_None;
Method = CXXMethodDecl::Create(SemaRef.Context, Record,
StartLoc, NameInfo, T, TInfo,
- SC, isAnyRedeclInlineSpecified(D),
+ SC, D->isInlineSpecified(),
D->isConstexpr(), D->getLocEnd());
}
Removed: cfe/trunk/test/CodeGenCXX/inlinehint.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/inlinehint.cpp?rev=234354&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/inlinehint.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/inlinehint.cpp (removed)
@@ -1,33 +0,0 @@
-// RUN: %clang_cc1 -triple x86_64-linux %s -emit-llvm -o - | FileCheck %s
-
-inline void InlineFunc() {}
-// CHECK: define linkonce_odr void @_Z10InlineFuncv() #[[INLINEHINTATTR:[0-9]+]]
-
-struct MyClass {
- static void InlineStaticMethod();
- void InlineInstanceMethod();
-};
-inline void MyClass::InlineStaticMethod() {}
-// CHECK: define linkonce_odr void @_ZN7MyClass18InlineStaticMethodEv() #[[INLINEHINTATTR]]
-inline void MyClass::InlineInstanceMethod() {}
-// CHECK: define linkonce_odr void @_ZN7MyClass20InlineInstanceMethodEv(%struct.MyClass* %this) #[[INLINEHINTATTR]]
-
-template <typename T>
-struct MyTemplate {
- static void InlineStaticMethod();
- void InlineInstanceMethod();
-};
-template <typename T> inline void MyTemplate<T>::InlineStaticMethod() {}
-// CHECK: define linkonce_odr void @_ZN10MyTemplateIiE18InlineStaticMethodEv() #[[INLINEHINTATTR]]
-template <typename T> inline void MyTemplate<T>::InlineInstanceMethod() {}
-// CHECK: define linkonce_odr void @_ZN10MyTemplateIiE20InlineInstanceMethodEv(%struct.MyTemplate* %this) #[[INLINEHINTATTR]]
-
-void UseThem() {
- InlineFunc();
- MyClass::InlineStaticMethod();
- MyClass().InlineInstanceMethod();
- MyTemplate<int>::InlineStaticMethod();
- MyTemplate<int>().InlineInstanceMethod();
-}
-
-// CHECK: attributes #[[INLINEHINTATTR]] = { {{.*}}inlinehint{{.*}} }
More information about the cfe-commits
mailing list