/// declaration. Returns true if diagnosed.
template <typename AttrTy>
static bool checkAttrMutualExclusion(Sema &S, Decl *D,
- const AttributeList &Attr,
- const char *OtherName) {
- // FIXME: it would be nice if OtherName did not have to be passed in, but was
- // instead determined based on the AttrTy template parameter.
- if (D->hasAttr<AttrTy>()) {
+ const AttributeList &Attr) {
+ if (AttrTy *A = D->getAttr<AttrTy>()) {
S.Diag(Attr.getLoc(), diag::err_attributes_are_not_compatible)
- << Attr.getName() << OtherName;
+ << Attr.getName() << A;
return true;
}
return false;
}
static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
- if (checkAttrMutualExclusion<HotAttr>(S, D, Attr, "hot"))
+ if (checkAttrMutualExclusion<HotAttr>(S, D, Attr))
return;
D->addAttr(::new (S.Context) ColdAttr(Attr.getRange(), S.Context,
}
static void handleHotAttr(Sema &S, Decl *D, const AttributeList &Attr) {
- if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr, "cold"))
+ if (checkAttrMutualExclusion<ColdAttr>(S, D, Attr))
return;
D->addAttr(::new (S.Context) HotAttr(Attr.getRange(), S.Context,
static void handleCFAuditedTransferAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
- if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr,
- "cf_unknown_transfer"))
+ if (checkAttrMutualExclusion<CFUnknownTransferAttr>(S, D, Attr))
return;
D->addAttr(::new (S.Context)
static void handleCFUnknownTransferAttr(Sema &S, Decl *D,
const AttributeList &Attr) {
- if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr,
- "cf_audited_transfer"))
+ if (checkAttrMutualExclusion<CFAuditedTransferAttr>(S, D, Attr))
return;
D->addAttr(::new (S.Context)