[clang] b2ce79e - Thread safety analysis: ValueDecl in Project is non-null
Aaron Puchert via cfe-commits
cfe-commits at lists.llvm.org
Sat Sep 5 08:27:02 PDT 2020
Author: Aaron Puchert
Date: 2020-09-05T17:26:12+02:00
New Revision: b2ce79ef66157dd752e3864ece57915e23a73f5d
URL: https://github.com/llvm/llvm-project/commit/b2ce79ef66157dd752e3864ece57915e23a73f5d
DIFF: https://github.com/llvm/llvm-project/commit/b2ce79ef66157dd752e3864ece57915e23a73f5d.diff
LOG: Thread safety analysis: ValueDecl in Project is non-null
The constructor asserts that, use it in the ThreadSafetyAnalyzer.
Also note that the result of a cast<> cannot be null.
Added:
Modified:
clang/lib/Analysis/ThreadSafety.cpp
clang/lib/Analysis/ThreadSafetyCommon.cpp
Removed:
################################################################################
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 1d4aabaaeb57..5b97265a6d8a 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -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;
diff --git a/clang/lib/Analysis/ThreadSafetyCommon.cpp b/clang/lib/Analysis/ThreadSafetyCommon.cpp
index 1b8c55e56d47..aee918576007 100644
--- a/clang/lib/Analysis/ThreadSafetyCommon.cpp
+++ b/clang/lib/Analysis/ThreadSafetyCommon.cpp
@@ -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) {
More information about the cfe-commits
mailing list