diff options
| author | Aaron Ballman <aaron@aaronballman.com> | 2013-12-02 15:02:49 +0000 | 
|---|---|---|
| committer | Aaron Ballman <aaron@aaronballman.com> | 2013-12-02 15:02:49 +0000 | 
| commit | e61b8b816a6b0cd9c4f901e95763cc4a026af6c4 (patch) | |
| tree | b8f405fbf32fc6b3218f7c21e151ed7d3812103d /clang/lib/Sema | |
| parent | af7131d0a237c525a29956c4f72068720e42a576 (diff) | |
| download | bcm5719-llvm-e61b8b816a6b0cd9c4f901e95763cc4a026af6c4.tar.gz bcm5719-llvm-e61b8b816a6b0cd9c4f901e95763cc4a026af6c4.zip | |
Replacing custom subject application logic with table-generated logic. Affects: guarded_var, pt_guarded_var, guarded_by, pt_guarded_by, acquired_after and acquired_before. No functional change intended.
llvm-svn: 196105
Diffstat (limited to 'clang/lib/Sema')
| -rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 55 | 
1 files changed, 2 insertions, 53 deletions
| diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 7c5e066cc92..9f34fa9498f 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -337,17 +337,6 @@ static void handleSimpleAttribute(Sema &S, Decl *D,                                          Attr.getAttributeSpellingListIndex()));  } -/// -/// \brief Check if passed in Decl is a field or potentially shared global var -/// \return true if the Decl is a field or potentially shared global variable -/// -static bool mayBeSharedVariable(const Decl *D) { -  if (const VarDecl *vd = dyn_cast<VarDecl>(D)) -    return vd->hasGlobalStorage() && !vd->getTLSKind(); - -  return true; -} -  /// \brief Check if the passed-in expression is of type int or bool.  static bool isIntOrBool(Expr *Exp) {    QualType QT = Exp->getType(); @@ -543,32 +532,8 @@ static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D,  // least add some helper functions to check most argument patterns (#  // and types of args). -static bool checkGuardedVarAttrCommon(Sema &S, Decl *D, -                                      const AttributeList &Attr) { -  // D must be either a member field or global (potentially shared) variable. -  if (!mayBeSharedVariable(D)) { -    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) -      << Attr.getName() << ExpectedFieldOrGlobalVar; -    return false; -  } - -  return true; -} - -static void handleGuardedVarAttr(Sema &S, Decl *D, const AttributeList &Attr) { -  if (!checkGuardedVarAttrCommon(S, D, Attr)) -    return; - -  D->addAttr(::new (S.Context) -             GuardedVarAttr(Attr.getRange(), S.Context, -                            Attr.getAttributeSpellingListIndex())); -} -  static void handlePtGuardedVarAttr(Sema &S, Decl *D,                                     const AttributeList &Attr) { -  if (!checkGuardedVarAttrCommon(S, D, Attr)) -    return; -    if (!threadSafetyCheckIsPointer(S, D, Attr))      return; @@ -580,13 +545,6 @@ static void handlePtGuardedVarAttr(Sema &S, Decl *D,  static bool checkGuardedByAttrCommon(Sema &S, Decl *D,                                       const AttributeList &Attr,                                       Expr* &Arg) { -  // D must be either a member field or global (potentially shared) variable. -  if (!mayBeSharedVariable(D)) { -    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) -      << Attr.getName() << ExpectedFieldOrGlobalVar; -    return false; -  } -    SmallVector<Expr*, 1> Args;    // check that all arguments are lockable objects    checkAttrArgsAreLockableObjs(S, D, Attr, Args); @@ -626,16 +584,8 @@ static bool checkAcquireOrderAttrCommon(Sema &S, Decl *D,    if (!checkAttributeAtLeastNumArgs(S, Attr, 1))      return false; -  // D must be either a member field or global (potentially shared) variable. -  ValueDecl *VD = dyn_cast<ValueDecl>(D); -  if (!VD || !mayBeSharedVariable(D)) { -    S.Diag(Attr.getLoc(), diag::warn_attribute_wrong_decl_type) -      << Attr.getName() << ExpectedFieldOrGlobalVar; -    return false; -  } -    // Check that this attribute only applies to lockable types. -  QualType QT = VD->getType(); +  QualType QT = cast<ValueDecl>(D)->getType();    if (!QT->isDependentType()) {      const RecordType *RT = getRecordType(QT);      if (!RT || !RT->getDecl()->getAttr<LockableAttr>()) { @@ -4302,8 +4252,7 @@ static void ProcessDeclAttribute(Sema &S, Scope *scope, Decl *D,      handleAssertSharedLockAttr(S, D, Attr);      break;    case AttributeList::AT_GuardedVar: -    handleGuardedVarAttr(S, D, Attr); -    break; +    handleSimpleAttribute<GuardedVarAttr>(S, D, Attr); break;    case AttributeList::AT_PtGuardedVar:      handlePtGuardedVarAttr(S, D, Attr);      break; | 

