Correct the tablegen logic for MutualExclusions attribute checking.
authorAaron Ballman <aaron@aaronballman.com>
Wed, 7 Apr 2021 17:59:54 +0000 (13:59 -0400)
committerAaron Ballman <aaron@aaronballman.com>
Wed, 7 Apr 2021 18:04:08 +0000 (14:04 -0400)
Just because an attribute is a statement attribute doesn't mean it's
not also a declaration attribute. In Clang, there are not currently any
DeclOrStmtAttr attributes that require mutual exclusion checking, but
downstream clients discovered this issue.

clang/utils/TableGen/ClangAttrEmitter.cpp

index 6b76ad8..ececceb 100644 (file)
@@ -3644,10 +3644,12 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
   if (Attr.isSubClassOf("TypeAttr"))
     return;
 
-  // This means the attribute is either a statement attribute or a decl
-  // attribute, find out which.
+  // This means the attribute is either a statement attribute, a decl
+  // attribute, or both; find out which.
   bool CurAttrIsStmtAttr =
       Attr.isSubClassOf("StmtAttr") || Attr.isSubClassOf("DeclOrStmtAttr");
+  bool CurAttrIsDeclAttr =
+      !CurAttrIsStmtAttr || Attr.isSubClassOf("DeclOrStmtAttr");
 
   std::vector<std::string> DeclAttrs, StmtAttrs;
 
@@ -3666,7 +3668,7 @@ static void GenerateMutualExclusionsChecks(const Record &Attr,
 
         if (CurAttrIsStmtAttr)
           StmtAttrs.push_back((AttrToExclude->getName() + "Attr").str());
-        else
+        if (CurAttrIsDeclAttr)
           DeclAttrs.push_back((AttrToExclude->getName() + "Attr").str());
       }
     }