diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2014-03-20 16:02:49 +0000 |
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2014-03-20 16:02:49 +0000 |
| commit | 18d85aed3974564dc636b2fba6215ade85a00370 (patch) | |
| tree | 0897aa1798f0fbee51ca45fd5c0f90001266357b /clang/lib/Sema | |
| parent | 202113ff5bee7c893fa6b338db6abfedc0d5ff6f (diff) | |
| download | bcm5719-llvm-18d85aed3974564dc636b2fba6215ade85a00370.tar.gz bcm5719-llvm-18d85aed3974564dc636b2fba6215ade85a00370.zip | |
Replacing the exclusive_lock_function, shared_lock_function and unlock_function attributes with the acquire_capability and release_capability attributes. The old spellings will continue to work, but the underlying semantic attributes have been replaced.
Downgraded the capability diagnostics from error to warning to match the desired behavior, and updated the existing test cases.
llvm-svn: 204350
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 73 | ||||
| -rw-r--r-- | clang/lib/Sema/SemaDeclCXX.cpp | 8 |
2 files changed, 7 insertions, 74 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 26d7ae96671..29aca3370dc 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -599,33 +599,6 @@ static bool checkLockFunAttrCommon(Sema &S, Decl *D, return true; } -static void handleSharedLockFunctionAttr(Sema &S, Decl *D, - const AttributeList &Attr) { - SmallVector<Expr*, 1> Args; - if (!checkLockFunAttrCommon(S, D, Attr, Args)) - return; - - unsigned Size = Args.size(); - Expr **StartArg = Size == 0 ? 0 : &Args[0]; - D->addAttr(::new (S.Context) - SharedLockFunctionAttr(Attr.getRange(), S.Context, StartArg, Size, - Attr.getAttributeSpellingListIndex())); -} - -static void handleExclusiveLockFunctionAttr(Sema &S, Decl *D, - const AttributeList &Attr) { - SmallVector<Expr*, 1> Args; - if (!checkLockFunAttrCommon(S, D, Attr, Args)) - return; - - unsigned Size = Args.size(); - Expr **StartArg = Size == 0 ? 0 : &Args[0]; - D->addAttr(::new (S.Context) - ExclusiveLockFunctionAttr(Attr.getRange(), S.Context, - StartArg, Size, - Attr.getAttributeSpellingListIndex())); -} - static void handleAssertSharedLockAttr(Sema &S, Decl *D, const AttributeList &Attr) { SmallVector<Expr*, 1> Args; @@ -698,20 +671,6 @@ static void handleExclusiveTrylockFunctionAttr(Sema &S, Decl *D, Attr.getAttributeSpellingListIndex())); } -static void handleUnlockFunAttr(Sema &S, Decl *D, - const AttributeList &Attr) { - // zero or more arguments ok - // check that all arguments are lockable objects - SmallVector<Expr*, 1> Args; - checkAttrArgsAreLockableObjs(S, D, Attr, Args, 0, /*ParamIdxOk=*/true); - unsigned Size = Args.size(); - Expr **StartArg = Size == 0 ? 0 : &Args[0]; - - D->addAttr(::new (S.Context) - UnlockFunctionAttr(Attr.getRange(), S.Context, StartArg, Size, - Attr.getAttributeSpellingListIndex())); -} - static void handleLockReturnedAttr(Sema &S, Decl *D, const AttributeList &Attr) { // check that the argument is lockable object @@ -3912,12 +3871,7 @@ static void handleAssertCapabilityAttr(Sema &S, Decl *D, static void handleAcquireCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) { SmallVector<Expr*, 1> Args; - if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) - return; - - // Check that all arguments are lockable objects. - checkAttrArgsAreLockableObjs(S, D, Attr, Args); - if (Args.empty()) + if (!checkLockFunAttrCommon(S, D, Attr, Args)) return; D->addAttr(::new (S.Context) AcquireCapabilityAttr(Attr.getRange(), @@ -3942,19 +3896,13 @@ static void handleTryAcquireCapabilityAttr(Sema &S, Decl *D, static void handleReleaseCapabilityAttr(Sema &S, Decl *D, const AttributeList &Attr) { - SmallVector<Expr*, 1> Args; - if (!checkAttributeAtLeastNumArgs(S, Attr, 1)) - return; - // Check that all arguments are lockable objects. - checkAttrArgsAreLockableObjs(S, D, Attr, Args); - if (Args.empty()) - return; + SmallVector<Expr *, 1> Args; + checkAttrArgsAreLockableObjs(S, D, Attr, Args, 0, true); - D->addAttr(::new (S.Context) ReleaseCapabilityAttr(Attr.getRange(), - S.Context, - Args.data(), Args.size(), - Attr.getAttributeSpellingListIndex())); + D->addAttr(::new (S.Context) ReleaseCapabilityAttr( + Attr.getRange(), S.Context, Args.data(), Args.size(), + Attr.getAttributeSpellingListIndex())); } static void handleRequiresCapabilityAttr(Sema &S, Decl *D, @@ -4417,9 +4365,6 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, case AttributeList::AT_PtGuardedBy: handlePtGuardedByAttr(S, D, Attr); break; - case AttributeList::AT_ExclusiveLockFunction: - handleExclusiveLockFunctionAttr(S, D, Attr); - break; case AttributeList::AT_ExclusiveTrylockFunction: handleExclusiveTrylockFunctionAttr(S, D, Attr); break; @@ -4429,15 +4374,9 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D, case AttributeList::AT_LocksExcluded: handleLocksExcludedAttr(S, D, Attr); break; - case AttributeList::AT_SharedLockFunction: - handleSharedLockFunctionAttr(S, D, Attr); - break; case AttributeList::AT_SharedTrylockFunction: handleSharedTrylockFunctionAttr(S, D, Attr); break; - case AttributeList::AT_UnlockFunction: - handleUnlockFunAttr(S, D, Attr); - break; case AttributeList::AT_AcquiredBefore: handleAcquiredBeforeAttr(S, D, Attr); break; diff --git a/clang/lib/Sema/SemaDeclCXX.cpp b/clang/lib/Sema/SemaDeclCXX.cpp index fc37727344c..5abaab8883a 100644 --- a/clang/lib/Sema/SemaDeclCXX.cpp +++ b/clang/lib/Sema/SemaDeclCXX.cpp @@ -12597,19 +12597,13 @@ bool Sema::checkThisInStaticMemberFunctionAttributes(CXXMethodDecl *Method) { Args = ArrayRef<Expr *>(AA->args_begin(), AA->args_size()); else if (const auto *AB = dyn_cast<AcquiredBeforeAttr>(A)) Args = ArrayRef<Expr *>(AB->args_begin(), AB->args_size()); - else if (const auto *ELF = dyn_cast<ExclusiveLockFunctionAttr>(A)) - Args = ArrayRef<Expr *>(ELF->args_begin(), ELF->args_size()); - else if (const auto *SLF = dyn_cast<SharedLockFunctionAttr>(A)) - Args = ArrayRef<Expr *>(SLF->args_begin(), SLF->args_size()); else if (const auto *ETLF = dyn_cast<ExclusiveTrylockFunctionAttr>(A)) { Arg = ETLF->getSuccessValue(); Args = ArrayRef<Expr *>(ETLF->args_begin(), ETLF->args_size()); } else if (const auto *STLF = dyn_cast<SharedTrylockFunctionAttr>(A)) { Arg = STLF->getSuccessValue(); Args = ArrayRef<Expr *>(STLF->args_begin(), STLF->args_size()); - } else if (const auto *UF = dyn_cast<UnlockFunctionAttr>(A)) - Args = ArrayRef<Expr *>(UF->args_begin(), UF->args_size()); - else if (const auto *LR = dyn_cast<LockReturnedAttr>(A)) + } else if (const auto *LR = dyn_cast<LockReturnedAttr>(A)) Arg = LR->getArg(); else if (const auto *LE = dyn_cast<LocksExcludedAttr>(A)) Args = ArrayRef<Expr *>(LE->args_begin(), LE->args_size()); |

