diff options
author | Aaron Ballman <aaron@aaronballman.com> | 2013-11-27 19:35:27 +0000 |
---|---|---|
committer | Aaron Ballman <aaron@aaronballman.com> | 2013-11-27 19:35:27 +0000 |
commit | 57ede3bd8087a128958c1f68b5cd619bae1a2614 (patch) | |
tree | cfb3621efe87e8ec2a834b5e4042d6635454cffb /clang/lib | |
parent | 745bd85c6a62c8292fabeb87eb2c7336e912f21e (diff) | |
download | llvm-57ede3bd8087a128958c1f68b5cd619bae1a2614.zip llvm-57ede3bd8087a128958c1f68b5cd619bae1a2614.tar.gz llvm-57ede3bd8087a128958c1f68b5cd619bae1a2614.tar.bz2 |
Converts the lockable attributes to use the simple attribute handler because the semantic checking was already automated.
llvm-svn: 195866
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 35 |
1 files changed, 2 insertions, 33 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 0c3a257..f7d8fa7 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -620,35 +620,6 @@ static void handlePtGuardedByAttr(Sema &S, Decl *D, S.Context, Arg)); } -static bool checkLockableAttrCommon(Sema &S, Decl *D, - const AttributeList &Attr) { - // FIXME: Lockable structs for C code. - if (!isa<RecordDecl>(D)) { - S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) - << Attr.getName() << ExpectedStructOrUnionOrClass; - return false; - } - - return true; -} - -static void handleLockableAttr(Sema &S, Decl *D, const AttributeList &Attr) { - if (!checkLockableAttrCommon(S, D, Attr)) - return; - - D->addAttr(::new (S.Context) LockableAttr(Attr.getRange(), S.Context)); -} - -static void handleScopedLockableAttr(Sema &S, Decl *D, - const AttributeList &Attr) { - if (!checkLockableAttrCommon(S, D, Attr)) - return; - - D->addAttr(::new (S.Context) - ScopedLockableAttr(Attr.getRange(), S.Context, - Attr.getAttributeSpellingListIndex())); -} - static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D, const AttributeList &Attr, SmallVectorImpl<Expr *> &Args) { @@ -4357,8 +4328,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handlePtGuardedVarAttr(S, D, Attr); break; case AttributeList::AT_ScopedLockable: - handleScopedLockableAttr(S, D, Attr); - break; + handleSimpleAttribute<ScopedLockableAttr>(S, D, Attr); break; case AttributeList::AT_NoSanitizeAddress: handleSimpleAttribute<NoSanitizeAddressAttr>(S, D, Attr); break; @@ -4372,8 +4342,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, handleSimpleAttribute<NoSanitizeMemoryAttr>(S, D, Attr); break; case AttributeList::AT_Lockable: - handleLockableAttr(S, D, Attr); - break; + handleSimpleAttribute<LockableAttr>(S, D, Attr); break; case AttributeList::AT_GuardedBy: handleGuardedByAttr(S, D, Attr); break; |