r305381 - Reverted 305379 (Function with unparsed body is a definition)
Serge Pavlov via cfe-commits
cfe-commits at lists.llvm.org
Wed Jun 14 03:57:57 PDT 2017
Author: sepavloff
Date: Wed Jun 14 05:57:56 2017
New Revision: 305381
URL: http://llvm.org/viewvc/llvm-project?rev=305381&view=rev
Log:
Reverted 305379 (Function with unparsed body is a definition)
It broke clang-x86_64-linux-selfhost-modules-2 and some other buildbots.
Modified:
cfe/trunk/include/clang/AST/Decl.h
cfe/trunk/lib/Sema/SemaCUDA.cpp
cfe/trunk/lib/Sema/SemaDecl.cpp
cfe/trunk/lib/Sema/SemaDeclCXX.cpp
cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
cfe/trunk/test/SemaCXX/friend2.cpp
Modified: cfe/trunk/include/clang/AST/Decl.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/AST/Decl.h?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/include/clang/AST/Decl.h (original)
+++ cfe/trunk/include/clang/AST/Decl.h Wed Jun 14 05:57:56 2017
@@ -1872,7 +1872,7 @@ public:
///
bool isThisDeclarationADefinition() const {
return IsDeleted || IsDefaulted || Body || IsLateTemplateParsed ||
- WillHaveBody || hasDefiningAttr();
+ hasDefiningAttr();
}
/// doesThisDeclarationHaveABody - Returns whether this specific
Modified: cfe/trunk/lib/Sema/SemaCUDA.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaCUDA.cpp?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaCUDA.cpp (original)
+++ cfe/trunk/lib/Sema/SemaCUDA.cpp Wed Jun 14 05:57:56 2017
@@ -629,6 +629,12 @@ static bool IsKnownEmitted(Sema &S, Func
// emitted, because (say) the definition could include "inline".
FunctionDecl *Def = FD->getDefinition();
+ // We may currently be parsing the body of FD, in which case
+ // FD->getDefinition() will be null, but we still want to treat FD as though
+ // it's a definition.
+ if (!Def && FD->willHaveBody())
+ Def = FD;
+
if (Def &&
!isDiscardableGVALinkage(S.getASTContext().GetGVALinkageForFunction(Def)))
return true;
Modified: cfe/trunk/lib/Sema/SemaDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDecl.cpp?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDecl.cpp Wed Jun 14 05:57:56 2017
@@ -12218,7 +12218,6 @@ Decl *Sema::ActOnFinishFunctionBody(Decl
if (FD) {
FD->setBody(Body);
- FD->setWillHaveBody(false);
if (getLangOpts().CPlusPlus14) {
if (!FD->isInvalidDecl() && Body && !FD->isDependentContext() &&
Modified: cfe/trunk/lib/Sema/SemaDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclCXX.cpp?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaDeclCXX.cpp (original)
+++ cfe/trunk/lib/Sema/SemaDeclCXX.cpp Wed Jun 14 05:57:56 2017
@@ -13878,9 +13878,6 @@ void Sema::SetDeclDeleted(Decl *Dcl, Sou
return;
}
- // Deleted function does not have a body.
- Fn->setWillHaveBody(false);
-
if (const FunctionDecl *Prev = Fn->getPreviousDecl()) {
// Don't consider the implicit declaration we generate for explicit
// specializations. FIXME: Do not generate these implicit declarations.
Modified: cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp (original)
+++ cfe/trunk/lib/Sema/SemaTemplateInstantiateDecl.cpp Wed Jun 14 05:57:56 2017
@@ -1782,12 +1782,6 @@ Decl *TemplateDeclInstantiator::VisitFun
Previous.clear();
}
- if (isFriend) {
- Function->setObjectOfFriendDecl();
- if (FunctionTemplate)
- FunctionTemplate->setObjectOfFriendDecl();
- }
-
SemaRef.CheckFunctionDeclaration(/*Scope*/ nullptr, Function, Previous,
isExplicitSpecialization);
@@ -1798,6 +1792,7 @@ Decl *TemplateDeclInstantiator::VisitFun
// If the original function was part of a friend declaration,
// inherit its namespace state and add it to the owner.
if (isFriend) {
+ PrincipalDecl->setObjectOfFriendDecl();
DC->makeDeclVisibleInContext(PrincipalDecl);
bool QueuedInstantiation = false;
Modified: cfe/trunk/test/SemaCXX/friend2.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/SemaCXX/friend2.cpp?rev=305381&r1=305380&r2=305381&view=diff
==============================================================================
--- cfe/trunk/test/SemaCXX/friend2.cpp (original)
+++ cfe/trunk/test/SemaCXX/friend2.cpp Wed Jun 14 05:57:56 2017
@@ -170,15 +170,3 @@ struct Test {
template class Test<int>;
}
-
-namespace pr14785 {
-template<typename T>
-struct Somewhat {
- void internal() const { }
- friend void operator+(int const &, Somewhat<T> const &) {} // expected-error{{redefinition of 'operator+'}}
-};
-
-void operator+(int const &, Somewhat<char> const &x) { // expected-note {{previous definition is here}}
- x.internal(); // expected-note{{in instantiation of template class 'pr14785::Somewhat<char>' requested here}}
-}
-}
More information about the cfe-commits
mailing list