================
@@ -1668,6 +1656,25 @@ static bool checkCommonAttributeFeatures(Sema &S, const
Ty *Node,
return false;
}
+template <typename Ty>
+static bool checkCommonAttributeFeatures(Sema &S, const Ty *Node,
+ const ParsedAttr &A,
+ bool SkipArgCountCheck) {
+ // Run the checks shared with type attributes (language options, target, and
+ // argument count). This also bails on unknown and ignored attributes.
+ if (checkCommonAttributeFeatures(S, A, SkipArgCountCheck))
+ return true;
+ // Check whether the attribute appertains to the given subject.
+ if (!A.diagnoseAppertainsTo(S, Node))
+ return true;
+ // Check whether the attribute is mutually exclusive with other attributes
+ // that have already been applied to the declaration.
+ if (!A.diagnoseMutualExclusion(S, Node))
+ return true;
----------------
tahonermann wrote:
> I spend some time looking at this and I think adding appertainment support
> for types is a bigger task and warrants its own PR.
I agree. I don't see sufficient motivation for us to take that on; not any time
soon anyway.
> I am leaning towards centralizing the checks we can ...
I agree with this too. The direction of the PR is good. Adding additional
overloads of `diagnoseAppertainsTo()` and `diagnoseMutualExclusion()` that
accept a `QualType` will avoid the refactoring of
`checkCommonAttributeFeatures()` while allowing for future extension. In the
meantime, those new functions can just be stubs with a comment like the
existing one for the `diagnoseMutualExclusion(class Sema &S, const Stmt *St)`
overload in `clang/include/clang/Sema/ParsedAttr.h`.
https://github.com/llvm/llvm-project/pull/227421
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits