mirror of https://github.com/microsoft/clang.git
Thread safety analysis no longer hands when analyzing a self-referencing initializer.
This fixes PR38640. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@340636 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
3ad50fd19c
commit
8e7c1967e0
|
@ -1656,6 +1656,9 @@ void BuildLockset::checkAccess(const Expr *Exp, AccessKind AK,
|
|||
const auto *VD = dyn_cast<VarDecl>(DRE->getDecl()->getCanonicalDecl());
|
||||
if (VD && VD->isLocalVarDecl() && VD->getType()->isReferenceType()) {
|
||||
if (const auto *E = VD->getInit()) {
|
||||
// Guard against self-initialization. e.g., int &i = i;
|
||||
if (E == Exp)
|
||||
break;
|
||||
Exp = E;
|
||||
continue;
|
||||
}
|
||||
|
|
|
@ -5503,3 +5503,11 @@ namespace ReturnScopedLockable {
|
|||
return ptr->f();
|
||||
}
|
||||
}
|
||||
|
||||
namespace PR38640 {
|
||||
void f() {
|
||||
// Self-referencing assignment previously caused an infinite loop when thread
|
||||
// safety analysis was enabled.
|
||||
int &i = i; // expected-warning {{reference 'i' is not yet bound to a value when used within its own initialization}}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue