This is an archive of the discontinued LLVM Phabricator instance.

Add operator bool for MemoryLocations.
Needs ReviewPublic

Authored by bryant on Feb 9 2017, 8:14 AM.

Details

Summary

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.

Diff Detail

Repository
rL LLVM

Event Timeline

bryant created this revision.Feb 9 2017, 8:14 AM
efriedma edited edge metadata.Feb 9 2017, 10:03 AM

I'm not sure we want to encourage the use of null MemoryLocations... maybe getLocForWrite() should use Optional<MemoryLocation> instead?

include/llvm/Analysis/MemoryLocation.h
122

operator bool() should always be explicit.