summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaDeclAttr.cpp
diff options
context:
space:
mode:
authorAaron Ballman <aaron@aaronballman.com>2013-12-21 16:49:29 +0000
committerAaron Ballman <aaron@aaronballman.com>2013-12-21 16:49:29 +0000
commitbf7b1ee385c056b6ec708b6d2bddfff73bd6921a (patch)
tree763a7045dcef316aaaee2f9b1ec08650afe671f7 /clang/lib/Sema/SemaDeclAttr.cpp
parent16f35ea9bba8732cb7bb3a5e566630ab33d995ba (diff)
downloadbcm5719-llvm-bf7b1ee385c056b6ec708b6d2bddfff73bd6921a.tar.gz
bcm5719-llvm-bf7b1ee385c056b6ec708b6d2bddfff73bd6921a.zip
The const and nothrow attributes can be handled by the simple attribute handler. This removes a silent dropping of the attributes when they are duplicated on a Decl.
llvm-svn: 197864
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r--clang/lib/Sema/SemaDeclAttr.cpp28
1 files changed, 4 insertions, 24 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp
index 0532dac34a7..87c38eef415 100644
--- a/clang/lib/Sema/SemaDeclAttr.cpp
+++ b/clang/lib/Sema/SemaDeclAttr.cpp
@@ -2354,28 +2354,6 @@ static void handleSectionAttr(Sema &S, Decl *D, const AttributeList &Attr) {
}
-static void handleNothrowAttr(Sema &S, Decl *D, const AttributeList &Attr) {
- if (NoThrowAttr *Existing = D->getAttr<NoThrowAttr>()) {
- if (Existing->getLocation().isInvalid())
- Existing->setRange(Attr.getRange());
- } else {
- D->addAttr(::new (S.Context)
- NoThrowAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex()));
- }
-}
-
-static void handleConstAttr(Sema &S, Decl *D, const AttributeList &Attr) {
- if (ConstAttr *Existing = D->getAttr<ConstAttr>()) {
- if (Existing->getLocation().isInvalid())
- Existing->setRange(Attr.getRange());
- } else {
- D->addAttr(::new (S.Context)
- ConstAttr(Attr.getRange(), S.Context,
- Attr.getAttributeSpellingListIndex() ));
- }
-}
-
static void handleCleanupAttr(Sema &S, Decl *D, const AttributeList &Attr) {
VarDecl *VD = cast<VarDecl>(D);
if (!VD->hasLocalStorage()) {
@@ -3929,7 +3907,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_Naked:
handleSimpleAttribute<NakedAttr>(S, D, Attr); break;
case AttributeList::AT_NoReturn: handleNoReturnAttr (S, D, Attr); break;
- case AttributeList::AT_NoThrow: handleNothrowAttr (S, D, Attr); break;
+ case AttributeList::AT_NoThrow:
+ handleSimpleAttribute<NoThrowAttr>(S, D, Attr); break;
case AttributeList::AT_CUDAShared:
handleSimpleAttribute<CUDASharedAttr>(S, D, Attr); break;
case AttributeList::AT_VecReturn: handleVecReturnAttr (S, D, Attr); break;
@@ -4027,7 +4006,8 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,
case AttributeList::AT_ObjCNSObject:handleObjCNSObject (S, D, Attr); break;
case AttributeList::AT_Blocks: handleBlocksAttr (S, D, Attr); break;
case AttributeList::AT_Sentinel: handleSentinelAttr (S, D, Attr); break;
- case AttributeList::AT_Const: handleConstAttr (S, D, Attr); break;
+ case AttributeList::AT_Const:
+ handleSimpleAttribute<ConstAttr>(S, D, Attr); break;
case AttributeList::AT_Pure:
handleSimpleAttribute<PureAttr>(S, D, Attr); break;
case AttributeList::AT_Cleanup: handleCleanupAttr (S, D, Attr); break;
OpenPOWER on IntegriCloud