llvm/lldb/include/lldb/lldb-enumerations.h

//===-- lldb-enumerations.h -------------------------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLDB_LLDB_ENUMERATIONS_H
#define LLDB_LLDB_ENUMERATIONS_H

#include <cstdint>
#include <type_traits>

#ifndef SWIG
// Macro to enable bitmask operations on an enum.  Without this, Enum | Enum
// gets promoted to an int, so you have to say Enum a = Enum(eFoo | eBar).  If
// you mark Enum with LLDB_MARK_AS_BITMASK_ENUM(Enum), however, you can simply
// write Enum a = eFoo | eBar.
// Unfortunately, swig<3.0 doesn't recognise the constexpr keyword, so remove
// this entire block, as it is not necessary for swig processing.
#define LLDB_MARK_AS_BITMASK_ENUM(Enum)
#else
#define LLDB_MARK_AS_BITMASK_ENUM
#endif

#ifndef SWIG
// With MSVC, the default type of an enum is always signed, even if one of the
// enumerator values is too large to fit into a signed integer but would
// otherwise fit into an unsigned integer.  As a result of this, all of LLDB's
// flag-style enumerations that specify something like eValueFoo = 1u << 31
// result in negative values.  This usually just results in a benign warning,
// but in a few places we actually do comparisons on the enum values, which
// would cause a real bug.  Furthermore, there's no way to silence only this
// warning, as it's part of -Wmicrosoft which also catches a whole slew of
// other useful issues.
//
// To make matters worse, early versions of SWIG don't recognize the syntax of
// specifying the underlying type of an enum (and Python doesn't care anyway)
// so we need a way to specify the underlying type when the enum is being used
// from C++ code, but just use a regular enum when swig is pre-processing.
#define FLAGS_ENUM(Name)
#define FLAGS_ANONYMOUS_ENUM()
#else
#define FLAGS_ENUM
#define FLAGS_ANONYMOUS_ENUM
#endif

lldb // namespace lldb

#endif // LLDB_LLDB_ENUMERATIONS_H