From: Reid Kleckner Date: Thu, 17 Mar 2016 20:06:58 +0000 (+0000) Subject: Revert "For MS ABI, emit dllexport friend functions defined inline in class" X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=402b389802ab2abb0e30530937836ed29aa3174f;p=clang Revert "For MS ABI, emit dllexport friend functions defined inline in class" This reverts commit r263738. This appears to cause a failure in CXX/temp/temp.decls/temp.friend/p1.cpp git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@263740 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang/AST/ASTConsumer.h b/include/clang/AST/ASTConsumer.h index 0b1f0068fa..7b5dd9be8a 100644 --- a/include/clang/AST/ASTConsumer.h +++ b/include/clang/AST/ASTConsumer.h @@ -55,9 +55,9 @@ public: /// \returns true to continue parsing, or false to abort parsing. virtual bool HandleTopLevelDecl(DeclGroupRef D); - /// \brief This callback is invoked each time an inline (method or friend) - /// function definition in a class is completed. - virtual void HandleInlineFunctionDefinition(FunctionDecl *D) {} + /// \brief This callback is invoked each time an inline method definition is + /// completed. + virtual void HandleInlineMethodDefinition(CXXMethodDecl *D) {} /// HandleInterestingDecl - Handle the specified interesting declaration. This /// is called by the AST reader when deserializing things that might interest diff --git a/include/clang/Frontend/MultiplexConsumer.h b/include/clang/Frontend/MultiplexConsumer.h index d13565c27b..da14526633 100644 --- a/include/clang/Frontend/MultiplexConsumer.h +++ b/include/clang/Frontend/MultiplexConsumer.h @@ -36,7 +36,7 @@ public: void Initialize(ASTContext &Context) override; void HandleCXXStaticMemberVarInstantiation(VarDecl *VD) override; bool HandleTopLevelDecl(DeclGroupRef D) override; - void HandleInlineFunctionDefinition(FunctionDecl *D) override; + void HandleInlineMethodDefinition(CXXMethodDecl *D) override; void HandleInterestingDecl(DeclGroupRef D) override; void HandleTranslationUnit(ASTContext &Ctx) override; void HandleTagDeclDefinition(TagDecl *D) override; diff --git a/include/clang/Sema/Sema.h b/include/clang/Sema/Sema.h index 270856fddd..ba39b10be0 100644 --- a/include/clang/Sema/Sema.h +++ b/include/clang/Sema/Sema.h @@ -1773,7 +1773,7 @@ public: Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body); Decl *ActOnFinishFunctionBody(Decl *Decl, Stmt *Body, bool IsInstantiation); Decl *ActOnSkippedFunctionBody(Decl *Decl); - void ActOnFinishInlineFunctionDef(FunctionDecl *D); + void ActOnFinishInlineMethodDef(CXXMethodDecl *D); /// ActOnFinishDelayedAttribute - Invoked when we have finished parsing an /// attribute for which parsing is delayed. diff --git a/lib/CodeGen/CodeGenAction.cpp b/lib/CodeGen/CodeGenAction.cpp index edd258d3d5..638f79a245 100644 --- a/lib/CodeGen/CodeGenAction.cpp +++ b/lib/CodeGen/CodeGenAction.cpp @@ -123,14 +123,14 @@ namespace clang { return true; } - void HandleInlineFunctionDefinition(FunctionDecl *D) override { + void HandleInlineMethodDefinition(CXXMethodDecl *D) override { PrettyStackTraceDecl CrashInfo(D, SourceLocation(), Context->getSourceManager(), - "LLVM IR generation of inline function"); + "LLVM IR generation of inline method"); if (llvm::TimePassesIsEnabled) LLVMIRGeneration.startTimer(); - Gen->HandleInlineFunctionDefinition(D); + Gen->HandleInlineMethodDefinition(D); if (llvm::TimePassesIsEnabled) LLVMIRGeneration.stopTimer(); diff --git a/lib/CodeGen/ModuleBuilder.cpp b/lib/CodeGen/ModuleBuilder.cpp index 14e6bc5b91..bd59332a27 100644 --- a/lib/CodeGen/ModuleBuilder.cpp +++ b/lib/CodeGen/ModuleBuilder.cpp @@ -143,22 +143,12 @@ namespace { DeferredInlineMethodDefinitions.clear(); } - void HandleInlineFunctionDefinition(FunctionDecl *D) override { + void HandleInlineMethodDefinition(CXXMethodDecl *D) override { if (Diags.hasErrorOccurred()) return; assert(D->doesThisDeclarationHaveABody()); - // Handle friend functions. - if (D->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend)) { - if (Ctx->getTargetInfo().getCXXABI().isMicrosoft()) - Builder->EmitTopLevelDecl(D); - return; - } - - // Otherwise, must be a method. - auto MD = cast(D); - // We may want to emit this definition. However, that decision might be // based on computing the linkage, and we have to defer that in case we // are inside of something that will change the method's final linkage, @@ -167,13 +157,13 @@ namespace { // void bar(); // void foo() { bar(); } // } A; - DeferredInlineMethodDefinitions.push_back(MD); + DeferredInlineMethodDefinitions.push_back(D); // Provide some coverage mapping even for methods that aren't emitted. // Don't do this for templated classes though, as they may not be // instantiable. - if (!MD->getParent()->getDescribedClassTemplate()) - Builder->AddDeferredUnusedCoverageMapping(MD); + if (!D->getParent()->getDescribedClassTemplate()) + Builder->AddDeferredUnusedCoverageMapping(D); } /// HandleTagDeclDefinition - This callback is invoked each time a TagDecl diff --git a/lib/Frontend/MultiplexConsumer.cpp b/lib/Frontend/MultiplexConsumer.cpp index ccda8c360a..31c9b5f23f 100644 --- a/lib/Frontend/MultiplexConsumer.cpp +++ b/lib/Frontend/MultiplexConsumer.cpp @@ -272,9 +272,9 @@ bool MultiplexConsumer::HandleTopLevelDecl(DeclGroupRef D) { return Continue; } -void MultiplexConsumer::HandleInlineFunctionDefinition(FunctionDecl *D) { +void MultiplexConsumer::HandleInlineMethodDefinition(CXXMethodDecl *D) { for (auto &Consumer : Consumers) - Consumer->HandleInlineFunctionDefinition(D); + Consumer->HandleInlineMethodDefinition(D); } void MultiplexConsumer::HandleCXXStaticMemberVarInstantiation(VarDecl *VD) { diff --git a/lib/Parse/ParseCXXInlineMethods.cpp b/lib/Parse/ParseCXXInlineMethods.cpp index 3db75c7ee7..07e32b7e42 100644 --- a/lib/Parse/ParseCXXInlineMethods.cpp +++ b/lib/Parse/ParseCXXInlineMethods.cpp @@ -564,10 +564,8 @@ void Parser::ParseLexedMethodDef(LexedMethod &LM) { if (Tok.is(tok::eof) && Tok.getEofData() == LM.D) ConsumeAnyToken(); - if (auto *FD = dyn_cast_or_null(LM.D)) - if (isa(FD) || - FD->isInIdentifierNamespace(Decl::IDNS_OrdinaryFriend)) - Actions.ActOnFinishInlineFunctionDef(FD); + if (CXXMethodDecl *MD = dyn_cast_or_null(LM.D)) + Actions.ActOnFinishInlineMethodDef(MD); } /// ParseLexedMemberInitializers - We finished parsing the member specification diff --git a/lib/Sema/SemaDecl.cpp b/lib/Sema/SemaDecl.cpp index 7620e9713e..2f50b701ca 100644 --- a/lib/Sema/SemaDecl.cpp +++ b/lib/Sema/SemaDecl.cpp @@ -10872,8 +10872,8 @@ Sema::ActOnStartOfFunctionDef(Scope *FnBodyScope, Declarator &D, return ActOnStartOfFunctionDef(FnBodyScope, DP, SkipBody); } -void Sema::ActOnFinishInlineFunctionDef(FunctionDecl *D) { - Consumer.HandleInlineFunctionDefinition(D); +void Sema::ActOnFinishInlineMethodDef(CXXMethodDecl *D) { + Consumer.HandleInlineMethodDefinition(D); } static bool ShouldWarnAboutMissingPrototype(const FunctionDecl *FD, diff --git a/test/CodeGenCXX/dllexport.cpp b/test/CodeGenCXX/dllexport.cpp index 7f188a18d8..082bd00d7d 100644 --- a/test/CodeGenCXX/dllexport.cpp +++ b/test/CodeGenCXX/dllexport.cpp @@ -255,11 +255,9 @@ __declspec(dllexport) void redecl2(); // GNU-DAG: define dllexport void @_Z7friend1v() // MSC-DAG: define dllexport void @"\01?friend2@@YAXXZ"() // GNU-DAG: define dllexport void @_Z7friend2v() -// MSC-DAG: define weak_odr dllexport void @"\01?friend3@@YAXXZ"() struct FuncFriend { friend __declspec(dllexport) void friend1(); friend __declspec(dllexport) void friend2(); - friend __declspec(dllexport) void friend3() {} }; __declspec(dllexport) void friend1() {} void friend2() {}