// Loc of auto in return type (c++14).
auto CurLoc = D->getReturnTypeSourceRange().getBegin();
// Loc of "auto" in operator auto()
- if (CurLoc.isInvalid() && dyn_cast<CXXConversionDecl>(D))
+ if (CurLoc.isInvalid() && isa<CXXConversionDecl>(D))
CurLoc = D->getTypeSourceInfo()->getTypeLoc().getBeginLoc();
// Loc of "auto" in function with trailing return type (c++11).
if (CurLoc.isInvalid())
return "const";
return "";
}
- if (isa<IntegerLiteral>(S) || isa<FloatingLiteral>(S) ||
- isa<FixedPointLiteral>(S) || isa<CharacterLiteral>(S) ||
- isa<ImaginaryLiteral>(S) || isa<CXXBoolLiteralExpr>(S))
+ if (isa<IntegerLiteral, FloatingLiteral, FixedPointLiteral,
+ CharacterLiteral, ImaginaryLiteral, CXXBoolLiteralExpr>(S))
return toString([&](raw_ostream &OS) {
S->printPretty(OS, nullptr, Ctx.getPrintingPolicy());
});
void VisitMemberExpr(const MemberExpr *E) {
// Skip destructor calls to avoid duplication: TypeLoc within will be
// visited separately.
- if (llvm::dyn_cast<CXXDestructorDecl>(E->getFoundDecl().getDecl()))
+ if (llvm::isa<CXXDestructorDecl>(E->getFoundDecl().getDecl()))
return;
Refs.push_back(ReferenceLoc{E->getQualifierLoc(),
E->getMemberNameInfo().getLoc(),
// declaration.
while (Method->isVirtual() && Method->size_overridden_methods())
Method = *Method->overridden_methods().begin();
- return dyn_cast<NamedDecl>(Method->getCanonicalDecl());
+ return Method->getCanonicalDecl();
}
if (const auto *Function = dyn_cast<FunctionDecl>(D))
if (const FunctionTemplateDecl *Template = Function->getPrimaryTemplate())
// if it's a lambda expression, return an error message
if (isa<RecordType>(*DeducedType) &&
- dyn_cast<RecordType>(*DeducedType)->getDecl()->isLambda()) {
+ cast<RecordType>(*DeducedType)->getDecl()->isLambda()) {
return error("Could not expand type of lambda expression");
}
}
};
FindDeclRefsVisitor Visitor;
- Visitor.TraverseStmt(const_cast<Stmt *>(dyn_cast<Stmt>(Expr)));
+ Visitor.TraverseStmt(const_cast<Stmt *>(cast<Stmt>(Expr)));
return Visitor.ReferencedDecls;
}
TargetDirective = CA->ASTNode.get<UsingDirectiveDecl>();
if (!TargetDirective)
return false;
- if (!dyn_cast<Decl>(TargetDirective->getDeclContext()))
+ if (!isa<Decl>(TargetDirective->getDeclContext()))
return false;
// FIXME: Unavailable for namespaces containing using-namespace decl.
// It is non-trivial to deal with cases where identifiers come from the inner
for (const SelectionTree::Node *N = Inputs.ASTSelection.commonAncestor();
N && !If; N = N->Parent) {
// Stop once we hit a block, e.g. a lambda in the if condition.
- if (dyn_cast_or_null<CompoundStmt>(N->ASTNode.get<Stmt>()))
+ if (llvm::isa_and_nonnull<CompoundStmt>(N->ASTNode.get<Stmt>()))
return false;
If = dyn_cast_or_null<IfStmt>(N->ASTNode.get<Stmt>());
}
// avoid dealing with single-statement brances, they require careful handling
// to avoid changing semantics of the code (i.e. dangling else).
- return If && dyn_cast_or_null<CompoundStmt>(If->getThen()) &&
- dyn_cast_or_null<CompoundStmt>(If->getElse());
+ return If && isa_and_nonnull<CompoundStmt>(If->getThen()) &&
+ isa_and_nonnull<CompoundStmt>(If->getElse());
}
Expected<Tweak::Effect> SwapIfBranches::apply(const Selection &Inputs) {