forked from OSchip/llvm-project
[NFC] Switch up some dyn_cast calls
This commit is contained in:
parent
4c77a0f1ce
commit
7af6a13450
|
@ -367,7 +367,7 @@ public:
|
|||
// 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())
|
||||
|
|
|
@ -242,9 +242,8 @@ class DumpVisitor : public RecursiveASTVisitor<DumpVisitor> {
|
|||
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());
|
||||
});
|
||||
|
|
|
@ -843,7 +843,7 @@ llvm::SmallVector<ReferenceLoc> refInStmt(const Stmt *S) {
|
|||
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(),
|
||||
|
|
|
@ -119,7 +119,7 @@ const NamedDecl *canonicalRenameDecl(const NamedDecl *D) {
|
|||
// 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())
|
||||
|
|
|
@ -111,7 +111,7 @@ Expected<Tweak::Effect> ExpandAutoType::apply(const Selection& Inputs) {
|
|||
|
||||
// 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");
|
||||
}
|
||||
|
||||
|
|
|
@ -79,7 +79,7 @@ computeReferencedDecls(const clang::Expr *Expr) {
|
|||
}
|
||||
};
|
||||
FindDeclRefsVisitor Visitor;
|
||||
Visitor.TraverseStmt(const_cast<Stmt *>(dyn_cast<Stmt>(Expr)));
|
||||
Visitor.TraverseStmt(const_cast<Stmt *>(cast<Stmt>(Expr)));
|
||||
return Visitor.ReferencedDecls;
|
||||
}
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ bool RemoveUsingNamespace::prepare(const Selection &Inputs) {
|
|||
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
|
||||
|
|
|
@ -54,14 +54,14 @@ bool SwapIfBranches::prepare(const Selection &Inputs) {
|
|||
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) {
|
||||
|
|
Loading…
Reference in New Issue