Thread-safety analysis: fix bug in expression matching code.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@163656 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
DeLesley Hutchins 2012-09-11 23:04:49 +00:00
Родитель 10d65cd8c8
Коммит f9ee0bacd2
2 изменённых файлов: 43 добавлений и 2 удалений

Просмотреть файл

@ -454,7 +454,6 @@ private:
void buildSExprFromExpr(Expr *MutexExp, Expr *DeclExp, const NamedDecl *D) {
CallingContext CallCtx(D);
if (MutexExp) {
if (StringLiteral* SLit = dyn_cast<StringLiteral>(MutexExp)) {
if (SLit->getString() == StringRef("*"))
@ -562,7 +561,9 @@ public:
bool matches(const SExpr &Other, unsigned i = 0, unsigned j = 0) const {
if (NodeVec[i].matches(Other.NodeVec[j])) {
unsigned n = NodeVec[i].arity();
unsigned ni = NodeVec[i].arity();
unsigned nj = Other.NodeVec[j].arity();
unsigned n = (ni < nj) ? ni : nj;
bool Result = true;
unsigned ci = i+1; // first child of i
unsigned cj = j+1; // first child of j

Просмотреть файл

@ -3341,3 +3341,43 @@ public:
} // end namespace TemplateLockReturned
namespace ExprMatchingBugFix {
class Foo {
public:
Mutex mu_;
};
class Bar {
public:
bool c;
Foo* foo;
Bar(Foo* f) : foo(f) { }
struct Nested {
Foo* foo;
Nested(Foo* f) : foo(f) { }
void unlockFoo() UNLOCK_FUNCTION(&Foo::mu_);
};
void test();
};
void Bar::test() {
foo->mu_.Lock();
if (c) {
Nested *n = new Nested(foo);
n->unlockFoo();
}
else {
foo->mu_.Unlock();
}
}
}; // end namespace ExprMatchingBugfix