forked from OSchip/llvm-project
[clang] Use isa instead of dyn_cast (NFC)
This commit is contained in:
parent
7379736774
commit
d0ac215dd5
|
@ -86,7 +86,7 @@ public:
|
|||
|
||||
/// Determine whether this capture handles a variable.
|
||||
bool capturesVariable() const {
|
||||
return dyn_cast_or_null<VarDecl>(DeclAndBits.getPointer());
|
||||
return isa_and_nonnull<VarDecl>(DeclAndBits.getPointer());
|
||||
}
|
||||
|
||||
/// Determine whether this captures a variable length array bound
|
||||
|
|
|
@ -488,7 +488,7 @@ public:
|
|||
|
||||
/// Determine whether this is an array new with an unknown bound.
|
||||
bool isVariableLengthArrayNew() const {
|
||||
return getKind() == EK_New && dyn_cast_or_null<IncompleteArrayType>(
|
||||
return getKind() == EK_New && isa_and_nonnull<IncompleteArrayType>(
|
||||
getType()->getAsArrayTypeUnsafe());
|
||||
}
|
||||
|
||||
|
|
|
@ -296,7 +296,7 @@ static NestedNameSpecifier *createNestedNameSpecifierForScopeOf(
|
|||
} else if (const auto *TD = dyn_cast<TagDecl>(Outer)) {
|
||||
return createNestedNameSpecifier(
|
||||
Ctx, TD, FullyQualified, WithGlobalNsPrefix);
|
||||
} else if (dyn_cast<TranslationUnitDecl>(Outer)) {
|
||||
} else if (isa<TranslationUnitDecl>(Outer)) {
|
||||
// Context is the TU. Nothing needs to be done.
|
||||
return nullptr;
|
||||
} else {
|
||||
|
|
|
@ -1892,7 +1892,7 @@ DeducedType *Type::getContainedDeducedType() const {
|
|||
}
|
||||
|
||||
bool Type::hasAutoForTrailingReturnType() const {
|
||||
return dyn_cast_or_null<FunctionType>(
|
||||
return isa_and_nonnull<FunctionType>(
|
||||
GetContainedDeducedTypeVisitor(true).Visit(this));
|
||||
}
|
||||
|
||||
|
|
|
@ -3913,7 +3913,7 @@ static void emitPrivatesInit(CodeGenFunction &CGF,
|
|||
SharedRefLValue.getTBAAInfo());
|
||||
} else if (CGF.LambdaCaptureFields.count(
|
||||
Pair.second.Original->getCanonicalDecl()) > 0 ||
|
||||
dyn_cast_or_null<BlockDecl>(CGF.CurCodeDecl)) {
|
||||
isa_and_nonnull<BlockDecl>(CGF.CurCodeDecl)) {
|
||||
SharedRefLValue = CGF.EmitLValue(Pair.second.OriginalRef);
|
||||
} else {
|
||||
// Processing for implicitly captured variables.
|
||||
|
|
|
@ -4720,7 +4720,7 @@ void CodeGenFunction::EmitOMPTargetTaskBasedDirective(
|
|||
[&InputInfo]() { return InputInfo.SizesArray; });
|
||||
// If there is no user-defined mapper, the mapper array will be nullptr. In
|
||||
// this case, we don't need to privatize it.
|
||||
if (!dyn_cast_or_null<llvm::ConstantPointerNull>(
|
||||
if (!isa_and_nonnull<llvm::ConstantPointerNull>(
|
||||
InputInfo.MappersArray.getPointer())) {
|
||||
MVD = createImplicitFirstprivateForType(
|
||||
getContext(), Data, BaseAndPointerAndMapperType, CD, S.getBeginLoc());
|
||||
|
|
|
@ -499,7 +499,7 @@ public:
|
|||
AbstractCallee(const FunctionDecl *FD) : CalleeDecl(FD) {}
|
||||
AbstractCallee(const ObjCMethodDecl *OMD) : CalleeDecl(OMD) {}
|
||||
bool hasFunctionDecl() const {
|
||||
return dyn_cast_or_null<FunctionDecl>(CalleeDecl);
|
||||
return isa_and_nonnull<FunctionDecl>(CalleeDecl);
|
||||
}
|
||||
const Decl *getDecl() const { return CalleeDecl; }
|
||||
unsigned getNumParams() const {
|
||||
|
|
|
@ -1953,7 +1953,7 @@ void CodeGenModule::setLLVMFunctionFEnvAttributes(const FunctionDecl *D,
|
|||
|
||||
void CodeGenModule::SetCommonAttributes(GlobalDecl GD, llvm::GlobalValue *GV) {
|
||||
const Decl *D = GD.getDecl();
|
||||
if (dyn_cast_or_null<NamedDecl>(D))
|
||||
if (isa_and_nonnull<NamedDecl>(D))
|
||||
setGVProperties(GV, GD);
|
||||
else
|
||||
GV->setVisibility(llvm::GlobalValue::DefaultVisibility);
|
||||
|
@ -4807,7 +4807,7 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old,
|
|||
callSite->getOperandBundlesAsDefs(newBundles);
|
||||
|
||||
llvm::CallBase *newCall;
|
||||
if (dyn_cast<llvm::CallInst>(callSite)) {
|
||||
if (isa<llvm::CallInst>(callSite)) {
|
||||
newCall =
|
||||
llvm::CallInst::Create(newFn, newArgs, newBundles, "", callSite);
|
||||
} else {
|
||||
|
|
|
@ -969,7 +969,7 @@ struct CounterCoverageMappingBuilder
|
|||
// If last statement contains terminate statements, add a gap area
|
||||
// between the two statements. Skipping attributed statements, because
|
||||
// they don't have valid start location.
|
||||
if (LastStmt && HasTerminateStmt && !dyn_cast<AttributedStmt>(Child)) {
|
||||
if (LastStmt && HasTerminateStmt && !isa<AttributedStmt>(Child)) {
|
||||
auto Gap = findGapAreaBetween(getEnd(LastStmt), getStart(Child));
|
||||
if (Gap)
|
||||
fillGapAreaWithCount(Gap->getBegin(), Gap->getEnd(),
|
||||
|
|
|
@ -2741,8 +2741,8 @@ static bool isValidBPFPreserveFieldInfoArg(Expr *Arg) {
|
|||
// to BPF backend to check whether the access is a
|
||||
// field access or not.
|
||||
return (Arg->IgnoreParens()->getObjectKind() == OK_BitField ||
|
||||
dyn_cast<MemberExpr>(Arg->IgnoreParens()) ||
|
||||
dyn_cast<ArraySubscriptExpr>(Arg->IgnoreParens()));
|
||||
isa<MemberExpr>(Arg->IgnoreParens()) ||
|
||||
isa<ArraySubscriptExpr>(Arg->IgnoreParens()));
|
||||
}
|
||||
|
||||
static bool isEltOfVectorTy(ASTContext &Context, CallExpr *Call, Sema &S,
|
||||
|
@ -2766,8 +2766,8 @@ static bool isValidBPFPreserveTypeInfoArg(Expr *Arg) {
|
|||
// 1. __builtin_preserve_type_info(*(<type> *)0, flag);
|
||||
// 2. <type> var;
|
||||
// __builtin_preserve_type_info(var, flag);
|
||||
if (!dyn_cast<DeclRefExpr>(Arg->IgnoreParens()) &&
|
||||
!dyn_cast<UnaryOperator>(Arg->IgnoreParens()))
|
||||
if (!isa<DeclRefExpr>(Arg->IgnoreParens()) &&
|
||||
!isa<UnaryOperator>(Arg->IgnoreParens()))
|
||||
return false;
|
||||
|
||||
// Typedef type.
|
||||
|
|
|
@ -5781,7 +5781,7 @@ bool Sema::diagnoseQualifiedDeclaration(CXXScopeSpec &SS, DeclContext *DC,
|
|||
NestedNameSpecifierLoc SpecLoc(SS.getScopeRep(), SS.location_data());
|
||||
while (SpecLoc.getPrefix())
|
||||
SpecLoc = SpecLoc.getPrefix();
|
||||
if (dyn_cast_or_null<DecltypeType>(
|
||||
if (isa_and_nonnull<DecltypeType>(
|
||||
SpecLoc.getNestedNameSpecifier()->getAsType()))
|
||||
Diag(Loc, diag::err_decltype_in_declarator)
|
||||
<< SpecLoc.getTypeLoc().getSourceRange();
|
||||
|
|
|
@ -611,7 +611,7 @@ ActOnSuperClassOfClassInterface(Scope *S,
|
|||
}
|
||||
}
|
||||
|
||||
if (!dyn_cast_or_null<TypedefNameDecl>(PrevDecl)) {
|
||||
if (!isa_and_nonnull<TypedefNameDecl>(PrevDecl)) {
|
||||
if (!SuperClassDecl)
|
||||
Diag(SuperLoc, diag::err_undef_superclass)
|
||||
<< SuperName << ClassName << SourceRange(AtInterfaceLoc, ClassLoc);
|
||||
|
|
|
@ -5709,7 +5709,7 @@ Sema::VariadicCallType
|
|||
Sema::getVariadicCallType(FunctionDecl *FDecl, const FunctionProtoType *Proto,
|
||||
Expr *Fn) {
|
||||
if (Proto && Proto->isVariadic()) {
|
||||
if (dyn_cast_or_null<CXXConstructorDecl>(FDecl))
|
||||
if (isa_and_nonnull<CXXConstructorDecl>(FDecl))
|
||||
return VariadicConstructor;
|
||||
else if (Fn && Fn->getType()->isBlockPointerType())
|
||||
return VariadicBlock;
|
||||
|
|
|
@ -9860,9 +9860,9 @@ bool clang::isBetterOverloadCandidate(
|
|||
// F1 and F2 have the same type.
|
||||
// FIXME: Implement the "all parameters have the same type" check.
|
||||
bool Cand1IsInherited =
|
||||
dyn_cast_or_null<ConstructorUsingShadowDecl>(Cand1.FoundDecl.getDecl());
|
||||
isa_and_nonnull<ConstructorUsingShadowDecl>(Cand1.FoundDecl.getDecl());
|
||||
bool Cand2IsInherited =
|
||||
dyn_cast_or_null<ConstructorUsingShadowDecl>(Cand2.FoundDecl.getDecl());
|
||||
isa_and_nonnull<ConstructorUsingShadowDecl>(Cand2.FoundDecl.getDecl());
|
||||
if (Cand1IsInherited != Cand2IsInherited)
|
||||
return Cand2IsInherited;
|
||||
else if (Cand1IsInherited) {
|
||||
|
@ -12673,7 +12673,7 @@ static void AddOverloadedCallCandidate(Sema &S,
|
|||
return;
|
||||
}
|
||||
// Prevent ill-formed function decls to be added as overload candidates.
|
||||
if (!dyn_cast<FunctionProtoType>(Func->getType()->getAs<FunctionType>()))
|
||||
if (!isa<FunctionProtoType>(Func->getType()->getAs<FunctionType>()))
|
||||
return;
|
||||
|
||||
S.AddOverloadCandidate(Func, FoundDecl, Args, CandidateSet,
|
||||
|
|
|
@ -743,7 +743,7 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS,
|
|||
// Check if the nested name specifier is an enum type.
|
||||
bool IsEnum = false;
|
||||
if (NestedNameSpecifier *NNS = SS.getScopeRep())
|
||||
IsEnum = dyn_cast_or_null<EnumType>(NNS->getAsType());
|
||||
IsEnum = isa_and_nonnull<EnumType>(NNS->getAsType());
|
||||
|
||||
if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
|
||||
isa<CXXMethodDecl>(DC) && cast<CXXMethodDecl>(DC)->isInstance()) {
|
||||
|
|
|
@ -5428,7 +5428,7 @@ static TypeSourceInfo *GetFullTypeForDeclarator(TypeProcessingState &state,
|
|||
// Avoid emitting extra errors if we already errored on the scope.
|
||||
D.setInvalidType(true);
|
||||
} else if (S.isDependentScopeSpecifier(SS) ||
|
||||
dyn_cast_or_null<CXXRecordDecl>(S.computeDeclContext(SS))) {
|
||||
isa_and_nonnull<CXXRecordDecl>(S.computeDeclContext(SS))) {
|
||||
NestedNameSpecifier *NNS = SS.getScopeRep();
|
||||
NestedNameSpecifier *NNSPrefix = NNS->getPrefix();
|
||||
switch (NNS->getKind()) {
|
||||
|
|
|
@ -384,7 +384,7 @@ void DynamicTypePropagation::checkPostCall(const CallEvent &Call,
|
|||
// FIXME: Instead of relying on the ParentMap, we should have the
|
||||
// trigger-statement (InitListExpr in this case) available in this
|
||||
// callback, ideally as part of CallEvent.
|
||||
if (dyn_cast_or_null<InitListExpr>(
|
||||
if (isa_and_nonnull<InitListExpr>(
|
||||
LCtx->getParentMap().getParent(Ctor->getOriginExpr())))
|
||||
return;
|
||||
|
||||
|
|
|
@ -290,7 +290,7 @@ void RetainCountChecker::checkPostStmt(const ObjCIvarRefExpr *IRE,
|
|||
|
||||
ProgramStateRef State = C.getState();
|
||||
SymbolRef Sym = State->getSVal(*IVarLoc).getAsSymbol();
|
||||
if (!Sym || !dyn_cast_or_null<ObjCIvarRegion>(Sym->getOriginRegion()))
|
||||
if (!Sym || !isa_and_nonnull<ObjCIvarRegion>(Sym->getOriginRegion()))
|
||||
return;
|
||||
|
||||
// Accessing an ivar directly is unusual. If we've done that, be more
|
||||
|
|
|
@ -68,8 +68,7 @@ public:
|
|||
if (auto *F = CE->getDirectCallee()) {
|
||||
// Skip the first argument for overloaded member operators (e. g. lambda
|
||||
// or std::function call operator).
|
||||
unsigned ArgIdx =
|
||||
isa<CXXOperatorCallExpr>(CE) && dyn_cast_or_null<CXXMethodDecl>(F);
|
||||
unsigned ArgIdx = isa<CXXOperatorCallExpr>(CE) && isa_and_nonnull<CXXMethodDecl>(F);
|
||||
|
||||
for (auto P = F->param_begin();
|
||||
// FIXME: Also check variadic function parameters.
|
||||
|
|
|
@ -531,7 +531,7 @@ void ExprEngine::handleConstructor(const Expr *E,
|
|||
// FIXME: Instead of relying on the ParentMap, we should have the
|
||||
// trigger-statement (InitListExpr in this case) passed down from CFG or
|
||||
// otherwise always available during construction.
|
||||
if (dyn_cast_or_null<InitListExpr>(LCtx->getParentMap().getParent(E))) {
|
||||
if (isa_and_nonnull<InitListExpr>(LCtx->getParentMap().getParent(E))) {
|
||||
MemRegionManager &MRMgr = getSValBuilder().getRegionManager();
|
||||
Target = loc::MemRegionVal(MRMgr.getCXXTempObjectRegion(E, LCtx));
|
||||
CallOpts.IsCtorOrDtorWithImproperlyModeledTargetRegion = true;
|
||||
|
|
|
@ -1711,7 +1711,7 @@ CXType clang_Cursor_getReceiverType(CXCursor C) {
|
|||
ME = dyn_cast_or_null<MemberExpr>(CE->getCallee());
|
||||
|
||||
if (ME) {
|
||||
if (dyn_cast_or_null<CXXMethodDecl>(ME->getMemberDecl())) {
|
||||
if (isa_and_nonnull<CXXMethodDecl>(ME->getMemberDecl())) {
|
||||
auto receiverTy = ME->getBase()->IgnoreImpCasts()->getType();
|
||||
return cxtype::MakeCXType(receiverTy, TU);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue