diff --git a/llvm/docs/ProgrammersManual.rst b/llvm/docs/ProgrammersManual.rst index bb729597cc5a3..fe8aaa7cca72f 100644 --- a/llvm/docs/ProgrammersManual.rst +++ b/llvm/docs/ProgrammersManual.rst @@ -115,7 +115,9 @@ rarely have to include this file directly). The ``isa<>`` operator works exactly like the Java "``instanceof``" operator. It returns true or false depending on whether a reference or pointer points to an instance of the specified class. This can be very useful for constraint - checking of various sorts (example below). + checking of various sorts (example below). It's a variadic operator, so you + can specify more than one class to check if the reference or pointer points + to an instance of one of the classes specified. ``cast<>``: The ``cast<>`` operator is a "checked cast" operation. It converts a pointer @@ -131,7 +133,11 @@ rarely have to include this file directly). if (isa(V) || isa(V) || isa(V)) return true; - // Otherwise, it must be an instruction... + // Alternate, more compact form. + if (isa(V)) + return true; + + // Otherwise, it must be an instruction. return !L->contains(cast(V)->getParent()); } @@ -168,7 +174,8 @@ rarely have to include this file directly). The ``isa_and_present<>`` operator works just like the ``isa<>`` operator, except that it allows for a null pointer as an argument (which it then returns false). This can sometimes be useful, allowing you to combine several - null checks into one. + null checks into one. Similar to ``isa<>`` operator, you can specify more than + one class to check. ``cast_if_present<>``: The ``cast_if_present<>`` operator works just like the ``cast<>`` operator, diff --git a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp index 9be0eec7b73f3..f301872454fc3 100644 --- a/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp +++ b/llvm/tools/llvm-diff/lib/DifferenceEngine.cpp @@ -569,7 +569,7 @@ class FunctionDifferenceEngine { // Constants of the "same type" don't always actually have the same // type; I don't know why. Just white-list them. - if (isa(L) || isa(L) || isa(L)) + if (isa(L)) return true; // Block addresses only match if we've already encountered the diff --git a/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp b/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp index 34e0791d4e974..f4fb13ce16587 100644 --- a/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp +++ b/llvm/tools/llvm-reduce/deltas/ReduceDIMetadata.cpp @@ -63,7 +63,7 @@ void identifyUninterestingMDNodes(Oracle &O, MDNodeList &MDs) { for (size_t I = 0; I < Tup->getNumOperands(); ++I) { // Ignore any operands that are not DebugInfo metadata nodes. if (Metadata *Op = Tup->getOperand(I).get()) { - if (isa(Op) || isa(Op)) + if (isa(Op)) // Don't add uninteresting operands to the tuple. if (!O.shouldKeep()) continue; diff --git a/llvm/tools/llvm-reduce/deltas/Utils.cpp b/llvm/tools/llvm-reduce/deltas/Utils.cpp index a980a0f9fad2f..00f583fb2a1b0 100644 --- a/llvm/tools/llvm-reduce/deltas/Utils.cpp +++ b/llvm/tools/llvm-reduce/deltas/Utils.cpp @@ -39,9 +39,8 @@ Value *llvm::getDefaultValue(Type *T) { } bool llvm::hasAliasUse(Function &F) { - return any_of(F.users(), [](User *U) { - return isa(U) || isa(U); - }); + return any_of(F.users(), + [](User *U) { return isa(U); }); } bool llvm::hasAliasOrBlockAddressUse(Function &F) { diff --git a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp index 7f58c4a88c76d..1539ffe0fd4b5 100644 --- a/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp +++ b/llvm/utils/TableGen/Common/CodeGenDAGPatterns.cpp @@ -2915,7 +2915,7 @@ TreePatternNodePtr TreePattern::ParseTreePattern(const Init *TheInit, return Res; } - if (isa(TheInit) || isa(TheInit)) { + if (isa(TheInit)) { if (!OpName.empty()) error("Constant int or bit argument should not have a name!"); if (isa(TheInit)) diff --git a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp index 4c809b4016cbd..9a16f5c5297d8 100644 --- a/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp +++ b/llvm/utils/TableGen/Common/GlobalISel/GlobalISelMatchTable.cpp @@ -558,7 +558,7 @@ void GroupMatcher::optimize() { //===- SwitchMatcher ------------------------------------------------------===// bool SwitchMatcher::isSupportedPredicateType(const PredicateMatcher &P) { - return isa(P) || isa(P); + return isa(P); } bool SwitchMatcher::candidateConditionMatches( diff --git a/llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp b/llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp index 0a835bd7b0bc0..91e2e7623b609 100644 --- a/llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp +++ b/llvm/utils/TableGen/Common/VarLenCodeEmitterGen.cpp @@ -463,7 +463,7 @@ std::string VarLenCodeEmitterGen::getInstructionCaseForEncoding( const Init *Val = ES.Value; // If it's a StringInit or DagInit, it's a reference to an operand // or part of an operand. - if (isa(Val) || isa(Val)) { + if (isa(Val)) { StringRef OperandName; unsigned LoBit = 0U; if (const auto *SV = dyn_cast(Val)) { diff --git a/llvm/utils/TableGen/SearchableTableEmitter.cpp b/llvm/utils/TableGen/SearchableTableEmitter.cpp index 7251a1ba545d5..c91588b9cb02b 100644 --- a/llvm/utils/TableGen/SearchableTableEmitter.cpp +++ b/llvm/utils/TableGen/SearchableTableEmitter.cpp @@ -237,7 +237,7 @@ bool SearchableTableEmitter::compareBy(const Record *LHS, const Record *RHS, const Init *LHSI = LHS->getValueInit(Field.Name); const Init *RHSI = RHS->getValueInit(Field.Name); - if (isa(Field.RecType) || isa(Field.RecType)) { + if (isa(Field.RecType)) { int64_t LHSi = getAsInt(LHSI); int64_t RHSi = getAsInt(RHSI); if (LHSi < RHSi)