HomePhabricator

Don't type-erase the SymbolContextItem enumeration.

Description

Don't type-erase the SymbolContextItem enumeration.

When we get the resolve_scope parameter from the SB API, it's a
uint32_t. We then pass it through all of LLDB this way, as a uint32.
This is unfortunate, because it means the user of an API never actually
knows what they're dealing with. We can call it something like
resolve_scope and have comments saying "this is a value from the
SymbolContextItem enumeration, but it makes more sense to just have it
actually *be* the correct type in the actual C++ type system to begin
with. This way the person reading the code just knows what it is.

The reason to use integers instead of enumerations for flags is because
when you do bitwise operations on enumerations they get promoted to
integers, so it makes it tedious to constantly be casting them back
to the enumeration types, so I've introduced a macro to make this
happen magically. By writing LLDB_MARK_AS_BITMASK_ENUM after defining
an enumeration, it will define overloaded operators so that the
returned type will be the original enum. This should address all
the mechanical issues surrounding using rich enum types directly.

This way, we get a better debugger experience, and new users to
the codebase can get more easily acquainted with the codebase because
their IDE features can help them understand what the types mean.

Differential Revision: https://reviews.llvm.org/D53597

Details

Committed
zturnerOct 25 2018, 1:45 PM
Differential Revision
D53597: Don't type-erase the SymbolContextItem enum
Parents
rL345312: [NFC] Refactor SetBaseClasses and DeleteBaseClasses.
Branches
Unknown
Tags
Unknown