Skip to content

Commit

Permalink
Add "operator bool" to SB APIs
Browse files Browse the repository at this point in the history
Summary:
Our python version of the SB API has (the python equivalent of)
operator bool, but the C++ version doesn't.

This is because our python operators are added by modify-python-lldb.py,
which performs postprocessing on the swig-generated interface files.

In this patch, I add the "operator bool" to all SB classes which have an
IsValid method (which is the same logic used by modify-python-lldb.py).
This way, we make the two interfaces more constent, and it allows us to
rely on swig's automatic syntesis of python __nonzero__ methods instead
of doing manual fixups.

Reviewers: zturner, jingham, clayborg, jfb, serge-sans-paille

Subscribers: jdoerfert, lldb-commits

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

llvm-svn: 355824
  • Loading branch information
labath committed Mar 11, 2019
1 parent 52760bf commit 7f5237b
Show file tree
Hide file tree
Showing 168 changed files with 551 additions and 18 deletions.
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBAddress.h
Expand Up @@ -29,6 +29,8 @@ class LLDB_API SBAddress {

const lldb::SBAddress &operator=(const lldb::SBAddress &rhs);

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBlock.h
Expand Up @@ -28,6 +28,8 @@ class LLDB_API SBBlock {

bool IsInlined() const;

explicit operator bool() const;

bool IsValid() const;

const char *GetInlinedName() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBreakpoint.h
Expand Up @@ -36,6 +36,8 @@ class LLDB_API SBBreakpoint {

break_id_t GetID() const;

explicit operator bool() const;

bool IsValid() const;

void ClearAllBreakpointSites();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBreakpointLocation.h
Expand Up @@ -27,6 +27,8 @@ class LLDB_API SBBreakpointLocation {

break_id_t GetID();

explicit operator bool() const;

bool IsValid() const;

lldb::SBAddress GetAddress();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBreakpointName.h
Expand Up @@ -39,6 +39,8 @@ class LLDB_API SBBreakpointName {

bool operator!=(const lldb::SBBreakpointName &rhs);

explicit operator bool() const;

bool IsValid() const;

const char *GetName() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBBroadcaster.h
Expand Up @@ -25,6 +25,8 @@ class LLDB_API SBBroadcaster {

~SBBroadcaster();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
4 changes: 4 additions & 0 deletions lldb/include/lldb/API/SBCommandInterpreter.h
Expand Up @@ -87,6 +87,8 @@ class SBCommandInterpreter {

static bool EventIsCommandInterpreterEvent(const lldb::SBEvent &event);

explicit operator bool() const;

bool IsValid() const;

bool CommandExists(const char *cmd);
Expand Down Expand Up @@ -272,6 +274,8 @@ class SBCommand {
public:
SBCommand();

explicit operator bool() const;

bool IsValid();

const char *GetName();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBCommandReturnObject.h
Expand Up @@ -32,6 +32,8 @@ class LLDB_API SBCommandReturnObject {

lldb_private::CommandReturnObject *Release();

explicit operator bool() const;

bool IsValid() const;

const char *GetOutput();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBCommunication.h
Expand Up @@ -37,6 +37,8 @@ class LLDB_API SBCommunication {
SBCommunication(const char *broadcaster_name);
~SBCommunication();

explicit operator bool() const;

bool IsValid() const;

lldb::SBBroadcaster GetBroadcaster();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBCompileUnit.h
Expand Up @@ -24,6 +24,8 @@ class LLDB_API SBCompileUnit {

const lldb::SBCompileUnit &operator=(const lldb::SBCompileUnit &rhs);

explicit operator bool() const;

bool IsValid() const;

lldb::SBFileSpec GetFileSpec() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBData.h
Expand Up @@ -29,6 +29,8 @@ class LLDB_API SBData {

void Clear();

explicit operator bool() const;

bool IsValid();

size_t GetByteSize();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBDebugger.h
Expand Up @@ -62,6 +62,8 @@ class LLDB_API SBDebugger {

static void MemoryPressureDetected();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBDeclaration.h
Expand Up @@ -25,6 +25,8 @@ class LLDB_API SBDeclaration {

const lldb::SBDeclaration &operator=(const lldb::SBDeclaration &rhs);

explicit operator bool() const;

bool IsValid() const;

lldb::SBFileSpec GetFileSpec() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBError.h
Expand Up @@ -46,6 +46,8 @@ class LLDB_API SBError {
int SetErrorStringWithFormat(const char *format, ...)
__attribute__((format(printf, 2, 3)));

explicit operator bool() const;

bool IsValid() const;

bool GetDescription(lldb::SBStream &description);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBEvent.h
Expand Up @@ -35,6 +35,8 @@ class LLDB_API SBEvent {

const SBEvent &operator=(const lldb::SBEvent &rhs);

explicit operator bool() const;

bool IsValid() const;

const char *GetDataFlavor();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBFileSpec.h
Expand Up @@ -28,6 +28,8 @@ class LLDB_API SBFileSpec {

const SBFileSpec &operator=(const lldb::SBFileSpec &rhs);

explicit operator bool() const;

bool IsValid() const;

bool Exists() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBFrame.h
Expand Up @@ -26,6 +26,8 @@ class LLDB_API SBFrame {

bool IsEqual(const lldb::SBFrame &that) const;

explicit operator bool() const;

bool IsValid() const;

uint32_t GetFrameID() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBFunction.h
Expand Up @@ -25,6 +25,8 @@ class LLDB_API SBFunction {

~SBFunction();

explicit operator bool() const;

bool IsValid() const;

const char *GetName() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBInstruction.h
Expand Up @@ -31,6 +31,8 @@ class LLDB_API SBInstruction {

~SBInstruction();

explicit operator bool() const;

bool IsValid();

SBAddress GetAddress();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBInstructionList.h
Expand Up @@ -25,6 +25,8 @@ class LLDB_API SBInstructionList {

~SBInstructionList();

explicit operator bool() const;

bool IsValid() const;

size_t GetSize();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBLineEntry.h
Expand Up @@ -29,6 +29,8 @@ class LLDB_API SBLineEntry {

lldb::SBAddress GetEndAddress() const;

explicit operator bool() const;

bool IsValid() const;

lldb::SBFileSpec GetFileSpec() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBListener.h
Expand Up @@ -29,6 +29,8 @@ class LLDB_API SBListener {

void Clear();

explicit operator bool() const;

bool IsValid() const;

uint32_t StartListeningForEventClass(SBDebugger &debugger,
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBModule.h
Expand Up @@ -31,6 +31,8 @@ class LLDB_API SBModule {

~SBModule();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBModuleSpec.h
Expand Up @@ -24,6 +24,8 @@ class LLDB_API SBModuleSpec {

const SBModuleSpec &operator=(const SBModuleSpec &rhs);

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBPlatform.h
Expand Up @@ -91,6 +91,8 @@ class LLDB_API SBPlatform {

~SBPlatform();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBProcess.h
Expand Up @@ -51,6 +51,8 @@ class LLDB_API SBProcess {

void Clear();

explicit operator bool() const;

bool IsValid() const;

lldb::SBTarget GetTarget() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBProcessInfo.h
Expand Up @@ -22,6 +22,8 @@ class LLDB_API SBProcessInfo {

SBProcessInfo &operator=(const SBProcessInfo &rhs);

explicit operator bool() const;

bool IsValid() const;

const char *GetName();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBQueue.h
Expand Up @@ -28,6 +28,8 @@ class LLDB_API SBQueue {

~SBQueue();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBQueueItem.h
Expand Up @@ -22,6 +22,8 @@ class LLDB_API SBQueueItem {

~SBQueueItem();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBSection.h
Expand Up @@ -24,6 +24,8 @@ class LLDB_API SBSection {

const lldb::SBSection &operator=(const lldb::SBSection &rhs);

explicit operator bool() const;

bool IsValid() const;

const char *GetName();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBStream.h
Expand Up @@ -23,6 +23,8 @@ class LLDB_API SBStream {

~SBStream();

explicit operator bool() const;

bool IsValid() const;

// If this stream is not redirected to a file, it will maintain a local cache
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBStringList.h
Expand Up @@ -23,6 +23,8 @@ class LLDB_API SBStringList {

~SBStringList();

explicit operator bool() const;

bool IsValid() const;

void AppendString(const char *str);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBStructuredData.h
Expand Up @@ -28,6 +28,8 @@ class SBStructuredData {

lldb::SBStructuredData &operator=(const lldb::SBStructuredData &rhs);

explicit operator bool() const;

bool IsValid() const;

lldb::SBError SetFromJSON(lldb::SBStream &stream);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBSymbol.h
Expand Up @@ -26,6 +26,8 @@ class LLDB_API SBSymbol {

const lldb::SBSymbol &operator=(const lldb::SBSymbol &rhs);

explicit operator bool() const;

bool IsValid() const;

const char *GetName() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBSymbolContext.h
Expand Up @@ -29,6 +29,8 @@ class LLDB_API SBSymbolContext {

~SBSymbolContext();

explicit operator bool() const;

bool IsValid() const;

const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBSymbolContextList.h
Expand Up @@ -25,6 +25,8 @@ class LLDB_API SBSymbolContextList {
const lldb::SBSymbolContextList &
operator=(const lldb::SBSymbolContextList &rhs);

explicit operator bool() const;

bool IsValid() const;

uint32_t GetSize() const;
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBTarget.h
Expand Up @@ -55,6 +55,8 @@ class LLDB_API SBTarget {

const lldb::SBTarget &operator=(const lldb::SBTarget &rhs);

explicit operator bool() const;

bool IsValid() const;

static bool EventIsTargetEvent(const lldb::SBEvent &event);
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBThread.h
Expand Up @@ -39,6 +39,8 @@ class LLDB_API SBThread {

lldb::SBQueue GetQueue() const;

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBThreadCollection.h
Expand Up @@ -23,6 +23,8 @@ class LLDB_API SBThreadCollection {

~SBThreadCollection();

explicit operator bool() const;

bool IsValid() const;

size_t GetSize();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBThreadPlan.h
Expand Up @@ -30,6 +30,8 @@ class LLDB_API SBThreadPlan {

~SBThreadPlan();

explicit operator bool() const;

bool IsValid() const;

void Clear();
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBTrace.h
Expand Up @@ -100,6 +100,8 @@ class LLDB_API SBTrace {

lldb::user_id_t GetTraceUID();

explicit operator bool() const;

bool IsValid();

protected:
Expand Down
2 changes: 2 additions & 0 deletions lldb/include/lldb/API/SBTraceOptions.h
Expand Up @@ -44,6 +44,8 @@ class LLDB_API SBTraceOptions {

lldb::tid_t getThreadID();

explicit operator bool() const;

bool IsValid();

protected:
Expand Down

0 comments on commit 7f5237b

Please sign in to comment.