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 | 83cad4544f8a89fb6a611f330d71d027c238375e (patch) | |
tree | 37a44387fea975d24204da3574c30d53d1c65925 /lib/Sema/SemaDeclAttr.cpp | |
parent | b0f245ccce94a069c9334e51f3c5d502eb2d0215 (diff) |
Thread safety analysis: downgraded requirement that mutex expressions refer to a lockable type from error to warning.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@154198 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 38 |
1 files changed, 17 insertions, 21 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 77809e153f..5c6ddd2cb9 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/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)); } |