forked from qt-creator/qt-creator
C++: Use soft asserts instead of assert()
Some qmake versions ignore "DEFINES += NDEBUG" on Windows. Change-Id: Ibdf3b1036c2331dcef61dcd278463c02754044d2 Reviewed-by: Erik Verbruggen <erik.verbruggen@digia.com>
This commit is contained in:
5
src/libs/3rdparty/cplusplus/AST.cpp
vendored
5
src/libs/3rdparty/cplusplus/AST.cpp
vendored
@@ -23,7 +23,8 @@
|
||||
#include "ASTMatcher.h"
|
||||
#include "MemoryPool.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "cppassert.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
|
||||
@@ -42,7 +43,7 @@ AST::AST()
|
||||
{ }
|
||||
|
||||
AST::~AST()
|
||||
{ assert(0); }
|
||||
{ CPP_CHECK(0); }
|
||||
|
||||
void AST::accept(ASTVisitor *visitor)
|
||||
{
|
||||
|
||||
4
src/libs/3rdparty/cplusplus/AST.h
vendored
4
src/libs/3rdparty/cplusplus/AST.h
vendored
@@ -47,7 +47,7 @@ public:
|
||||
if (value)
|
||||
return value->firstToken();
|
||||
|
||||
// ### assert(0);
|
||||
// ### CPP_CHECK(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -58,7 +58,7 @@ public:
|
||||
if (lv)
|
||||
return lv->lastToken();
|
||||
|
||||
// ### assert(0);
|
||||
// ### CPP_CHECK(0);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
63
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
63
src/libs/3rdparty/cplusplus/Bind.cpp
vendored
@@ -27,10 +27,13 @@
|
||||
#include "CoreTypes.h"
|
||||
#include "Literals.h"
|
||||
#include "Scope.h"
|
||||
|
||||
#include "cppassert.h"
|
||||
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <memory>
|
||||
#include <cassert>
|
||||
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -285,7 +288,7 @@ void Bind::postVisit(AST *)
|
||||
bool Bind::visit(ObjCSelectorArgumentAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -303,7 +306,7 @@ const Name *Bind::objCSelectorArgument(ObjCSelectorArgumentAST *ast, bool *hasAr
|
||||
bool Bind::visit(AttributeAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -331,7 +334,7 @@ void Bind::attribute(AttributeAST *ast)
|
||||
bool Bind::visit(DeclaratorAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -380,14 +383,14 @@ FullySpecifiedType Bind::declarator(DeclaratorAST *ast, const FullySpecifiedType
|
||||
bool Bind::visit(QtPropertyDeclarationItemAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool Bind::visit(QtInterfaceNameAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -405,7 +408,7 @@ void Bind::qtInterfaceName(QtInterfaceNameAST *ast)
|
||||
bool Bind::visit(BaseSpecifierAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -433,7 +436,7 @@ void Bind::baseSpecifier(BaseSpecifierAST *ast, unsigned colon_token, Class *kla
|
||||
bool Bind::visit(CtorInitializerAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -452,7 +455,7 @@ void Bind::ctorInitializer(CtorInitializerAST *ast, Function *fun)
|
||||
bool Bind::visit(EnumeratorAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -482,7 +485,7 @@ void Bind::enumerator(EnumeratorAST *ast, Enum *symbol)
|
||||
bool Bind::visit(DynamicExceptionSpecificationAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -510,7 +513,7 @@ FullySpecifiedType Bind::exceptionSpecification(ExceptionSpecificationAST *ast,
|
||||
bool Bind::visit(MemInitializerAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -529,7 +532,7 @@ void Bind::memInitializer(MemInitializerAST *ast, Function *fun)
|
||||
bool Bind::visit(NestedNameSpecifierAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -568,7 +571,7 @@ void Bind::newPlacement(ExpressionListParenAST *ast)
|
||||
bool Bind::visit(NewArrayDeclaratorAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -588,7 +591,7 @@ FullySpecifiedType Bind::newArrayDeclarator(NewArrayDeclaratorAST *ast, const Fu
|
||||
bool Bind::visit(NewTypeIdAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -615,7 +618,7 @@ FullySpecifiedType Bind::newTypeId(NewTypeIdAST *ast)
|
||||
bool Bind::visit(OperatorAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -807,7 +810,7 @@ OperatorNameId::Kind Bind::cppOperator(OperatorAST *ast)
|
||||
bool Bind::visit(ParameterDeclarationClauseAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -836,7 +839,7 @@ void Bind::parameterDeclarationClause(ParameterDeclarationClauseAST *ast, unsign
|
||||
bool Bind::visit(TranslationUnitAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -853,7 +856,7 @@ void Bind::translationUnit(TranslationUnitAST *ast)
|
||||
bool Bind::visit(ObjCProtocolRefsAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -875,7 +878,7 @@ void Bind::objCProtocolRefs(ObjCProtocolRefsAST *ast, Symbol *objcClassOrProtoco
|
||||
bool Bind::visit(ObjCMessageArgumentAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -890,7 +893,7 @@ void Bind::objCMessageArgument(ObjCMessageArgumentAST *ast)
|
||||
bool Bind::visit(ObjCTypeNameAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -907,7 +910,7 @@ FullySpecifiedType Bind::objCTypeName(ObjCTypeNameAST *ast)
|
||||
bool Bind::visit(ObjCInstanceVariablesDeclarationAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -928,7 +931,7 @@ void Bind::objCInstanceVariablesDeclaration(ObjCInstanceVariablesDeclarationAST
|
||||
bool Bind::visit(ObjCPropertyAttributeAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -945,7 +948,7 @@ void Bind::objCPropertyAttribute(ObjCPropertyAttributeAST *ast)
|
||||
bool Bind::visit(ObjCMessageArgumentDeclarationAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -970,7 +973,7 @@ void Bind::objCMessageArgumentDeclaration(ObjCMessageArgumentDeclarationAST *ast
|
||||
bool Bind::visit(ObjCMethodPrototypeAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1013,7 +1016,7 @@ ObjCMethod *Bind::objCMethodPrototype(ObjCMethodPrototypeAST *ast)
|
||||
bool Bind::visit(ObjCSynthesizedPropertyAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1030,7 +1033,7 @@ void Bind::objCSynthesizedProperty(ObjCSynthesizedPropertyAST *ast)
|
||||
bool Bind::visit(LambdaIntroducerAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1047,7 +1050,7 @@ void Bind::lambdaIntroducer(LambdaIntroducerAST *ast)
|
||||
bool Bind::visit(LambdaCaptureAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1065,7 +1068,7 @@ void Bind::lambdaCapture(LambdaCaptureAST *ast)
|
||||
bool Bind::visit(CaptureAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1080,7 +1083,7 @@ void Bind::capture(CaptureAST *ast)
|
||||
bool Bind::visit(LambdaDeclaratorAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -1111,7 +1114,7 @@ void Bind::lambdaDeclarator(LambdaDeclaratorAST *ast)
|
||||
bool Bind::visit(TrailingReturnTypeAST *ast)
|
||||
{
|
||||
(void) ast;
|
||||
assert(!"unreachable");
|
||||
CPP_CHECK(!"unreachable");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
16
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
16
src/libs/3rdparty/cplusplus/Lexer.cpp
vendored
@@ -22,8 +22,10 @@
|
||||
#include "Control.h"
|
||||
#include "TranslationUnit.h"
|
||||
#include "Literals.h"
|
||||
|
||||
#include "cppassert.h"
|
||||
|
||||
#include <cctype>
|
||||
#include <cassert>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -210,7 +212,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
case '\\':
|
||||
while (_yychar != '\n' && std::isspace(_yychar))
|
||||
yyinp();
|
||||
// ### assert(! _yychar || _yychar == '\n');
|
||||
// ### CPP_CHECK(! _yychar || _yychar == '\n');
|
||||
if (_yychar == '\n') {
|
||||
tok->f.joined = true;
|
||||
tok->f.newline = false;
|
||||
@@ -278,7 +280,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
tok->f.kind = T_DOT_STAR;
|
||||
} else if (_yychar == '.') {
|
||||
yyinp();
|
||||
// ### assert(_yychar);
|
||||
// ### CPP_CHECK(_yychar);
|
||||
if (_yychar == '.') {
|
||||
yyinp();
|
||||
tok->f.kind = T_DOT_DOT_DOT;
|
||||
@@ -292,7 +294,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
yyinp();
|
||||
if (_yychar == '-' || _yychar == '+') {
|
||||
yyinp();
|
||||
// ### assert(std::isdigit(_yychar));
|
||||
// ### CPP_CHECK(std::isdigit(_yychar));
|
||||
}
|
||||
} else if (std::isalnum(_yychar) || _yychar == '.') {
|
||||
yyinp();
|
||||
@@ -497,7 +499,7 @@ void Lexer::scan_helper(Token *tok)
|
||||
while (_yychar && _yychar != '>')
|
||||
yyinp();
|
||||
int yylen = _currentChar - yytext;
|
||||
// ### assert(_yychar == '>');
|
||||
// ### CPP_CHECK(_yychar == '>');
|
||||
if (_yychar == '>')
|
||||
yyinp();
|
||||
if (control())
|
||||
@@ -709,7 +711,7 @@ void Lexer::scanCharLiteral(Token *tok, unsigned char hint)
|
||||
|
||||
void Lexer::scanUntilQuote(Token *tok, unsigned char quote)
|
||||
{
|
||||
assert(quote == '"' || quote == '\'');
|
||||
CPP_CHECK(quote == '"' || quote == '\'');
|
||||
|
||||
const char *yytext = _currentChar;
|
||||
while (_yychar
|
||||
@@ -740,7 +742,7 @@ void Lexer::scanNumericLiteral(Token *tok)
|
||||
yyinp();
|
||||
if (_yychar == '-' || _yychar == '+') {
|
||||
yyinp();
|
||||
// ### assert(std::isdigit(_yychar));
|
||||
// ### CPP_CHECK(std::isdigit(_yychar));
|
||||
}
|
||||
} else if (std::isalnum(_yychar) || _yychar == '.') {
|
||||
yyinp();
|
||||
|
||||
6
src/libs/3rdparty/cplusplus/MemoryPool.cpp
vendored
6
src/libs/3rdparty/cplusplus/MemoryPool.cpp
vendored
@@ -19,8 +19,10 @@
|
||||
// THE SOFTWARE.
|
||||
|
||||
#include "MemoryPool.h"
|
||||
|
||||
#include "cppassert.h"
|
||||
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -52,7 +54,7 @@ void MemoryPool::reset()
|
||||
|
||||
void *MemoryPool::allocate_helper(size_t size)
|
||||
{
|
||||
assert(size < BLOCK_SIZE);
|
||||
CPP_CHECK(size < BLOCK_SIZE);
|
||||
|
||||
if (++_blockCount == _allocatedBlocks) {
|
||||
if (! _allocatedBlocks)
|
||||
|
||||
3
src/libs/3rdparty/cplusplus/Names.cpp
vendored
3
src/libs/3rdparty/cplusplus/Names.cpp
vendored
@@ -21,9 +21,8 @@
|
||||
#include "Names.h"
|
||||
#include "NameVisitor.h"
|
||||
#include "Literals.h"
|
||||
#include <cstring>
|
||||
#include <cassert>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
|
||||
7
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
7
src/libs/3rdparty/cplusplus/Scope.cpp
vendored
@@ -23,7 +23,9 @@
|
||||
#include "Names.h"
|
||||
#include "Literals.h"
|
||||
#include "Templates.h"
|
||||
#include <cassert>
|
||||
|
||||
#include "cppassert.h"
|
||||
|
||||
#include <cstring>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
@@ -107,6 +109,8 @@ SymbolTable::~SymbolTable()
|
||||
|
||||
void SymbolTable::enterSymbol(Symbol *symbol)
|
||||
{
|
||||
CPP_ASSERT(! symbol->_scope || symbol->enclosingScope() == _owner, return);
|
||||
|
||||
if (++_symbolCount == _allocatedSymbols) {
|
||||
_allocatedSymbols <<= 1;
|
||||
if (! _allocatedSymbols)
|
||||
@@ -115,7 +119,6 @@ void SymbolTable::enterSymbol(Symbol *symbol)
|
||||
_symbols = reinterpret_cast<Symbol **>(realloc(_symbols, sizeof(Symbol *) * _allocatedSymbols));
|
||||
}
|
||||
|
||||
assert(! symbol->_scope || symbol->enclosingScope() == _owner);
|
||||
symbol->_index = _symbolCount;
|
||||
symbol->_scope = _owner;
|
||||
_symbols[_symbolCount] = symbol;
|
||||
|
||||
6
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
6
src/libs/3rdparty/cplusplus/Symbol.cpp
vendored
@@ -29,7 +29,9 @@
|
||||
#include "NameVisitor.h"
|
||||
#include "Scope.h"
|
||||
#include "Templates.h"
|
||||
#include <cassert>
|
||||
|
||||
#include "cppassert.h"
|
||||
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -233,7 +235,7 @@ Scope *Symbol::enclosingScope() const
|
||||
|
||||
void Symbol::setScope(Scope *scope)
|
||||
{
|
||||
assert(! _scope);
|
||||
CPP_CHECK(! _scope);
|
||||
_scope = scope;
|
||||
}
|
||||
|
||||
|
||||
9
src/libs/3rdparty/cplusplus/Templates.cpp
vendored
9
src/libs/3rdparty/cplusplus/Templates.cpp
vendored
@@ -25,7 +25,8 @@
|
||||
#include "Names.h"
|
||||
#include "Literals.h"
|
||||
|
||||
#include <cassert>
|
||||
#include "cppassert.h"
|
||||
|
||||
|
||||
using namespace CPlusPlus;
|
||||
|
||||
@@ -184,7 +185,7 @@ Symbol *CloneSymbol::cloneSymbol(Symbol *symbol, Subst *subst)
|
||||
accept(symbol);
|
||||
std::swap(_symbol, r);
|
||||
std::swap(_subst, subst);
|
||||
assert(r != 0);
|
||||
CPP_CHECK(r != 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -399,7 +400,7 @@ const Name *CloneName::cloneName(const Name *name, Subst *subst)
|
||||
accept(name);
|
||||
std::swap(_name, r);
|
||||
std::swap(_subst, subst);
|
||||
assert(r != 0);
|
||||
CPP_CHECK(r != 0);
|
||||
return r;
|
||||
}
|
||||
|
||||
@@ -448,7 +449,7 @@ void CloneName::visit(const QualifiedNameId *name)
|
||||
|
||||
void CloneName::visit(const SelectorNameId *name)
|
||||
{
|
||||
assert(name->nameCount() > 0);
|
||||
CPP_CHECK(name->nameCount() > 0);
|
||||
std::vector<const Name *> names(name->nameCount());
|
||||
for (unsigned i = 0; i < names.size(); ++i)
|
||||
names[i] = _clone->name(name->nameAt(i), _subst);
|
||||
|
||||
1
src/libs/3rdparty/cplusplus/cplusplus.pri
vendored
1
src/libs/3rdparty/cplusplus/cplusplus.pri
vendored
@@ -3,6 +3,7 @@ DEPENDPATH += $$PWD
|
||||
INCLUDEPATH += $$PWD
|
||||
|
||||
HEADERS += \
|
||||
$$PWD/cppassert.h \
|
||||
$$PWD/CPlusPlus.h \
|
||||
$$PWD/AST.h \
|
||||
$$PWD/ASTVisitor.h \
|
||||
|
||||
46
src/libs/3rdparty/cplusplus/cppassert.h
vendored
Normal file
46
src/libs/3rdparty/cplusplus/cppassert.h
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
/****************************************************************************
|
||||
* **
|
||||
* ** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
|
||||
* ** Contact: http://www.qt-project.org/legal
|
||||
* **
|
||||
* ** This file is part of Qt Creator.
|
||||
* **
|
||||
* ** Commercial License Usage
|
||||
* ** Licensees holding valid commercial Qt licenses may use this file in
|
||||
* ** accordance with the commercial license agreement provided with the
|
||||
* ** Software or, alternatively, in accordance with the terms contained in
|
||||
* ** a written agreement between you and Digia. For licensing terms and
|
||||
* ** conditions see http://qt.digia.com/licensing. For further information
|
||||
* ** use the contact form at http://qt.digia.com/contact-us.
|
||||
* **
|
||||
* ** GNU Lesser General Public License Usage
|
||||
* ** Alternatively, this file may be used under the terms of the GNU Lesser
|
||||
* ** General Public License version 2.1 as published by the Free Software
|
||||
* ** Foundation and appearing in the file LICENSE.LGPL included in the
|
||||
* ** packaging of this file. Please review the following information to
|
||||
* ** ensure the GNU Lesser General Public License version 2.1 requirements
|
||||
* ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
|
||||
* **
|
||||
* ** In addition, as a special exception, Digia gives you certain additional
|
||||
* ** rights. These rights are described in the Digia Qt LGPL Exception
|
||||
* ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
|
||||
* **
|
||||
* ****************************************************************************/
|
||||
|
||||
#ifndef SOFT_ASSERT_H
|
||||
#define SOFT_ASSERT_H
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#define CPP_ASSERT_STRINGIFY_HELPER(x) #x
|
||||
#define CPP_ASSERT_STRINGIFY(x) CPP_ASSERT_STRINGIFY_HELPER(x)
|
||||
#define CPP_ASSERT_STRING(cond) std::cerr \
|
||||
<< "SOFT ASSERT: \"" cond"\" in file " __FILE__ ", line " CPP_ASSERT_STRINGIFY(__LINE__) \
|
||||
<< std::endl;
|
||||
|
||||
#define CPP_ASSERT(cond, action) if (cond) {} else { CPP_ASSERT_STRING(#cond); action; } do {} while (0)
|
||||
#define CPP_CHECK(cond) if (cond) {} else { CPP_ASSERT_STRING(#cond); } do {} while (0)
|
||||
|
||||
#endif // SOFT_ASSERT_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user