Remove some redundant BT_ASSERT and BT_ASSERT_DBG.
- Most `as*()` methods call a constructor that does the exact same
check. Some exceptions are field class types that have signed and
unsigned variants, where the base class' assertion does not check the
signedness. Another one is `CommonNullValue::asNull`, where the
`CommonNullValue` constructor does not take a lib object pointer, so
does not do a check.
- Things that end up constructing a `BorrowedObject` don't need to do
a null pointer check, as `BorrowedObject`'s constructor does one.
- `BorrowedObjectIterator::operator*` does not need an assertion on the
length, as `operator[]` of the container is expected to do it (either
directly, or rely on the preconditions in the lib).
Change-Id: I6f11680628607eee11164a2e9d3f9de7fc7468cb
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Reviewed-on: https://review.lttng.org/c/babeltrace/+/12052
Reviewed-by: Philippe Proulx <eeppeliteloop@gmail.com>
Object operator*() const noexcept
{
- BT_ASSERT_DBG(_mIdx < _mContainer.length());
return _mContainer[_mIdx];
}
template <typename LibObjT>
CommonBitArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asBitArray() const noexcept
{
- BT_ASSERT_DBG(this->isBitArray());
return CommonBitArrayFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonIntegerFieldClass<LibObjT> CommonFieldClass<LibObjT>::asInteger() const noexcept
{
- BT_ASSERT_DBG(this->isInteger());
return CommonIntegerFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonBaseEnumerationFieldClass<LibObjT> CommonFieldClass<LibObjT>::asEnumeration() const noexcept
{
- BT_ASSERT_DBG(this->isEnumeration());
return CommonBaseEnumerationFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStructureFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStructure() const noexcept
{
- BT_ASSERT_DBG(this->isStructure());
return CommonStructureFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asArray() const noexcept
{
- BT_ASSERT_DBG(this->isArray());
return CommonArrayFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStaticArrayFieldClass<LibObjT> CommonFieldClass<LibObjT>::asStaticArray() const noexcept
{
- BT_ASSERT_DBG(this->isStaticArray());
return CommonStaticArrayFieldClass<LibObjT> {this->libObjPtr()};
}
CommonDynamicArrayWithLengthFieldClass<LibObjT>
CommonFieldClass<LibObjT>::asDynamicArrayWithLength() const noexcept
{
- BT_ASSERT_DBG(this->isDynamicArrayWithLength());
return CommonDynamicArrayWithLengthFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonOptionFieldClass<LibObjT> CommonFieldClass<LibObjT>::asOption() const noexcept
{
- BT_ASSERT_DBG(this->isOption());
return CommonOptionFieldClass<LibObjT> {this->libObjPtr()};
}
CommonOptionWithSelectorFieldClass<LibObjT>
CommonFieldClass<LibObjT>::asOptionWithSelector() const noexcept
{
- BT_ASSERT_DBG(this->isOptionWithSelector());
return CommonOptionWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
}
CommonOptionWithBoolSelectorFieldClass<LibObjT>
CommonFieldClass<LibObjT>::asOptionWithBoolSelector() const noexcept
{
- BT_ASSERT_DBG(this->isOptionWithBoolSelector());
return CommonOptionWithBoolSelectorFieldClass<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonVariantFieldClass<LibObjT> CommonFieldClass<LibObjT>::asVariant() const noexcept
{
- BT_ASSERT_DBG(this->isVariant());
return CommonVariantFieldClass<LibObjT> {this->libObjPtr()};
}
CommonVariantWithoutSelectorFieldClass<LibObjT>
CommonFieldClass<LibObjT>::asVariantWithoutSelector() const noexcept
{
- BT_ASSERT_DBG(this->isVariantWithoutSelector());
return CommonVariantWithoutSelectorFieldClass<LibObjT> {this->libObjPtr()};
}
CommonVariantWithSelectorFieldClass<LibObjT>
CommonFieldClass<LibObjT>::asVariantWithSelector() const noexcept
{
- BT_ASSERT_DBG(this->isVariantWithSelector());
return CommonVariantWithSelectorFieldClass<LibObjT> {this->libObjPtr()};
}
inline ConstIndexFieldPathItem ConstFieldPathItem::asIndex() const noexcept
{
- BT_ASSERT_DBG(this->isIndex());
return ConstIndexFieldPathItem {this->libObjPtr()};
}
template <typename LibObjT>
CommonBoolField<LibObjT> CommonField<LibObjT>::asBool() const noexcept
{
- BT_ASSERT_DBG(this->isBool());
return CommonBoolField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonBitArrayField<LibObjT> CommonField<LibObjT>::asBitArray() const noexcept
{
- BT_ASSERT_DBG(this->isBitArray());
return CommonBitArrayField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonUnsignedIntegerField<LibObjT> CommonField<LibObjT>::asUnsignedInteger() const noexcept
{
- BT_ASSERT_DBG(this->isUnsignedInteger());
return CommonUnsignedIntegerField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonSignedIntegerField<LibObjT> CommonField<LibObjT>::asSignedInteger() const noexcept
{
- BT_ASSERT_DBG(this->isSignedInteger());
return CommonSignedIntegerField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonUnsignedEnumerationField<LibObjT> CommonField<LibObjT>::asUnsignedEnumeration() const noexcept
{
- BT_ASSERT_DBG(this->isUnsignedEnumeration());
return CommonUnsignedEnumerationField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonSignedEnumerationField<LibObjT> CommonField<LibObjT>::asSignedEnumeration() const noexcept
{
- BT_ASSERT_DBG(this->isSignedEnumeration());
return CommonSignedEnumerationField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonSinglePrecisionRealField<LibObjT> CommonField<LibObjT>::asSinglePrecisionReal() const noexcept
{
- BT_ASSERT_DBG(this->isSinglePrecisionReal());
return CommonSinglePrecisionRealField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonDoublePrecisionRealField<LibObjT> CommonField<LibObjT>::asDoublePrecisionReal() const noexcept
{
- BT_ASSERT_DBG(this->isDoublePrecisionReal());
return CommonDoublePrecisionRealField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStringField<LibObjT> CommonField<LibObjT>::asString() const noexcept
{
- BT_ASSERT_DBG(this->isString());
return CommonStringField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStructureField<LibObjT> CommonField<LibObjT>::asStructure() const noexcept
{
- BT_ASSERT_DBG(this->isStructure());
return CommonStructureField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonArrayField<LibObjT> CommonField<LibObjT>::asArray() const noexcept
{
- BT_ASSERT_DBG(this->isArray());
return CommonArrayField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonDynamicArrayField<LibObjT> CommonField<LibObjT>::asDynamicArray() const noexcept
{
- BT_ASSERT_DBG(this->isDynamicArray());
return CommonDynamicArrayField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonOptionField<LibObjT> CommonField<LibObjT>::asOption() const noexcept
{
- BT_ASSERT_DBG(this->isOption());
return CommonOptionField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonVariantField<LibObjT> CommonField<LibObjT>::asVariant() const noexcept
{
- BT_ASSERT_DBG(this->isVariant());
return CommonVariantField<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStreamBeginningMessage<LibObjT> CommonMessage<LibObjT>::asStreamBeginning() const noexcept
{
- BT_ASSERT_DBG(this->isStreamBeginning());
return CommonStreamBeginningMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStreamEndMessage<LibObjT> CommonMessage<LibObjT>::asStreamEnd() const noexcept
{
- BT_ASSERT_DBG(this->isStreamEnd());
return CommonStreamEndMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonPacketBeginningMessage<LibObjT> CommonMessage<LibObjT>::asPacketBeginning() const noexcept
{
- BT_ASSERT_DBG(this->isPacketBeginning());
return CommonPacketBeginningMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonPacketEndMessage<LibObjT> CommonMessage<LibObjT>::asPacketEnd() const noexcept
{
- BT_ASSERT_DBG(this->isPacketEnd());
return CommonPacketEndMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonEventMessage<LibObjT> CommonMessage<LibObjT>::asEvent() const noexcept
{
- BT_ASSERT_DBG(this->isEvent());
return CommonEventMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonDiscardedEventsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedEvents() const noexcept
{
- BT_ASSERT_DBG(this->isDiscardedEvents());
return CommonDiscardedEventsMessage<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonDiscardedPacketsMessage<LibObjT> CommonMessage<LibObjT>::asDiscardedPackets() const noexcept
{
- BT_ASSERT_DBG(this->isDiscardedPackets());
return CommonDiscardedPacketsMessage<LibObjT> {this->libObjPtr()};
}
CommonMessageIteratorInactivityMessage<LibObjT>
CommonMessage<LibObjT>::asMessageIteratorInactivity() const noexcept
{
- BT_ASSERT_DBG(this->isMessageIteratorInactivity());
return CommonMessageIteratorInactivityMessage<LibObjT> {this->libObjPtr()};
}
#include <type_traits>
-#include "common/assert.h"
-
#include "borrowed-object-proxy.hpp"
namespace bt2 {
ObjT object() const noexcept
{
- BT_ASSERT_DBG(_mLibObjPtr);
return ObjT {_mLibObjPtr};
}
#include "logging.hpp"
-#include "common/assert.h"
#include "cpp-common/bt2c/c-string-view.hpp"
#include "borrowed-object-iterator.hpp"
switch (status) {
case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_OK:
- BT_ASSERT(libMsgIterPtr);
return MessageIterator::Shared::createWithoutRef(libMsgIterPtr);
case BT_MESSAGE_ITERATOR_CREATE_FROM_SINK_COMPONENT_STATUS_MEMORY_ERROR:
throw MemoryError {};
#include <babeltrace2/babeltrace.h>
-#include "common/assert.h"
#include "common/common.h"
#include "borrowed-object.hpp"
switch (status) {
case BT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_OK:
- BT_ASSERT(libMsgIterPtr);
return MessageIterator::Shared::createWithoutRef(libMsgIterPtr);
case BT_MESSAGE_ITERATOR_CREATE_FROM_MESSAGE_ITERATOR_STATUS_MEMORY_ERROR:
throw MemoryError {};
#include <utility>
-#include "common/assert.h"
-
#include "optional-borrowed-object.hpp"
namespace bt2 {
ObjT operator*() const noexcept
{
- BT_ASSERT_DBG(_mObj);
return *_mObj;
}
BorrowedObjectProxy<ObjT> operator->() const noexcept
{
- BT_ASSERT_DBG(_mObj);
return _mObj.operator->();
}
*/
ObjT release() noexcept
{
- BT_ASSERT_DBG(_mObj);
-
const auto obj = *_mObj;
this->_reset();
template <typename LibObjT>
CommonBoolValue<LibObjT> CommonValue<LibObjT>::asBool() const noexcept
{
- BT_ASSERT_DBG(this->isBool());
return CommonBoolValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonSignedIntegerValue<LibObjT> CommonValue<LibObjT>::asSignedInteger() const noexcept
{
- BT_ASSERT_DBG(this->isSignedInteger());
return CommonSignedIntegerValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonUnsignedIntegerValue<LibObjT> CommonValue<LibObjT>::asUnsignedInteger() const noexcept
{
- BT_ASSERT_DBG(this->isUnsignedInteger());
return CommonUnsignedIntegerValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonRealValue<LibObjT> CommonValue<LibObjT>::asReal() const noexcept
{
- BT_ASSERT_DBG(this->isReal());
return CommonRealValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonStringValue<LibObjT> CommonValue<LibObjT>::asString() const noexcept
{
- BT_ASSERT_DBG(this->isString());
return CommonStringValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonArrayValue<LibObjT> CommonValue<LibObjT>::asArray() const noexcept
{
- BT_ASSERT_DBG(this->isArray());
return CommonArrayValue<LibObjT> {this->libObjPtr()};
}
template <typename LibObjT>
CommonMapValue<LibObjT> CommonValue<LibObjT>::asMap() const noexcept
{
- BT_ASSERT_DBG(this->isMap());
return CommonMapValue<LibObjT> {this->libObjPtr()};
}