GaloisInc / llvm-pretty

An llvm pretty printer inspired by the haskell llvm binding
Other
28 stars 15 forks source link

Print identifiers with special characters as escaped quoted strings. #22

Closed brianhuffman closed 6 years ago

brianhuffman commented 6 years ago

This behavior matches the LLVM Language Reference Manual:

"Named values are represented as a string of characters with their prefix. For example, %foo, @DivisionByZero, %a.really.long.identifier. The actual regular expression used is ‘[%@][-a-zA-Z$._][-a-zA-Z$._0-9]*‘. Identifiers that require other characters in their names can be surrounded with quotes. Special characters may be escaped using "\xx" where xx is the ASCII code for the character in hexadecimal... Unnamed values are represented as an unsigned numeric value with their prefix. For example, %12, @2, %44."

elliottt commented 6 years ago

Thanks Brian! Are you still building from this repository, or do you need a hackage release soon?

brianhuffman commented 6 years ago

We're still building directly from this repo, so we're not waiting on a release.

brianhuffman commented 6 years ago

While creating this commit, I noticed that the string escaping function ppStringLiteral implicitly assumes that all characters are in the range 0x00 to 0xff. Perhaps Symbol and Ident should use ByteString instead of String? See GaloisInc/llvm-pretty-bc-parser#63

elliottt commented 6 years ago

That seems fine to me. If you're interested in pushing that change through that would be great, otherwise I'll make an issue so it doesn't get lost.

brianhuffman commented 6 years ago

I'll make another pull request for it. Or you could just give me push access if that's easier for you.

elliottt commented 6 years ago

You've actually got a pending invitation for commit access :)

brianhuffman commented 6 years ago

I have no idea where to find that invitation, and I've been looking for 10 minutes :(

EDIT: I finally found it in my personal email (although the accept invitation link went to a 404 page at first, until I pasted the link into a different browser where I was logged in to github)

elliottt commented 6 years ago

Well done github!