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:
Nikolai Kosjar
2013-05-13 10:20:00 +02:00
parent 9fa9c227db
commit c426b71334
11 changed files with 113 additions and 53 deletions

View File

@@ -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();