================
@@ -4904,13 +4907,43 @@ class PtrToIntInst : public CastInst {
 
   // Methods for support type inquiry through isa, cast, and dyn_cast:
   static bool classof(const Instruction *I) {
-    return I->getOpcode() == PtrToInt;
+    return I->getOpcode() == PtrToInt || I->getOpcode() == PtrToAddr;
+  }
+  static bool classof(const Value *V) {
+    return isa<Instruction>(V) && classof(cast<Instruction>(V));
+  }
+};
+
+/// This class represents a cast from a pointer to an address (non-capturing
+/// ptrtoint). Inherits from PtrToIntInst since it is a less restrictive 
version
+/// of ptrtoint, so treating it as ptrtoint is conservatively correct.
+class PtrToAddrInst : public PtrToIntInst {
----------------
krzysz00 wrote:

I'd argue for not inheriting, since it's likely to create footguns where code 
meant to work with a `ptrtoint` will end up quietly incorrect under `ptrtoaddr` 
semantics

https://github.com/llvm/llvm-project/pull/139357
_______________________________________________
llvm-branch-commits mailing list
llvm-branch-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits

Reply via email to