summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2014-01-03 16:23:46 +0000
committerAaron Ballman <aaron@aaronballman.com>2014-01-03 16:23:46 +0000
commit2cfbc00506734a4b67cdc5c9549344fb7659c4d6 (patch)
tree673084a0100a676d785cd24a1ce5fc050ec8a517 /clang/lib/Sema/SemaDeclAttr.cpp
parentfc58987f00ff261304d33028f0a98957c9ed79fb (diff)
downloadbcm5719-llvm-2cfbc00506734a4b67cdc5c9549344fb7659c4d6.tar.gz
bcm5719-llvm-2cfbc00506734a4b67cdc5c9549344fb7659c4d6.zip
Simplifying the mutual exclusion check now that the diagnostics engine knows how to handle Attr objects directly. Updates an associated test case due to the attribute name being properly quoted again.
llvm-svn: 198424
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp19
1 files changed, 7 insertions, 12 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index dbbd4a16248..6b23dd66911 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -245,13 +245,10 @@ static bool checkUInt32Argument(Sema &S, const AttributeList &Attr,
/// 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;
@@ -1428,7 +1425,7 @@ static void handleAliasAttr(Sema &S, Decl *D, const AttributeList &Attr) {
}
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,
@@ -1436,7 +1433,7 @@ static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {
}
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,
@@ -3562,8 +3559,7 @@ static void handleObjCRequiresSuperAttr(Sema &S, Decl *D,
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)
@@ -3573,8 +3569,7 @@ static void handleCFAuditedTransferAttr(Sema &S, Decl *D,
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)
OpenPOWER on IntegriCloud