diff options
author | DeLesley Hutchins <delesley@google.com> | 2012-04-23 16:45:01 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2012-04-23 16:45:01 +0000 |
commit | 79747e00e9f6b13b56e91462982d2456d0d9128f (patch) | |
tree | 066a6b3a01741182ccf20f77d92c255db05a56bb /lib/Sema/SemaDeclAttr.cpp | |
parent | e656b8397f05fd1b7c4a735372f79a52f4e32be5 (diff) |
Thread-safety analysis: support new "pointer to member" syntax for
existentially quantified lock expressions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@155357 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Sema/SemaDeclAttr.cpp')
-rw-r--r-- | lib/Sema/SemaDeclAttr.cpp | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/lib/Sema/SemaDeclAttr.cpp b/lib/Sema/SemaDeclAttr.cpp index 843d5a4731..27980bd541 100644 --- a/lib/Sema/SemaDeclAttr.cpp +++ b/lib/Sema/SemaDeclAttr.cpp @@ -313,7 +313,11 @@ static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D, continue; } - if (isa<StringLiteral>(ArgExp)) { + if (StringLiteral *StrLit = dyn_cast<StringLiteral>(ArgExp)) { + // Ignore empty strings without warnings + if (StrLit->getLength() == 0) + continue; + // We allow constant strings to be used as a placeholder for expressions // that are not valid C++ syntax, but warn that they are ignored. S.Diag(Attr.getLoc(), diag::warn_thread_attribute_ignored) << @@ -323,6 +327,14 @@ static void checkAttrArgsAreLockableObjs(Sema &S, Decl *D, QualType ArgTy = ArgExp->getType(); + // A pointer to member expression of the form &MyClass::mu is treated + // specially -- we need to look at the type of the member. + if (UnaryOperator *UOp = dyn_cast<UnaryOperator>(ArgExp)) + if (UOp->getOpcode() == UO_AddrOf) + if (DeclRefExpr *DRE = dyn_cast<DeclRefExpr>(UOp->getSubExpr())) + if (DRE->getDecl()->isCXXInstanceMember()) + ArgTy = DRE->getDecl()->getType(); + // First see if we can just cast to record type, or point to record type. const RecordType *RT = getRecordType(ArgTy); |