Index: llvm/trunk/include/llvm/IR/InstVisitor.h =================================================================== --- llvm/trunk/include/llvm/IR/InstVisitor.h +++ llvm/trunk/include/llvm/IR/InstVisitor.h @@ -268,17 +268,23 @@ RetTy visitCmpInst(CmpInst &I) { DELEGATE(Instruction);} RetTy visitUnaryInstruction(UnaryInstruction &I){ DELEGATE(Instruction);} - // Provide a special visitor for a 'callsite' that visits both calls and - // invokes. When unimplemented, properly delegates to either the terminator or - // regular instruction visitor. + // The next level delegation for `CallBase` is slightly more complex in order + // to support visiting cases where the call is also a terminator. + RetTy visitCallBase(CallBase &I) { + if (isa(I)) + return static_cast(this)->visitTerminator(I); + + DELEGATE(Instruction); + } + + // Provide a legacy visitor for a 'callsite' that visits both calls and + // invokes. + // + // Prefer overriding the type system based `CallBase` instead. RetTy visitCallSite(CallSite CS) { assert(CS); Instruction &I = *CS.getInstruction(); - if (CS.isCall()) - DELEGATE(Instruction); - - assert(CS.isInvoke()); - return static_cast(this)->visitTerminator(I); + DELEGATE(CallBase); } // If the user wants a 'default' case, they can choose to override this