[PATCH] D29766: Add operator bool for MemoryLocations.
bryant via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 9 08:14:17 PST 2017
bryant created this revision.
The primary benefit of this patch is being able to write stuff like:
// getLocForWrite returns `MemoryLocation()` upon failure.
if (MemoryLocation M = getLocForWrite(Instruction, AA)) {
// do stuff with M
}
If there are any down sides, please let me know.
Repository:
rL LLVM
https://reviews.llvm.org/D29766
Files:
include/llvm/Analysis/MemoryLocation.h
Index: include/llvm/Analysis/MemoryLocation.h
===================================================================
--- include/llvm/Analysis/MemoryLocation.h
+++ include/llvm/Analysis/MemoryLocation.h
@@ -118,6 +118,8 @@
bool operator==(const MemoryLocation &Other) const {
return Ptr == Other.Ptr && Size == Other.Size && AATags == Other.AATags;
}
+
+ operator bool() const { return Ptr; }
};
// Specialize DenseMapInfo for MemoryLocation.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29766.87812.patch
Type: text/x-patch
Size: 456 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170209/43a07c01/attachment.bin>
More information about the llvm-commits
mailing list