]> granicus.if.org Git - clang/commitdiff
Replace the custom handling for several attributes; NFC.
authorAaron Ballman <aaron@aaronballman.com>
Sun, 4 Mar 2018 15:32:01 +0000 (15:32 +0000)
committerAaron Ballman <aaron@aaronballman.com>
Sun, 4 Mar 2018 15:32:01 +0000 (15:32 +0000)
These attributes were only customized because of the need to check for attribute mutual exclusion, but we now have the handleSimpleAttributeWithExclusions() helper function to handle these scenarios.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@326675 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Sema/SemaDeclAttr.cpp

index a58726fae5fa928acd95aed54c52ec0e6d2ebc10..b35c3114ff6a92a4e4b09477323fe280a9e38d8a 100644 (file)
@@ -1842,22 +1842,6 @@ static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &AL) {
                                          AL.getAttributeSpellingListIndex()));
 }
 
-static void handleColdAttr(Sema &S, Decl *D, const AttributeList &AL) {
-  if (checkAttrMutualExclusion<HotAttr>(S, D, AL.getRange(), AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context) ColdAttr(AL.getRange(), S.Context,
-                                        AL.getAttributeSpellingListIndex()));
-}
-
-static void handleHotAttr(Sema &S, Decl *D, const AttributeList &AL) {
-  if (checkAttrMutualExclusion<ColdAttr>(S, D, AL.getRange(), AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context) HotAttr(AL.getRange(), S.Context,
-                                       AL.getAttributeSpellingListIndex()));
-}
-
 static void handleTLSModelAttr(Sema &S, Decl *D,
                                const AttributeList &AL) {
   StringRef Model;
@@ -2066,26 +2050,6 @@ static void handleDependencyAttr(Sema &S, Scope *Scope, Decl *D,
                                    AL.getAttributeSpellingListIndex()));
 }
 
-static void handleNotTailCalledAttr(Sema &S, Decl *D,
-                                    const AttributeList &AL) {
-  if (checkAttrMutualExclusion<AlwaysInlineAttr>(S, D, AL.getRange(),
-                                                 AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context) NotTailCalledAttr(
-      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
-}
-
-static void handleDisableTailCallsAttr(Sema &S, Decl *D,
-                                       const AttributeList &AL) {
-  if (checkAttrMutualExclusion<NakedAttr>(S, D, AL.getRange(),
-                                          AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context) DisableTailCallsAttr(
-      AL.getRange(), S.Context, AL.getAttributeSpellingListIndex()));
-}
-
 static void handleUnusedAttr(Sema &S, Decl *D, const AttributeList &AL) {
   bool IsCXX17Attr = AL.isCXX11Attribute() && !AL.getScopeName();
 
@@ -4807,28 +4771,6 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
       Attrs.getRange(), S.Context, Attrs.getAttributeSpellingListIndex()));
 }
 
-static void handleCFAuditedTransferAttr(Sema &S, Decl *D,
-                                        const AttributeList &AL) {
-  if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, AL.getRange(),
-                                                      AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context)
-             CFAuditedTransferAttr(AL.getRange(), S.Context,
-                                   AL.getAttributeSpellingListIndex()));
-}
-
-static void handleCFUnknownTransferAttr(Sema &S, Decl *D,
-                                        const AttributeList &AL) {
-  if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, AL.getRange(),
-                                                      AL.getName()))
-    return;
-
-  D->addAttr(::new (S.Context)
-             CFUnknownTransferAttr(AL.getRange(), S.Context,
-             AL.getAttributeSpellingListIndex()));
-}
-
 static void handleObjCBridgeAttr(Sema &S, Decl *D, const AttributeList &AL) {
   IdentifierLoc *Parm = AL.isArgIdent(0) ? AL.getArgAsIdent(0) : nullptr;
 
@@ -6100,10 +6042,10 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
     handleOwnershipAttr(S, D, AL);
     break;
   case AttributeList::AT_Cold:
-    handleColdAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<ColdAttr, HotAttr>(S, D, AL);
     break;
   case AttributeList::AT_Hot:
-    handleHotAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<HotAttr, ColdAttr>(S, D, AL);
     break;
   case AttributeList::AT_Naked:
     handleNakedAttr(S, D, AL);
@@ -6154,10 +6096,12 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
     handleObjCBoxable(S, D, AL);
     break;
   case AttributeList::AT_CFAuditedTransfer:
-    handleCFAuditedTransferAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<CFAuditedTransferAttr,
+                                        CFUnknownTransferAttr>(S, D, AL);
     break;
   case AttributeList::AT_CFUnknownTransfer:
-    handleCFUnknownTransferAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<CFUnknownTransferAttr,
+                                        CFAuditedTransferAttr>(S, D, AL);
     break;
   case AttributeList::AT_CFConsumed:
   case AttributeList::AT_NSConsumed:
@@ -6225,10 +6169,12 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
     handleSimpleAttribute<ReturnsTwiceAttr>(S, D, AL);
     break;
   case AttributeList::AT_NotTailCalled:
-    handleNotTailCalledAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<NotTailCalledAttr,
+                                        AlwaysInlineAttr>(S, D, AL);
     break;
   case AttributeList::AT_DisableTailCalls:
-    handleDisableTailCallsAttr(S, D, AL);
+    handleSimpleAttributeWithExclusions<DisableTailCallsAttr,
+                                        NakedAttr>(S, D, AL);
     break;
   case AttributeList::AT_Used:
     handleSimpleAttribute<UsedAttr>(S, D, AL);