This is an archive of the discontinued LLVM Phabricator instance.

Switch DWARFDie::getAttributeValueAsString() to return an llvm::Optional<const char *>.
AbandonedPublic

Authored by clayborg on Dec 13 2016, 12:52 PM.

Details

Summary

I will be changing all DWARFDie::getAttributeValueAsXXX() over to return llvm::Optional one by one. Starting with string values.

Diff Detail

Event Timeline

clayborg updated this revision to Diff 81287.Dec 13 2016, 12:52 PM
clayborg retitled this revision from to Switch DWARFDie::getAttributeValueAsString() to return an llvm::Optional<const char *>..
clayborg updated this object.
aprantl edited edge metadata.Dec 13 2016, 1:26 PM

I'm all for replacing the Value getAttribute(Attr attr, Value default) interfaces with Optional<Value> getAttribute(Attr attr) versions, and perhaps provide the default-value mechanism in a generic way. However, in the concrete case of a const char * return value I think LLVM typically returns a nullptr to signal failure.

clayborg abandoned this revision.Dec 13 2016, 2:53 PM

Ok, then string access is the way it should be. I'll make patches for the integers.

I thought you still wanted to get rid of the default value? It's just that Optional<PointerType> is redundant because pointers are already implicitly optional (via nullptr).