forked from qt-creator/qt-creator
C++: Replace non-absolute-critical asserts for soft ones
Change-Id: I021074a78d90929b4e83b8aff9db1ae7995e8c6a Reviewed-by: hjk <qthjk@ovi.com>
This commit is contained in:
@@ -43,6 +43,8 @@
|
||||
#include <AST.h>
|
||||
#include <SymbolVisitor.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QCoreApplication>
|
||||
#include <QtCore/QThreadPool>
|
||||
#include <QtCore/QDebug>
|
||||
@@ -284,7 +286,7 @@ protected:
|
||||
|
||||
CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &context)
|
||||
{
|
||||
Q_ASSERT(doc);
|
||||
QTC_ASSERT(doc, return Future());
|
||||
|
||||
return (new CheckSymbols(doc, context))->start();
|
||||
}
|
||||
|
||||
@@ -95,7 +95,7 @@ public:
|
||||
InsertionPointLocator locator(refactoring);
|
||||
const InsertionLocation loc = locator.methodDeclarationInClass(
|
||||
m_targetFileName, m_targetSymbol, m_xsSpec);
|
||||
Q_ASSERT(loc.isValid());
|
||||
QTC_ASSERT(loc.isValid(), return);
|
||||
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(m_targetFileName);
|
||||
int targetPosition1 = targetFile->position(loc.line(), loc.column());
|
||||
@@ -120,12 +120,12 @@ private:
|
||||
|
||||
Class *isMemberFunction(const LookupContext &context, Function *function)
|
||||
{
|
||||
Q_ASSERT(function);
|
||||
QTC_ASSERT(function, return 0);
|
||||
|
||||
Scope *enclosingScope = function->enclosingScope();
|
||||
while (! (enclosingScope->isNamespace() || enclosingScope->isClass()))
|
||||
enclosingScope = enclosingScope->enclosingScope();
|
||||
Q_ASSERT(enclosingScope != 0);
|
||||
QTC_ASSERT(enclosingScope != 0, return 0);
|
||||
|
||||
const Name *functionName = function->name();
|
||||
if (! functionName)
|
||||
@@ -245,7 +245,7 @@ public:
|
||||
void performChanges(const CppRefactoringFilePtr &,
|
||||
const CppRefactoringChanges &refactoring)
|
||||
{
|
||||
Q_ASSERT(m_loc.isValid());
|
||||
QTC_ASSERT(m_loc.isValid(), return);
|
||||
|
||||
CppRefactoringFilePtr targetFile = refactoring.file(m_loc.fileName());
|
||||
|
||||
|
||||
@@ -42,6 +42,8 @@
|
||||
#include <cppeditor/cppquickfix.h>
|
||||
#include <coreplugin/ifile.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QTextStream>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
@@ -159,7 +161,7 @@ void InsertQtPropertyMembers::Operation::performChanges(const CppRefactoringFile
|
||||
const QString getterDeclaration = typeName + QLatin1Char(' ') + m_getterName +
|
||||
QLatin1String("() const\n{\nreturn ") + m_storageName + QLatin1String(";\n}\n");
|
||||
InsertionLocation getterLoc = locator.methodDeclarationInClass(file->fileName(), m_class, InsertionPointLocator::Public);
|
||||
Q_ASSERT(getterLoc.isValid());
|
||||
QTC_ASSERT(getterLoc.isValid(), return);
|
||||
insertAndIndent(file, &declarations, getterLoc, getterDeclaration);
|
||||
}
|
||||
|
||||
@@ -176,7 +178,7 @@ void InsertQtPropertyMembers::Operation::performChanges(const CppRefactoringFile
|
||||
<< " = arg;\nemit " << m_signalName << "(arg);\n}\n}\n";
|
||||
}
|
||||
InsertionLocation setterLoc = locator.methodDeclarationInClass(file->fileName(), m_class, InsertionPointLocator::PublicSlot);
|
||||
Q_ASSERT(setterLoc.isValid());
|
||||
QTC_ASSERT(setterLoc.isValid(), return);
|
||||
insertAndIndent(file, &declarations, setterLoc, setterDeclaration);
|
||||
}
|
||||
|
||||
@@ -185,7 +187,7 @@ void InsertQtPropertyMembers::Operation::performChanges(const CppRefactoringFile
|
||||
const QString declaration = QLatin1String("void ") + m_signalName + QLatin1Char('(')
|
||||
+ typeName + QLatin1String(" arg);\n");
|
||||
InsertionLocation loc = locator.methodDeclarationInClass(file->fileName(), m_class, InsertionPointLocator::Signals);
|
||||
Q_ASSERT(loc.isValid());
|
||||
QTC_ASSERT(loc.isValid(), return);
|
||||
insertAndIndent(file, &declarations, loc, declaration);
|
||||
}
|
||||
|
||||
@@ -194,7 +196,7 @@ void InsertQtPropertyMembers::Operation::performChanges(const CppRefactoringFile
|
||||
const QString storageDeclaration = typeName + QLatin1String(" m_")
|
||||
+ propertyName + QLatin1String(";\n");
|
||||
InsertionLocation storageLoc = locator.methodDeclarationInClass(file->fileName(), m_class, InsertionPointLocator::Private);
|
||||
Q_ASSERT(storageLoc.isValid());
|
||||
QTC_ASSERT(storageLoc.isValid(), return);
|
||||
insertAndIndent(file, &declarations, storageLoc, storageDeclaration);
|
||||
}
|
||||
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include <coreplugin/ifile.h>
|
||||
#include <coreplugin/editormanager/editormanager.h>
|
||||
#include <cplusplus/OverviewModel.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QTimer>
|
||||
@@ -206,7 +207,7 @@ TextEditor::IOutlineWidget *CppOutlineWidgetFactory::createWidget(Core::IEditor
|
||||
{
|
||||
CPPEditor *cppEditor = qobject_cast<CPPEditor*>(editor);
|
||||
CPPEditorWidget *cppEditorWidget = qobject_cast<CPPEditorWidget*>(cppEditor->widget());
|
||||
Q_ASSERT(cppEditorWidget);
|
||||
QTC_ASSERT(cppEditorWidget, return 0);
|
||||
|
||||
CppOutlineWidget *widget = new CppOutlineWidget(cppEditorWidget);
|
||||
|
||||
|
||||
@@ -1551,7 +1551,7 @@ private:
|
||||
virtual void performChanges(const CppRefactoringFilePtr ¤tFile,
|
||||
const CppRefactoringChanges &)
|
||||
{
|
||||
Q_ASSERT(fwdClass != 0);
|
||||
QTC_ASSERT(fwdClass != 0, return);
|
||||
|
||||
CppTools::SymbolFinder symbolFinder;
|
||||
if (Class *k =
|
||||
|
||||
@@ -37,6 +37,7 @@
|
||||
|
||||
#include <texteditor/basetextdocumentlayout.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
#include <QtCore/QMetaEnum>
|
||||
@@ -319,14 +320,14 @@ void CodeFormatter::recalculateStateAfter(const QTextBlock &block)
|
||||
case else_clause:
|
||||
// ### shouldn't happen
|
||||
dump();
|
||||
Q_ASSERT(false);
|
||||
QTC_CHECK(false);
|
||||
leave(true);
|
||||
break;
|
||||
|
||||
case do_statement:
|
||||
// ### shouldn't happen
|
||||
dump();
|
||||
Q_ASSERT(false);
|
||||
QTC_CHECK(false);
|
||||
leave(true);
|
||||
break;
|
||||
|
||||
@@ -649,7 +650,7 @@ void CodeFormatter::enter(int newState)
|
||||
|
||||
void CodeFormatter::leave(bool statementDone)
|
||||
{
|
||||
Q_ASSERT(m_currentState.size() > 1);
|
||||
QTC_ASSERT(m_currentState.size() > 1, return);
|
||||
if (m_currentState.top().type == topmost_intro)
|
||||
return;
|
||||
|
||||
@@ -688,7 +689,7 @@ void CodeFormatter::leave(bool statementDone)
|
||||
void CodeFormatter::correctIndentation(const QTextBlock &block)
|
||||
{
|
||||
const int lexerState = tokenizeBlock(block);
|
||||
Q_ASSERT(m_currentState.size() >= 1);
|
||||
QTC_ASSERT(m_currentState.size() >= 1, return);
|
||||
|
||||
adjustIndent(m_tokens, lexerState, &m_indentDepth, &m_paddingDepth);
|
||||
}
|
||||
@@ -979,7 +980,7 @@ int CodeFormatter::tokenizeBlock(const QTextBlock &block, bool *endedJoined)
|
||||
int startState = loadLexerState(block.previous());
|
||||
if (block.blockNumber() == 0)
|
||||
startState = 0;
|
||||
Q_ASSERT(startState != -1);
|
||||
QTC_ASSERT(startState != -1, return 0);
|
||||
|
||||
SimpleLexer tokenize;
|
||||
tokenize.setQtMocRunEnabled(true);
|
||||
|
||||
@@ -69,6 +69,7 @@
|
||||
#include <texteditor/snippets/snippet.h>
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/completionsettings.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QLatin1String>
|
||||
#include <QtGui/QTextCursor>
|
||||
@@ -1250,7 +1251,7 @@ int CppCompletionAssistProcessor::startCompletionInternal(const QString fileName
|
||||
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
|
||||
|
||||
Scope *scope = thisDocument->scopeAt(line, column);
|
||||
Q_ASSERT(scope != 0);
|
||||
QTC_ASSERT(scope != 0, return -1);
|
||||
|
||||
if (expression.isEmpty()) {
|
||||
if (m_model->m_completionOperator == T_EOF_SYMBOL || m_model->m_completionOperator == T_COLON_COLON) {
|
||||
|
||||
@@ -196,7 +196,7 @@ static void find_helper(QFutureInterface<Usage> &future,
|
||||
Symbol *symbol)
|
||||
{
|
||||
const Identifier *symbolId = symbol->identifier();
|
||||
Q_ASSERT(symbolId != 0);
|
||||
QTC_ASSERT(symbolId != 0, return);
|
||||
|
||||
const Snapshot snapshot = context.snapshot();
|
||||
|
||||
|
||||
@@ -43,6 +43,7 @@
|
||||
#include <texteditor/texteditorsettings.h>
|
||||
#include <texteditor/tabsettings.h>
|
||||
#include <projectexplorer/editorconfiguration.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtGui/QTextBlock>
|
||||
|
||||
@@ -242,7 +243,7 @@ int CppRefactoringFile::endOf(unsigned index) const
|
||||
int CppRefactoringFile::endOf(const AST *ast) const
|
||||
{
|
||||
unsigned end = ast->lastToken();
|
||||
Q_ASSERT(end > 0);
|
||||
QTC_ASSERT(end > 0, return -1);
|
||||
return endOf(end - 1);
|
||||
}
|
||||
|
||||
|
||||
@@ -66,6 +66,7 @@
|
||||
#include <find/ifindfilter.h>
|
||||
#include <find/searchresultwindow.h>
|
||||
#include <utils/filesearch.h>
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QtPlugin>
|
||||
#include <QtCore/QFileInfo>
|
||||
@@ -325,7 +326,7 @@ QString CppToolsPlugin::correspondingHeaderOrSourceI(const QString &fileName) co
|
||||
}
|
||||
if (!bestFileName.isEmpty()) {
|
||||
const QFileInfo candidateFi(bestFileName);
|
||||
Q_ASSERT(candidateFi.isFile());
|
||||
QTC_ASSERT(candidateFi.isFile(), return QString());
|
||||
m_headerSourceMapping[fi.absoluteFilePath()] = candidateFi.absoluteFilePath();
|
||||
m_headerSourceMapping[candidateFi.absoluteFilePath()] = fi.absoluteFilePath();
|
||||
return candidateFi.absoluteFilePath();
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <cplusplus/Scope.h>
|
||||
#include <cplusplus/LookupContext.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <QtCore/QStringBuilder>
|
||||
#include <QtGui/QTextDocument>
|
||||
#include <QDebug>
|
||||
@@ -220,7 +222,7 @@ QString DoxygenGenerator::commandSpelling(Command command)
|
||||
if (command == ReturnCommand)
|
||||
return QLatin1String("return ");
|
||||
|
||||
Q_ASSERT(command == BriefCommand);
|
||||
QTC_ASSERT(command == BriefCommand, return QString());
|
||||
return QLatin1String("brief ");
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
#include <coreplugin/icore.h>
|
||||
#include <coreplugin/mimedatabase.h>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
using namespace CPlusPlus;
|
||||
using namespace CppTools;
|
||||
|
||||
@@ -173,7 +175,7 @@ protected:
|
||||
bool &needsPrefix,
|
||||
bool &needsSuffix)
|
||||
{
|
||||
Q_ASSERT(!ranges.isEmpty());
|
||||
QTC_ASSERT(!ranges.isEmpty(), return);
|
||||
const int lastIndex = ranges.size() - 1;
|
||||
|
||||
// try an exact match, and ignore the first (default) access spec:
|
||||
@@ -349,7 +351,7 @@ public:
|
||||
|
||||
const Value &get() const
|
||||
{
|
||||
Q_ASSERT(_set);
|
||||
QTC_ASSERT(_set, return Value());
|
||||
return _value;
|
||||
}
|
||||
};
|
||||
|
||||
@@ -13,6 +13,8 @@
|
||||
|
||||
#include <QtCore/QDebug>
|
||||
|
||||
#include <utils/qtcassert.h>
|
||||
|
||||
#include <algorithm>
|
||||
#include <utility>
|
||||
|
||||
@@ -218,7 +220,7 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
|
||||
Scope *enclosingScope = functionType->enclosingScope();
|
||||
while (! (enclosingScope->isNamespace() || enclosingScope->isClass()))
|
||||
enclosingScope = enclosingScope->enclosingScope();
|
||||
Q_ASSERT(enclosingScope != 0);
|
||||
QTC_ASSERT(enclosingScope != 0, return);
|
||||
|
||||
const Name *functionName = functionType->name();
|
||||
if (! functionName)
|
||||
|
||||
Reference in New Issue
Block a user