llvm-project/lldb/include/lldb/API/SBSymbolContext.h
Pavel Labath 7f5237bccc Add "operator bool" to SB APIs
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
2019-03-11 13:58:46 +00:00

84 lines
2.3 KiB
C++

//===-- SBSymbolContext.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_SBSymbolContext_h_
#define LLDB_SBSymbolContext_h_
#include "lldb/API/SBBlock.h"
#include "lldb/API/SBCompileUnit.h"
#include "lldb/API/SBDefines.h"
#include "lldb/API/SBFunction.h"
#include "lldb/API/SBLineEntry.h"
#include "lldb/API/SBModule.h"
#include "lldb/API/SBSymbol.h"
namespace lldb {
class LLDB_API SBSymbolContext {
public:
SBSymbolContext();
SBSymbolContext(const lldb::SBSymbolContext &rhs);
SBSymbolContext(const lldb_private::SymbolContext *sc_ptr);
~SBSymbolContext();
explicit operator bool() const;
bool IsValid() const;
const lldb::SBSymbolContext &operator=(const lldb::SBSymbolContext &rhs);
lldb::SBModule GetModule();
lldb::SBCompileUnit GetCompileUnit();
lldb::SBFunction GetFunction();
lldb::SBBlock GetBlock();
lldb::SBLineEntry GetLineEntry();
lldb::SBSymbol GetSymbol();
void SetModule(lldb::SBModule module);
void SetCompileUnit(lldb::SBCompileUnit compile_unit);
void SetFunction(lldb::SBFunction function);
void SetBlock(lldb::SBBlock block);
void SetLineEntry(lldb::SBLineEntry line_entry);
void SetSymbol(lldb::SBSymbol symbol);
SBSymbolContext GetParentOfInlinedScope(const SBAddress &curr_frame_pc,
SBAddress &parent_frame_addr) const;
bool GetDescription(lldb::SBStream &description);
protected:
friend class SBAddress;
friend class SBFrame;
friend class SBModule;
friend class SBThread;
friend class SBTarget;
friend class SBSymbolContextList;
lldb_private::SymbolContext *operator->() const;
lldb_private::SymbolContext &operator*();
lldb_private::SymbolContext &ref();
const lldb_private::SymbolContext &operator*() const;
lldb_private::SymbolContext *get() const;
void SetSymbolContext(const lldb_private::SymbolContext *sc_ptr);
private:
std::unique_ptr<lldb_private::SymbolContext> m_opaque_up;
};
} // namespace lldb
#endif // LLDB_SBSymbolContext_h_