[Lldb-commits] [PATCH] D17088: Add target and host platform enums so we're not using strings everywhere

Zachary Turner via lldb-commits lldb-commits at lists.llvm.org
Wed Feb 10 11:56:19 PST 2016

zturner created this revision.
zturner added reviewers: tfiala, labath, tberghammer.
zturner added a subscriber: lldb-commits.
Herald added subscribers: srhines, danalbert, tberghammer.

The original motivation for this came when I tried to combine two decorators:


into a single decorator:


This results in a really ugly syntax, because `@expectedFailureDarwin` calls `getDarwinOsTriples()` which is itself a list.  So you would have to do something like this:


Not the end of the world, but not ideal either.  Then I remembered that we've all had this ugliness surrounding the translation of python api calls such as `sys.name`, `os.platform`, and target names and host names into something consistent, so it occurred to me that many things would become cleaner and more elegant if we had actual enums for everything, and a centralized place where we can convert between enums and strings or whatever else we need.

So this patch introduces two enums.  `target` and `host`, updates the common decorator to support these values from these enums, and changes two decorators to using these new values as a proof of concept.

One nice thing about these enums is that we can make standardized enum values for "combinations" of targets or hosts where it makes sense (such as is the case of with darwin, which is why the `getDarwinOsTriples()` function existed in the first place.  So in that sense it works similarly to a flags enum in C / C++.

Eventually it would be nice if we could start using these enums all over the codebase instead of using strings everywhere, but this patch does not attempt to solve that problem.



-------------- next part --------------
A non-text attachment was scrubbed...
Name: D17088.47498.patch
Type: text/x-patch
Size: 6563 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20160210/6fdac10b/attachment.bin>

More information about the lldb-commits mailing list