Skip to content

Commit f7d7b5e

Browse files
committed
[NFC][LLVM][IR] Adopt vadiadic isa<>
- Adopt variadic `isa<>` in all files except Verifier.cpp
1 parent 34a4c58 commit f7d7b5e

24 files changed

+73
-90
lines changed

llvm/include/llvm/IR/DebugProgramInstruction.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -467,8 +467,7 @@ class DbgVariableRecord : public DbgRecord, protected DebugValueUser {
467467
/// replaceVariableLocationOp and addVariableLocationOps should be used where
468468
/// possible to avoid creating invalid state.
469469
void setRawLocation(Metadata *NewLocation) {
470-
assert((isa<ValueAsMetadata>(NewLocation) || isa<DIArgList>(NewLocation) ||
471-
isa<MDNode>(NewLocation)) &&
470+
assert((isa<ValueAsMetadata, DIArgList, MDNode>(NewLocation)) &&
472471
"Location for a DbgVariableRecord must be either ValueAsMetadata or "
473472
"DIArgList");
474473
resetDebugValue(0, NewLocation);

llvm/include/llvm/IR/InstVisitor.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class InstVisitor {
268268
// The next level delegation for `CallBase` is slightly more complex in order
269269
// to support visiting cases where the call is also a terminator.
270270
RetTy visitCallBase(CallBase &I) {
271-
if (isa<InvokeInst>(I) || isa<CallBrInst>(I))
271+
if (isa<InvokeInst, CallBrInst>(I))
272272
return static_cast<SubClass *>(this)->visitTerminator(I);
273273

274274
DELEGATE(Instruction);

llvm/include/llvm/IR/Instructions.h

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5023,17 +5023,15 @@ inline Value *getPointerOperand(Value *V) {
50235023

50245024
/// A helper function that returns the alignment of load or store instruction.
50255025
inline Align getLoadStoreAlignment(const Value *I) {
5026-
assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
5027-
"Expected Load or Store instruction");
5026+
assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
50285027
if (auto *LI = dyn_cast<LoadInst>(I))
50295028
return LI->getAlign();
50305029
return cast<StoreInst>(I)->getAlign();
50315030
}
50325031

50335032
/// A helper function that set the alignment of load or store instruction.
50345033
inline void setLoadStoreAlignment(Value *I, Align NewAlign) {
5035-
assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
5036-
"Expected Load or Store instruction");
5034+
assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
50375035
if (auto *LI = dyn_cast<LoadInst>(I))
50385036
LI->setAlignment(NewAlign);
50395037
else
@@ -5043,17 +5041,15 @@ inline void setLoadStoreAlignment(Value *I, Align NewAlign) {
50435041
/// A helper function that returns the address space of the pointer operand of
50445042
/// load or store instruction.
50455043
inline unsigned getLoadStoreAddressSpace(const Value *I) {
5046-
assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
5047-
"Expected Load or Store instruction");
5044+
assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
50485045
if (auto *LI = dyn_cast<LoadInst>(I))
50495046
return LI->getPointerAddressSpace();
50505047
return cast<StoreInst>(I)->getPointerAddressSpace();
50515048
}
50525049

50535050
/// A helper function that returns the type of a load or store instruction.
50545051
inline Type *getLoadStoreType(const Value *I) {
5055-
assert((isa<LoadInst>(I) || isa<StoreInst>(I)) &&
5056-
"Expected Load or Store instruction");
5052+
assert((isa<LoadInst, StoreInst>(I)) && "Expected Load or Store instruction");
50575053
if (auto *LI = dyn_cast<LoadInst>(I))
50585054
return LI->getType();
50595055
return cast<StoreInst>(I)->getValueOperand()->getType();

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ class RawLocationWrapper {
249249
: RawLocation(RawLocation) {
250250
// Allow ValueAsMetadata, empty MDTuple, DIArgList.
251251
assert(RawLocation && "unexpected null RawLocation");
252-
assert(isa<ValueAsMetadata>(RawLocation) || isa<DIArgList>(RawLocation) ||
252+
assert((isa<ValueAsMetadata, DIArgList>(RawLocation)) ||
253253
(isa<MDNode>(RawLocation) &&
254254
!cast<MDNode>(RawLocation)->getNumOperands()));
255255
}
@@ -1791,7 +1791,7 @@ class GCProjectionInst : public IntrinsicInst {
17911791
bool isTiedToInvoke() const {
17921792
const Value *Token = getArgOperand(0);
17931793

1794-
return isa<LandingPadInst>(Token) || isa<InvokeInst>(Token);
1794+
return isa<LandingPadInst, InvokeInst>(Token);
17951795
}
17961796

17971797
/// The statepoint with which this gc.relocate is associated.

llvm/include/llvm/IR/Operator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ class Operator : public User {
5858
static bool classof(const Instruction *) { return true; }
5959
static bool classof(const ConstantExpr *) { return true; }
6060
static bool classof(const Value *V) {
61-
return isa<Instruction>(V) || isa<ConstantExpr>(V);
61+
return isa<Instruction, ConstantExpr>(V);
6262
}
6363

6464
/// Return true if this operator has flags which may cause this operator

llvm/include/llvm/IR/User.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -354,9 +354,7 @@ class User : public Value {
354354
bool replaceUsesOfWith(Value *From, Value *To);
355355

356356
// Methods for support type inquiry through isa, cast, and dyn_cast:
357-
static bool classof(const Value *V) {
358-
return isa<Instruction>(V) || isa<Constant>(V);
359-
}
357+
static bool classof(const Value *V) { return isa<Instruction, Constant>(V); }
360358
};
361359

362360
// Either Use objects, or a Use pointer can be prepended to User.

llvm/include/llvm/IR/Value.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,14 +1046,13 @@ template <> struct isa_impl<GlobalIFunc, Value> {
10461046

10471047
template <> struct isa_impl<GlobalValue, Value> {
10481048
static inline bool doit(const Value &Val) {
1049-
return isa<GlobalObject>(Val) || isa<GlobalAlias>(Val);
1049+
return isa<GlobalObject, GlobalAlias>(Val);
10501050
}
10511051
};
10521052

10531053
template <> struct isa_impl<GlobalObject, Value> {
10541054
static inline bool doit(const Value &Val) {
1055-
return isa<GlobalVariable>(Val) || isa<Function>(Val) ||
1056-
isa<GlobalIFunc>(Val);
1055+
return isa<GlobalVariable, Function, GlobalIFunc>(Val);
10571056
}
10581057
};
10591058

llvm/lib/IR/AsmWriter.cpp

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ static OrderMap orderModule(const Module *M) {
141141
OrderMap OM;
142142

143143
auto orderConstantValue = [&OM](const Value *V) {
144-
if (isa<Constant>(V) || isa<InlineAsm>(V))
144+
if (isa<Constant, InlineAsm>(V))
145145
orderValue(V, OM);
146146
};
147147

@@ -1625,7 +1625,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
16251625
return;
16261626
}
16271627

1628-
if (isa<ConstantAggregateZero>(CV) || isa<ConstantTargetNone>(CV)) {
1628+
if (isa<ConstantAggregateZero, ConstantTargetNone>(CV)) {
16291629
Out << "zeroinitializer";
16301630
return;
16311631
}
@@ -1741,7 +1741,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
17411741
return;
17421742
}
17431743

1744-
if (isa<ConstantVector>(CV) || isa<ConstantDataVector>(CV)) {
1744+
if (isa<ConstantVector, ConstantDataVector>(CV)) {
17451745
auto *CVVTy = cast<FixedVectorType>(CV->getType());
17461746
Type *ETy = CVVTy->getElementType();
17471747

@@ -1751,7 +1751,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
17511751
// TODO: Remove this block when the UseConstant{Int,FP}ForFixedLengthSplat
17521752
// options are removed.
17531753
if (auto *SplatVal = CV->getSplatValue()) {
1754-
if (isa<ConstantInt>(SplatVal) || isa<ConstantFP>(SplatVal)) {
1754+
if (isa<ConstantInt, ConstantFP>(SplatVal)) {
17551755
Out << "splat (";
17561756
WriterCtx.TypePrinter->print(ETy, Out);
17571757
Out << ' ';
@@ -1803,7 +1803,7 @@ static void WriteConstantInternal(raw_ostream &Out, const Constant *CV,
18031803
// options are removed.
18041804
if (CE->getOpcode() == Instruction::ShuffleVector) {
18051805
if (auto *SplatVal = CE->getSplatValue()) {
1806-
if (isa<ConstantInt>(SplatVal) || isa<ConstantFP>(SplatVal)) {
1806+
if (isa<ConstantInt, ConstantFP>(SplatVal)) {
18071807
Out << "splat (";
18081808
WriterCtx.TypePrinter->print(SplatVal->getType(), Out);
18091809
Out << ' ';
@@ -4760,9 +4760,8 @@ void AssemblyWriter::printInstruction(const Instruction &I) {
47604760

47614761
// Select, Store, ShuffleVector, CmpXchg and AtomicRMW always print all
47624762
// types.
4763-
if (isa<SelectInst>(I) || isa<StoreInst>(I) || isa<ShuffleVectorInst>(I) ||
4764-
isa<ReturnInst>(I) || isa<AtomicCmpXchgInst>(I) ||
4765-
isa<AtomicRMWInst>(I)) {
4763+
if (isa<SelectInst, StoreInst, ShuffleVectorInst, ReturnInst,
4764+
AtomicCmpXchgInst, AtomicRMWInst>(I)) {
47664765
PrintAllTypes = true;
47674766
} else {
47684767
for (unsigned i = 1, E = I.getNumOperands(); i != E; ++i) {
@@ -5194,7 +5193,7 @@ void Value::print(raw_ostream &ROS, bool IsForDebug) const {
51945193
bool ShouldInitializeAllMetadata = false;
51955194
if (auto *I = dyn_cast<Instruction>(this))
51965195
ShouldInitializeAllMetadata = isReferencingMDNode(*I);
5197-
else if (isa<Function>(this) || isa<MetadataAsValue>(this))
5196+
else if (isa<Function, MetadataAsValue>(this))
51985197
ShouldInitializeAllMetadata = true;
51995198

52005199
ModuleSlotTracker MST(getModuleFromVal(this), ShouldInitializeAllMetadata);
@@ -5240,7 +5239,7 @@ void Value::print(raw_ostream &ROS, ModuleSlotTracker &MST,
52405239
OS << ' ';
52415240
AsmWriterContext WriterCtx(&TypePrinter, MST.getMachine());
52425241
WriteConstantInternal(OS, C, WriterCtx);
5243-
} else if (isa<InlineAsm>(this) || isa<Argument>(this)) {
5242+
} else if (isa<InlineAsm, Argument>(this)) {
52445243
this->printAsOperand(OS, /* PrintType */ true, MST);
52455244
} else {
52465245
llvm_unreachable("Unknown value to print out!");

llvm/lib/IR/BasicBlock.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ const Instruction *BasicBlock::getFirstMayFaultInst() const {
362362
if (InstList.empty())
363363
return nullptr;
364364
for (const Instruction &I : *this)
365-
if (isa<LoadInst>(I) || isa<StoreInst>(I) || isa<CallBase>(I))
365+
if (isa<LoadInst, StoreInst, CallBase>(I))
366366
return &I;
367367
return nullptr;
368368
}
@@ -400,7 +400,7 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIIt() const {
400400
BasicBlock::const_iterator
401401
BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
402402
for (const Instruction &I : *this) {
403-
if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
403+
if (isa<PHINode, DbgInfoIntrinsic>(I))
404404
continue;
405405

406406
if (SkipPseudoOp && isa<PseudoProbeInst>(I))
@@ -418,7 +418,7 @@ BasicBlock::getFirstNonPHIOrDbg(bool SkipPseudoOp) const {
418418
BasicBlock::const_iterator
419419
BasicBlock::getFirstNonPHIOrDbgOrLifetime(bool SkipPseudoOp) const {
420420
for (const Instruction &I : *this) {
421-
if (isa<PHINode>(I) || isa<DbgInfoIntrinsic>(I))
421+
if (isa<PHINode, DbgInfoIntrinsic>(I))
422422
continue;
423423

424424
if (I.isLifetimeStartOrEnd())
@@ -461,8 +461,7 @@ BasicBlock::const_iterator BasicBlock::getFirstNonPHIOrDbgOrAlloca() const {
461461
if (isEntryBlock()) {
462462
const_iterator End = end();
463463
while (InsertPt != End &&
464-
(isa<AllocaInst>(*InsertPt) || isa<DbgInfoIntrinsic>(*InsertPt) ||
465-
isa<PseudoProbeInst>(*InsertPt))) {
464+
isa<AllocaInst, DbgInfoIntrinsic, PseudoProbeInst>(*InsertPt)) {
466465
if (const AllocaInst *AI = dyn_cast<AllocaInst>(&*InsertPt)) {
467466
if (!AI->isStaticAlloca())
468467
break;

llvm/lib/IR/ConstantFold.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,8 +321,8 @@ Constant *llvm::ConstantFoldSelectInstruction(Constant *Cond,
321321
if (isa<ConstantExpr>(C))
322322
return false;
323323

324-
if (isa<ConstantInt>(C) || isa<GlobalVariable>(C) || isa<ConstantFP>(C) ||
325-
isa<ConstantPointerNull>(C) || isa<Function>(C))
324+
if (isa<ConstantInt, GlobalVariable, ConstantFP, ConstantPointerNull,
325+
Function>(C))
326326
return true;
327327

328328
if (C->getType()->isVectorTy())

0 commit comments

Comments
 (0)