Skip to content

Commit

Permalink
Thread safety analysis: ValueDecl in Project is non-null
Browse files Browse the repository at this point in the history
The constructor asserts that, use it in the ThreadSafetyAnalyzer.
Also note that the result of a cast<> cannot be null.
  • Loading branch information
aaronpuchert committed Sep 5, 2020
1 parent 9dcc82f commit b2ce79e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
5 changes: 2 additions & 3 deletions clang/lib/Analysis/ThreadSafety.cpp
Expand Up @@ -1277,9 +1277,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;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Analysis/ThreadSafetyCommon.cpp
Expand Up @@ -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) {
Expand Down

0 comments on commit b2ce79e

Please sign in to comment.