From: Hans Wennborg Date: Tue, 24 Jun 2014 23:57:05 +0000 (+0000) Subject: Merge handleDLLImportAttr and handleDLLExportAttr into one function. X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e82f19c14efcf53954ee19674b57c75f23537e98;p=platform%2Fupstream%2Fllvm.git Merge handleDLLImportAttr and handleDLLExportAttr into one function. llvm-svn: 211647 --- diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 5c868e9..af216d2 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/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);