From: Hans Wennborg Date: Tue, 16 Dec 2014 01:15:01 +0000 (+0000) Subject: Clarify the code in checkDLLAttribute() X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7e5d25d7aa07c3df3ebf83dfeb8d44b96cecaedd;p=clang Clarify the code in checkDLLAttribute() Update the comments to make it more clear what's going on, and address Richard's comments from PR21718. This doesn't fix that bug, but hopefully makes the code easier to understand. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@224303 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaDeclCXX.cpp b/lib/Sema/SemaDeclCXX.cpp index 8240725065..ec87b850ba 100644 --- a/lib/Sema/SemaDeclCXX.cpp +++ b/lib/Sema/SemaDeclCXX.cpp @@ -4748,7 +4748,7 @@ static void checkDLLAttribute(Sema &S, CXXRecordDecl *Class) { if (MD && ClassExported) { if (MD->isUserProvided()) { - // Instantiate non-default methods.. + // Instantiate non-default class member functions ... // .. except for certain kinds of template specializations. if (TSK == TSK_ExplicitInstantiationDeclaration) @@ -4757,16 +4757,21 @@ static void checkDLLAttribute(Sema &S, CXXRecordDecl *Class) { continue; S.MarkFunctionReferenced(Class->getLocation(), MD); + + // The function will be passed to the consumer when its definition is + // encountered. } else if (!MD->isTrivial() || MD->isExplicitlyDefaulted() || MD->isCopyAssignmentOperator() || MD->isMoveAssignmentOperator()) { - // Instantiate non-trivial or explicitly defaulted methods, and the - // copy assignment / move assignment operators. + // Synthesize and instantiate non-trivial implicit methods, explicitly + // defaulted methods, and the copy and move assignment operators. The + // latter are exported even if they are trivial, because the address of + // an operator can be taken and should compare equal accross libraries. S.MarkFunctionReferenced(Class->getLocation(), MD); - // Resolve its exception specification; CodeGen needs it. - auto *FPT = MD->getType()->getAs(); - S.ResolveExceptionSpec(Class->getLocation(), FPT); - S.ActOnFinishInlineMethodDef(MD); + + // There is no later point when we will see the definition of this + // function, so pass it to the consumer now. + S.Consumer.HandleTopLevelDecl(DeclGroupRef(MD)); } } }