forked from OSchip/llvm-project
Thread safety analysis: Nullability improvements in TIL, NFCI
The constructor of Project asserts that the contained ValueDecl is not null, use that in the ThreadSafetyAnalyzer. In the case of LiteralPtr it's the other way around. Also dyn_cast<> is sufficient if we know something isn't null.
This commit is contained in:
parent
5250a03a99
commit
b296c64e64
|
@ -634,7 +634,9 @@ typename V::R_SExpr Literal::traverse(V &Vs, typename V::R_Ctx Ctx) {
|
|||
/// At compile time, pointer literals are represented by symbolic names.
|
||||
class LiteralPtr : public SExpr {
|
||||
public:
|
||||
LiteralPtr(const ValueDecl *D) : SExpr(COP_LiteralPtr), Cvdecl(D) {}
|
||||
LiteralPtr(const ValueDecl *D) : SExpr(COP_LiteralPtr), Cvdecl(D) {
|
||||
assert(D && "ValueDecl must not be null");
|
||||
}
|
||||
LiteralPtr(const LiteralPtr &) = default;
|
||||
|
||||
static bool classof(const SExpr *E) { return E->opcode() == COP_LiteralPtr; }
|
||||
|
|
|
@ -1279,9 +1279,8 @@ bool ThreadSafetyAnalyzer::inCurrentScope(const CapabilityExpr &CapE) {
|
|||
if (const auto *P = dyn_cast<til::Project>(SExp)) {
|
||||
if (!CurrentMethod)
|
||||
return false;
|
||||
const auto *VD = P->clangDecl();
|
||||
if (VD)
|
||||
return VD->getDeclContext() == CurrentMethod->getDeclContext();
|
||||
const ValueDecl *VD = P->clangDecl();
|
||||
return VD->getDeclContext() == CurrentMethod->getDeclContext();
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
@ -185,7 +185,7 @@ CapabilityExpr SExprBuilder::translateAttrExpr(const Expr *AttrExp,
|
|||
return CapabilityExpr(nullptr, false);
|
||||
|
||||
// Hack to deal with smart pointers -- strip off top-level pointer casts.
|
||||
if (const auto *CE = dyn_cast_or_null<til::Cast>(E)) {
|
||||
if (const auto *CE = dyn_cast<til::Cast>(E)) {
|
||||
if (CE->castOpcode() == til::CAST_objToPtr)
|
||||
return CapabilityExpr(CE->expr(), Neg);
|
||||
}
|
||||
|
@ -274,7 +274,7 @@ til::SExpr *SExprBuilder::translateDeclRefExpr(const DeclRefExpr *DRE,
|
|||
const auto *VD = cast<ValueDecl>(DRE->getDecl()->getCanonicalDecl());
|
||||
|
||||
// Function parameters require substitution and/or renaming.
|
||||
if (const auto *PV = dyn_cast_or_null<ParmVarDecl>(VD)) {
|
||||
if (const auto *PV = dyn_cast<ParmVarDecl>(VD)) {
|
||||
unsigned I = PV->getFunctionScopeIndex();
|
||||
const DeclContext *D = PV->getDeclContext();
|
||||
if (Ctx && Ctx->FunArgs) {
|
||||
|
|
Loading…
Reference in New Issue