diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-04-06 20:02:30 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-04-06 20:02:30 +0000 |
commit | 481d5abf453adb26c28286c72fcbb9cd90df2c9e (patch) | |
tree | dca94135653200e3585364a0e5fe75ad15b0e85e /clang/lib/Sema/SemaDeclAttr.cpp | |
parent | 24086bc93b9489fb28eab1604d32c640f4bed464 (diff) | |
download | bcm5719-llvm-481d5abf453adb26c28286c72fcbb9cd90df2c9e.tar.gz bcm5719-llvm-481d5abf453adb26c28286c72fcbb9cd90df2c9e.zip |
Thread safety analysis: downgraded requirement that mutex expressions refer to a lockable type from error to warning.
llvm-svn: 154198
Diffstat (limited to 'clang/lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | clang/lib/Sema/SemaDeclAttr.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/clang/lib/Sema/SemaDeclAttr.cpp b/clang/lib/Sema/SemaDeclAttr.cpp index 77809e153f1..5c6ddd2cb97 100644 --- a/clang/lib/Sema/SemaDeclAttr.cpp +++ b/clang/lib/Sema/SemaDeclAttr.cpp @@ -272,24 +272,25 @@ static const RecordType *getRecordType(QualType QT) { /// \brief Thread Safety Analysis: Checks that the passed in RecordType /// resolves to a lockable object. May flag an error. -static bool checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr, - const RecordType *RT) { - // Flag error if could not get record type for this argument. +static void checkForLockableRecord(Sema &S, Decl *D, const AttributeList &Attr, + QualType Ty) { + const RecordType *RT = getRecordType(Ty); + + // Warn if could not get record type for this argument. if (!RT) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_class) - << Attr.getName(); - return false; + S.Diag(Attr.getLoc(), diag::warn_attribute_argument_not_class) + << Attr.getName() << Ty.getAsString(); + return; } // Don't check for lockable if the class hasn't been defined yet. if (RT->isIncompleteType()) - return true; - // Flag error if the type is not lockable. + return; + // Warn if the type is not lockable. if (!RT->getDecl()->getAttr<LockableAttr>()) { - S.Diag(Attr.getLoc(), diag::err_attribute_argument_not_lockable) - << Attr.getName(); - return false; + S.Diag(Attr.getLoc(), diag::warn_attribute_argument_not_lockable) + << Attr.getName() << Ty.getAsString(); + return; } - return true; } /// \brief Thread Safety Analysis: Checks that all attribute arguments, starting @@ -331,12 +332,10 @@ static bool checkAttrArgsAreLockableObjs(Sema &S, Decl *D, return false; } ArgTy = FD->getParamDecl(ParamIdxFromZero)->getType(); - RT = getRecordType(ArgTy); } } - if (!checkForLockableRecord(S, D, Attr, RT)) - return false; + checkForLockableRecord(S, D, Attr, ArgTy); Args.push_back(ArgExp); } @@ -394,9 +393,7 @@ static void handleGuardedByAttr(Sema &S, Decl *D, const AttributeList &Attr, return; if (!Arg->isTypeDependent()) { - if (!checkForLockableRecord(S, D, Attr, getRecordType(Arg->getType()))) - return; - // FIXME -- semantic checks for dependent attributes + checkForLockableRecord(S, D, Attr, Arg->getType()); } if (pointer) @@ -481,7 +478,7 @@ static void handleAcquireOrderAttr(Sema &S, Decl *D, const AttributeList &Attr, if (!QT->isDependentType()) { const RecordType *RT = getRecordType(QT); if (!RT || !RT->getDecl()->getAttr<LockableAttr>()) { - S.Diag(Attr.getLoc(), diag::err_attribute_decl_not_lockable) + S.Diag(Attr.getLoc(), diag::warn_attribute_decl_not_lockable) << Attr.getName(); return; } @@ -651,8 +648,7 @@ static void handleLockReturnedAttr(Sema &S, Decl *D, return; // check that the argument is lockable object - if (!checkForLockableRecord(S, D, Attr, getRecordType(Arg->getType()))) - return; + checkForLockableRecord(S, D, Attr, Arg->getType()); D->addAttr(::new (S.Context) LockReturnedAttr(Attr.getRange(), S.Context, Arg)); } |