From 2c183aa7d4674ae3bea0cd1611415a8e8fe447f6 Mon Sep 17 00:00:00 2001 From: Hans Wennborg Date: Tue, 24 Jun 2014 23:57:05 +0000 Subject: Merge handleDLLImportAttr and handleDLLExportAttr into one function. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@211647 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Sema/SemaDeclAttr.cpp | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 5c868e94e3..af216d26e5 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -3844,13 +3844,6 @@ DLLImportAttr *Sema::mergeDLLImportAttr(Decl *D, SourceRange Range, return ::new (Context) DLLImportAttr(Range, Context, AttrSpellingListIndex); } -static void handleDLLImportAttr(Sema &S, Decl *D, const AttributeList &Attr) { - unsigned Index = Attr.getAttributeSpellingListIndex(); - DLLImportAttr *NewAttr = S.mergeDLLImportAttr(D, Attr.getRange(), Index); - if (NewAttr) - D->addAttr(NewAttr); -} - DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, unsigned AttrSpellingListIndex) { if (DLLImportAttr *Import = D->getAttr()) { @@ -3864,9 +3857,11 @@ DLLExportAttr *Sema::mergeDLLExportAttr(Decl *D, SourceRange Range, return ::new (Context) DLLExportAttr(Range, Context, AttrSpellingListIndex); } -static void handleDLLExportAttr(Sema &S, Decl *D, const AttributeList &Attr) { - unsigned Index = Attr.getAttributeSpellingListIndex(); - DLLExportAttr *NewAttr = S.mergeDLLExportAttr(D, Attr.getRange(), Index); +static void handleDLLAttr(Sema &S, Decl *D, const AttributeList &A) { + unsigned Index = A.getAttributeSpellingListIndex(); + Attr *NewAttr = A.getKind() == AttributeList::AT_DLLExport + ? (Attr *)S.mergeDLLExportAttr(D, A.getRange(), Index) + : (Attr *)S.mergeDLLImportAttr(D, A.getRange(), Index); if (NewAttr) D->addAttr(NewAttr); } @@ -4070,10 +4065,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handleX86ForceAlignArgPointerAttr(S, D, Attr); break; case AttributeList::AT_DLLExport: - handleDLLExportAttr(S, D, Attr); - break; case AttributeList::AT_DLLImport: - handleDLLImportAttr(S, D, Attr); + handleDLLAttr(S, D, Attr); break; case AttributeList::AT_Mips16: handleSimpleAttribute(S, D, Attr); -- cgit v1.2.3