"AddImplicitDtors and AddLifetime cannot be used at the same time");
if (BuildOpts.AddImplicitDtors)
- if (const CXXDestructorDecl *DD = dyn_cast_or_null<CXXDestructorDecl>(D))
+ if (const CXXDestructorDecl *DD = dyn_cast_if_present<CXXDestructorDecl>(D))
addImplicitDtorsForDestructor(DD);
// Visit the statements and create the CFG.
// fields. To handle this, make a CFG branch. We only need to add one such
// branch per constructor, since the Standard states that all virtual bases
// shall be initialized before non-virtual bases and direct data members.
- if (const auto *CD = dyn_cast_or_null<CXXConstructorDecl>(D)) {
+ if (const auto *CD = dyn_cast_if_present<CXXConstructorDecl>(D)) {
CFGBlock *VBaseSucc = nullptr;
for (auto *I : llvm::reverse(CD->inits())) {
if (BuildOpts.AddVirtualBaseBranches && !VBaseSucc &&
// If the initializer is an ArrayInitLoopExpr, we want to extract the
// initializer, that's used for each element.
- const auto *AILE = dyn_cast_or_null<ArrayInitLoopExpr>(Init);
+ const auto *AILE = dyn_cast_if_present<ArrayInitLoopExpr>(Init);
findConstructionContexts(
ConstructionContextLayer::create(cfg->getBumpVectorContext(), DS),
// Specially handle logical operators, which have a slightly
// more optimal CFG representation.
if (BinaryOperator *Cond =
- dyn_cast_or_null<BinaryOperator>(C ? C->IgnoreParens() : nullptr))
+ dyn_cast_if_present<BinaryOperator>(C ? C->IgnoreParens() : nullptr))
if (Cond->isLogicalOp()) {
std::tie(EntryConditionBlock, ExitConditionBlock) =
VisitLogicalOperator(Cond, F, BodyBlock, LoopSuccessor);
// If the 'To' has no label or is labeled but the label isn't a
// CaseStmt then filter this edge.
if (const SwitchStmt *S =
- dyn_cast_or_null<SwitchStmt>(From->getTerminatorStmt())) {
+ dyn_cast_if_present<SwitchStmt>(From->getTerminatorStmt())) {
if (S->isAllEnumCasesCovered()) {
const Stmt *L = To->getLabel();
if (!L || !isa<CaseStmt>(L))
bool modifiedCtx = false;
const DeclGroupRef DGrp = S->getDeclGroup();
for (const auto *D : DGrp) {
- if (const auto *VD = dyn_cast_or_null<VarDecl>(D)) {
+ if (const auto *VD = dyn_cast_if_present<VarDecl>(D)) {
const Expr *E = VD->getInit();
// Add local variables with trivial type to the variable map
Expr *BrE, bool Neg) {
// Find out which branch has the lock
bool branch = false;
- if (const auto *BLE = dyn_cast_or_null<CXXBoolLiteralExpr>(BrE))
+ if (const auto *BLE = dyn_cast_if_present<CXXBoolLiteralExpr>(BrE))
branch = BLE->getValue();
- else if (const auto *ILE = dyn_cast_or_null<IntegerLiteral>(BrE))
+ else if (const auto *ILE = dyn_cast_if_present<IntegerLiteral>(BrE))
branch = ILE->getValue().getBoolValue();
int branchnum = branch ? 0 : 1;
if (!Exp)
return;
- auto *FunDecl = dyn_cast_or_null<NamedDecl>(Exp->getCalleeDecl());
+ auto *FunDecl = dyn_cast_if_present<NamedDecl>(Exp->getCalleeDecl());
if(!FunDecl || !FunDecl->hasAttrs())
return;
assert(!Self);
const auto *TagT = Exp->getType()->getAs<TagType>();
if (TagT && Exp->isPRValue()) {
- std::pair<til::LiteralPtr *, StringRef> Placeholder =
+ auto [ThisPtr, DiagType] =
Analyzer->SxBuilder.createThisPlaceholder(Exp);
[[maybe_unused]] auto inserted =
- ConstructedObjects.insert({Exp, Placeholder.first});
+ ConstructedObjects.insert({Exp, ThisPtr});
assert(inserted.second && "Are we visiting the same expression again?");
if (isa<CXXConstructExpr>(Exp))
- Self = Placeholder.first;
+ Self = ThisPtr;
if (TagT->getDecl()->hasAttr<ScopedLockableAttr>())
- Scp = CapabilityExpr(Placeholder.first, Placeholder.second, false);
+ Scp = CapabilityExpr(ThisPtr, DiagType, false);
}
assert(Loc.isInvalid());
LVarCtx = Analyzer->LocalVarMap.getNextContext(CtxIndex, S, LVarCtx);
for (auto *D : S->getDeclGroup()) {
- if (auto *VD = dyn_cast_or_null<VarDecl>(D)) {
+ if (auto *VD = dyn_cast_if_present<VarDecl>(D)) {
const Expr *E = VD->getInit();
if (!E)
continue;
return false;
CFGElement Last = B->back();
- if (std::optional<CFGStmt> S = Last.getAs<CFGStmt>()) {
- if (isa<CXXThrowExpr>(S->getStmt()))
- return true;
- }
+ if (std::optional<CFGStmt> S = Last.getAs<CFGStmt>();
+ isa<CXXThrowExpr>(S->getStmt()))
+ return true;
+
return false;
}