[llvm-branch-commits] [cfe-branch] r236442 - Merging r232786:

Tom Stellard thomas.stellard at amd.com
Mon May 4 11:24:00 PDT 2015


Author: tstellar
Date: Mon May  4 13:23:59 2015
New Revision: 236442

URL: http://llvm.org/viewvc/llvm-project?rev=236442&view=rev
Log:
Merging r232786:

------------------------------------------------------------------------
r232786 | david.majnemer | 2015-03-19 20:02:27 -0400 (Thu, 19 Mar 2015) | 7 lines

Don't crash-on-valid when an inline function is friend of class template

We assumed that the most recent declaration of an inline function would
also be inline.  However, a more recent declaration can come from a
friend declaration in a class template that is instantiated at the
definition of the function.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_36/lib/AST/ASTContext.cpp
    cfe/branches/release_36/lib/AST/Decl.cpp
    cfe/branches/release_36/test/CodeGenCXX/inline-functions.cpp

Modified: cfe/branches/release_36/lib/AST/ASTContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/lib/AST/ASTContext.cpp?rev=236442&r1=236441&r2=236442&view=diff
==============================================================================
--- cfe/branches/release_36/lib/AST/ASTContext.cpp (original)
+++ cfe/branches/release_36/lib/AST/ASTContext.cpp Mon May  4 13:23:59 2015
@@ -7874,7 +7874,7 @@ static GVALinkage basicGVALinkageForFunc
   // Functions specified with extern and inline in -fms-compatibility mode
   // forcibly get emitted.  While the body of the function cannot be later
   // replaced, the function definition cannot be discarded.
-  if (FD->getMostRecentDecl()->isMSExternInline())
+  if (FD->isMSExternInline())
     return GVA_StrongODR;
 
   return GVA_DiscardableODR;

Modified: cfe/branches/release_36/lib/AST/Decl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/lib/AST/Decl.cpp?rev=236442&r1=236441&r2=236442&view=diff
==============================================================================
--- cfe/branches/release_36/lib/AST/Decl.cpp (original)
+++ cfe/branches/release_36/lib/AST/Decl.cpp Mon May  4 13:23:59 2015
@@ -2674,7 +2674,8 @@ bool FunctionDecl::isMSExternInline() co
   if (!Context.getLangOpts().MSVCCompat && !hasAttr<DLLExportAttr>())
     return false;
 
-  for (const FunctionDecl *FD = this; FD; FD = FD->getPreviousDecl())
+  for (const FunctionDecl *FD = getMostRecentDecl(); FD;
+       FD = FD->getPreviousDecl())
     if (FD->getStorageClass() == SC_Extern)
       return true;
 

Modified: cfe/branches/release_36/test/CodeGenCXX/inline-functions.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_36/test/CodeGenCXX/inline-functions.cpp?rev=236442&r1=236441&r2=236442&view=diff
==============================================================================
--- cfe/branches/release_36/test/CodeGenCXX/inline-functions.cpp (original)
+++ cfe/branches/release_36/test/CodeGenCXX/inline-functions.cpp Mon May  4 13:23:59 2015
@@ -121,3 +121,18 @@ struct TypeWithInlineMethods {
   // CHECK-NOT: _ZN21TypeWithInlineMethods12NonStaticFunEv
   void NonStaticFun() { StaticFun(); }
 };
+
+namespace PR22959 {
+template <typename>
+struct S;
+
+S<int> Foo();
+
+template <typename>
+struct S {
+  friend S<int> Foo();
+};
+
+__attribute__((used)) inline S<int> Foo() { return S<int>(); }
+// CHECK-LABEL: define linkonce_odr void @_ZN7PR229593FooEv(
+}





More information about the llvm-branch-commits mailing list