This is an archive of the discontinued LLVM Phabricator instance.

[Core] Remove use of ClangASTContext in DumpDataExtractor
ClosedPublic

Authored by xiaobai on Sep 5 2019, 2:34 PM.

Details

Summary

DumpDataExtractor uses ClangASTContext in order to get the proper llvm
fltSemantics for the type it needs so that it can dump floats in a more
precise way. However, there's no reason that this behavior needs to be
specific ClangASTContext. Instead, I think it makes sense to ask
TypeSystems for the float semantics for a type of a given size.

Event Timeline

xiaobai created this revision.Sep 5 2019, 2:34 PM
Herald added a project: Restricted Project. · View Herald TranscriptSep 5 2019, 2:34 PM
JDevlieghere accepted this revision.Sep 5 2019, 3:13 PM

Looks like a good improvement.

Does the APFloatBase::Bogus result of GetFloatTypeSemantics affect the functional behavior of the DumpDataExtractor or does GetAPInt just return None in that case?

This revision is now accepted and ready to land.Sep 5 2019, 3:13 PM

Hmm, good question. If you call GetAPInt with a byte_size of 0, it should assert when trying to read 0 bytes with the DataExtractor. In the worst case, it gives you a broken APInt. I think guarded the call to GetAPInt to protect against this, but I think that it would also be a good idea to make GetAPInt return llvm::None in that case.

clayborg accepted this revision.Sep 6 2019, 7:31 AM
xiaobai updated this revision to Diff 219145.Sep 6 2019, 11:05 AM

Refactored slightly to be a bit safer

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptSep 6 2019, 2:04 PM