aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/Analysis/ThreadSafety.cpp
diff options
context:
space:
mode:
authorTimm Bäder <tbaeder@redhat.com>2023-06-27 13:06:01 +0200
committerTimm Bäder <tbaeder@redhat.com>2023-06-27 13:06:27 +0200
commit0243a76f53abbf0bfa69e0893a4a9c8b9d926284 (patch)
tree1d50ff6291743a290008c0f4b9da4ae4ef786ccf /clang/lib/Analysis/ThreadSafety.cpp
parentbc81791e0702dc12f78825da427a285ad566542d (diff)
downloadllvm-0243a76f53abbf0bfa69e0893a4a9c8b9d926284.zip
llvm-0243a76f53abbf0bfa69e0893a4a9c8b9d926284.tar.gz
llvm-0243a76f53abbf0bfa69e0893a4a9c8b9d926284.tar.bz2
Revert "[clang][CFG][NFC] A few smaller cleanups"
This reverts commit 173df3dd5f9a812b07f9866965f4e92a982a3fca. Looks like this wasn't as innocent as it seemed: https://lab.llvm.org/buildbot#builders/38/builds/12982
Diffstat (limited to 'clang/lib/Analysis/ThreadSafety.cpp')
-rw-r--r--clang/lib/Analysis/ThreadSafety.cpp26
1 files changed, 13 insertions, 13 deletions
diff --git a/clang/lib/Analysis/ThreadSafety.cpp b/clang/lib/Analysis/ThreadSafety.cpp
index 1dc35ed..087994e 100644
--- a/clang/lib/Analysis/ThreadSafety.cpp
+++ b/clang/lib/Analysis/ThreadSafety.cpp
@@ -608,7 +608,7 @@ void VarMapBuilder::VisitDeclStmt(const DeclStmt *S) {
bool modifiedCtx = false;
const DeclGroupRef DGrp = S->getDeclGroup();
for (const auto *D : DGrp) {
- if (const auto *VD = dyn_cast_if_present<VarDecl>(D)) {
+ if (const auto *VD = dyn_cast_or_null<VarDecl>(D)) {
const Expr *E = VD->getInit();
// Add local variables with trivial type to the variable map
@@ -1347,9 +1347,9 @@ void ThreadSafetyAnalyzer::getMutexIDs(CapExprSet &Mtxs, AttrType *Attr,
Expr *BrE, bool Neg) {
// Find out which branch has the lock
bool branch = false;
- if (const auto *BLE = dyn_cast_if_present<CXXBoolLiteralExpr>(BrE))
+ if (const auto *BLE = dyn_cast_or_null<CXXBoolLiteralExpr>(BrE))
branch = BLE->getValue();
- else if (const auto *ILE = dyn_cast_if_present<IntegerLiteral>(BrE))
+ else if (const auto *ILE = dyn_cast_or_null<IntegerLiteral>(BrE))
branch = ILE->getValue().getBoolValue();
int branchnum = branch ? 0 : 1;
@@ -1472,7 +1472,7 @@ void ThreadSafetyAnalyzer::getEdgeLockset(FactSet& Result,
if (!Exp)
return;
- auto *FunDecl = dyn_cast_if_present<NamedDecl>(Exp->getCalleeDecl());
+ auto *FunDecl = dyn_cast_or_null<NamedDecl>(Exp->getCalleeDecl());
if(!FunDecl || !FunDecl->hasAttrs())
return;
@@ -1787,15 +1787,15 @@ void BuildLockset::handleCall(const Expr *Exp, const NamedDecl *D,
assert(!Self);
const auto *TagT = Exp->getType()->getAs<TagType>();
if (TagT && Exp->isPRValue()) {
- auto [ThisPtr, DiagType] =
+ std::pair<til::LiteralPtr *, StringRef> Placeholder =
Analyzer->SxBuilder.createThisPlaceholder(Exp);
[[maybe_unused]] auto inserted =
- ConstructedObjects.insert({Exp, ThisPtr});
+ ConstructedObjects.insert({Exp, Placeholder.first});
assert(inserted.second && "Are we visiting the same expression again?");
if (isa<CXXConstructExpr>(Exp))
- Self = ThisPtr;
+ Self = Placeholder.first;
if (TagT->getDecl()->hasAttr<ScopedLockableAttr>())
- Scp = CapabilityExpr(ThisPtr, DiagType, false);
+ Scp = CapabilityExpr(Placeholder.first, Placeholder.second, false);
}
assert(Loc.isInvalid());
@@ -2098,7 +2098,7 @@ void BuildLockset::VisitDeclStmt(const DeclStmt *S) {
LVarCtx = Analyzer->LocalVarMap.getNextContext(CtxIndex, S, LVarCtx);
for (auto *D : S->getDeclGroup()) {
- if (auto *VD = dyn_cast_if_present<VarDecl>(D)) {
+ if (auto *VD = dyn_cast_or_null<VarDecl>(D)) {
const Expr *E = VD->getInit();
if (!E)
continue;
@@ -2215,10 +2215,10 @@ static bool neverReturns(const CFGBlock *B) {
return false;
CFGElement Last = B->back();
- if (std::optional<CFGStmt> S = Last.getAs<CFGStmt>();
- isa<CXXThrowExpr>(S->getStmt()))
- return true;
-
+ if (std::optional<CFGStmt> S = Last.getAs<CFGStmt>()) {
+ if (isa<CXXThrowExpr>(S->getStmt()))
+ return true;
+ }
return false;
}