yaxunl added inline comments.

================
Comment at: lib/CodeGen/CodeGenTypes.cpp:743
+    auto NullPtr = CGM.getNullPtr(LLPT, T);
+    return isa<llvm::ConstantPointerNull>(NullPtr);
+  }
----------------
tony-tye wrote:
> Is this correct if the target does not represent a NULL pointer as the 
> address with value 0? Or should this be asking the target if this null 
> pointer is represented by an address value of 0?
Currently this is correct even if the target does not represent a null pointer 
as address with value 0. The purpose of this line is to check if NullPtr has 
zero value at compile time. In LLVM checking whether a pointer having zero 
value at compile time is by checking if it is ConstantPointerNull.

However, if in the future LLVM no longer assumes ConstantPointerNull having 
zero value, then this will become incorrect. To be future proof, I think I'd 
better add a member function isPtrZero to TargetCodeGenInfo and use it to check 
if a pointer has zero value.


https://reviews.llvm.org/D26196



_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to