diff options
author | DeLesley Hutchins <delesley@google.com> | 2015-09-03 21:14:22 +0000 |
---|---|---|
committer | DeLesley Hutchins <delesley@google.com> | 2015-09-03 21:14:22 +0000 |
commit | 445a31cd4b978e5af33b236272bd5a085a482053 (patch) | |
tree | 8e34cd8cef5b9e841c98abde7a791d367305d7f4 /clang/lib/Analysis/ThreadSafety.cpp | |
parent | 99d95328d6af9b99a607aec6ece9a950c38c8913 (diff) | |
download | llvm-445a31cd4b978e5af33b236272bd5a085a482053.zip llvm-445a31cd4b978e5af33b236272bd5a085a482053.tar.gz llvm-445a31cd4b978e5af33b236272bd5a085a482053.tar.bz2 |
Thread safety analysis: the NO_THREAD_SAFETY_ANALYSIS attribute will now
disable checking of arguments to the function, which is done by
-Wthread-safety-reference.
llvm-svn: 246806
Diffstat (limited to 'clang/lib/Analysis/ThreadSafety.cpp')
-rw-r--r-- | clang/lib/Analysis/ThreadSafety.cpp | 58 |
1 files changed, 33 insertions, 25 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp index e2c6ab5..922b157a 100644 --- a/clang/lib/Analysis/ThreadSafety.cpp +++ b/clang/lib/Analysis/ThreadSafety.cpp @@ -1926,34 +1926,42 @@ void BuildLockset::VisitCallExpr(CallExpr *Exp) { } } - if (ExamineArgs) { if (FunctionDecl *FD = Exp->getDirectCallee()) { - unsigned Fn = FD->getNumParams(); - unsigned Cn = Exp->getNumArgs(); - unsigned Skip = 0; - - unsigned i = 0; - if (OperatorFun) { - if (isa<CXXMethodDecl>(FD)) { - // First arg in operator call is implicit self argument, - // and doesn't appear in the FunctionDecl. - Skip = 1; - Cn--; - } else { - // Ignore the first argument of operators; it's been checked above. - i = 1; + + // NO_THREAD_SAFETY_ANALYSIS does double duty here. Normally it + // only turns off checking within the body of a function, but we also + // use it to turn off checking in arguments to the function. This + // could result in some false negatives, but the alternative is to + // create yet another attribute. + // + if (!FD->hasAttr<NoThreadSafetyAnalysisAttr>()) { + unsigned Fn = FD->getNumParams(); + unsigned Cn = Exp->getNumArgs(); + unsigned Skip = 0; + + unsigned i = 0; + if (OperatorFun) { + if (isa<CXXMethodDecl>(FD)) { + // First arg in operator call is implicit self argument, + // and doesn't appear in the FunctionDecl. + Skip = 1; + Cn--; + } else { + // Ignore the first argument of operators; it's been checked above. + i = 1; + } + } + // Ignore default arguments + unsigned n = (Fn < Cn) ? Fn : Cn; + + for (; i < n; ++i) { + ParmVarDecl* Pvd = FD->getParamDecl(i); + Expr* Arg = Exp->getArg(i+Skip); + QualType Qt = Pvd->getType(); + if (Qt->isReferenceType()) + checkAccess(Arg, AK_Read, POK_PassByRef); } - } - // Ignore default arguments - unsigned n = (Fn < Cn) ? Fn : Cn; - - for (; i < n; ++i) { - ParmVarDecl* Pvd = FD->getParamDecl(i); - Expr* Arg = Exp->getArg(i+Skip); - QualType Qt = Pvd->getType(); - if (Qt->isReferenceType()) - checkAccess(Arg, AK_Read, POK_PassByRef); } } } |