From 42ffba051894a66cf6d7b9a357e765a392d983ed Mon Sep 17 00:00:00 2001 From: Philip Reames Date: Wed, 7 Oct 2020 12:15:16 -0700 Subject: [PATCH] Add a clarifying a comment on CastInst::isNoopCast I made exactly the mistake described, so document the precondition. It would be better to have an assert, but there is (currently) no "castIsValid" with purely type arguments. --- llvm/include/llvm/IR/InstrTypes.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/llvm/include/llvm/IR/InstrTypes.h b/llvm/include/llvm/IR/InstrTypes.h index 00aa79c4a2391e..c86448ea72cb46 100644 --- a/llvm/include/llvm/IR/InstrTypes.h +++ b/llvm/include/llvm/IR/InstrTypes.h @@ -650,8 +650,8 @@ class CastInst : public UnaryInstruction { /// DataLayout argument is to determine the pointer size when examining casts /// involving Integer and Pointer types. They are no-op casts if the integer /// is the same size as the pointer. However, pointer size varies with - /// platform. - /// Determine if the described cast is a no-op cast. + /// platform. Note that a precondition of this method is that the cast is + /// legal - i.e. the instruction formed with these operands would verify. static bool isNoopCast( Instruction::CastOps Opcode, ///< Opcode of cast Type *SrcTy, ///< SrcTy of cast