summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLeandro Melo <leandro.melo@nokia.com>2012-01-23 17:44:49 +0100
committerhjk <qthjk@ovi.com>2012-01-24 09:58:59 +0100
commitefe9bca20c2569f039f0193c6572d88dc024cd3d (patch)
tree3f5173f35c94a6f93f0df32c46478c861b3fcf33
parent918131b6e7d8f6db583a8c056749efa675761111 (diff)
downloadqt-creator-efe9bca20c2569f039f0193c6572d88dc024cd3d.tar.gz
C++: Replace non-absolute-critical asserts for soft ones
Change-Id: I021074a78d90929b4e83b8aff9db1ae7995e8c6a Reviewed-by: hjk <qthjk@ovi.com>
-rw-r--r--src/plugins/cppeditor/cppchecksymbols.cpp4
-rw-r--r--src/plugins/cppeditor/cppinsertdecldef.cpp8
-rw-r--r--src/plugins/cppeditor/cppinsertqtpropertymembers.cpp10
-rw-r--r--src/plugins/cppeditor/cppoutline.cpp3
-rw-r--r--src/plugins/cppeditor/cppquickfixes.cpp2
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp11
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp3
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp2
-rw-r--r--src/plugins/cpptools/cpprefactoringchanges.cpp3
-rw-r--r--src/plugins/cpptools/cpptoolsplugin.cpp3
-rw-r--r--src/plugins/cpptools/doxygengenerator.cpp4
-rw-r--r--src/plugins/cpptools/insertionpointlocator.cpp6
-rw-r--r--src/plugins/cpptools/symbolfinder.cpp4
13 files changed, 39 insertions, 24 deletions
diff --git a/src/plugins/cppeditor/cppchecksymbols.cpp b/src/plugins/cppeditor/cppchecksymbols.cpp
index 8b1deeac60..e3ac38221c 100644
--- a/src/plugins/cppeditor/cppchecksymbols.cpp
+++ b/src/plugins/cppeditor/cppchecksymbols.cpp
@@ -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();
}
diff --git a/src/plugins/cppeditor/cppinsertdecldef.cpp b/src/plugins/cppeditor/cppinsertdecldef.cpp
index 4a4f4ffa9e..62005a0d6b 100644
--- a/src/plugins/cppeditor/cppinsertdecldef.cpp
+++ b/src/plugins/cppeditor/cppinsertdecldef.cpp
@@ -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());
diff --git a/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp b/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp
index 2834ec3720..49653864fd 100644
--- a/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp
+++ b/src/plugins/cppeditor/cppinsertqtpropertymembers.cpp
@@ -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);
}
diff --git a/src/plugins/cppeditor/cppoutline.cpp b/src/plugins/cppeditor/cppoutline.cpp
index 0c2a592ab3..09435037da 100644
--- a/src/plugins/cppeditor/cppoutline.cpp
+++ b/src/plugins/cppeditor/cppoutline.cpp
@@ -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);
diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp
index a75ef11f16..17aa1f593c 100644
--- a/src/plugins/cppeditor/cppquickfixes.cpp
+++ b/src/plugins/cppeditor/cppquickfixes.cpp
@@ -1551,7 +1551,7 @@ private:
virtual void performChanges(const CppRefactoringFilePtr &currentFile,
const CppRefactoringChanges &)
{
- Q_ASSERT(fwdClass != 0);
+ QTC_ASSERT(fwdClass != 0, return);
CppTools::SymbolFinder symbolFinder;
if (Class *k =
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 74d63e6256..50df0e1be6 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -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);
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index cd6e14be59..57f2d3e2d6 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -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) {
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 3f79794360..d59191a5c1 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -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();
diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp
index b75fa51c0e..2823ede932 100644
--- a/src/plugins/cpptools/cpprefactoringchanges.cpp
+++ b/src/plugins/cpptools/cpprefactoringchanges.cpp
@@ -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);
}
diff --git a/src/plugins/cpptools/cpptoolsplugin.cpp b/src/plugins/cpptools/cpptoolsplugin.cpp
index c08b639e47..c21cb9b5ed 100644
--- a/src/plugins/cpptools/cpptoolsplugin.cpp
+++ b/src/plugins/cpptools/cpptoolsplugin.cpp
@@ -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();
diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp
index 9883ceb322..9b2e5aaee3 100644
--- a/src/plugins/cpptools/doxygengenerator.cpp
+++ b/src/plugins/cpptools/doxygengenerator.cpp
@@ -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 ");
}
diff --git a/src/plugins/cpptools/insertionpointlocator.cpp b/src/plugins/cpptools/insertionpointlocator.cpp
index 64ccb8ed4c..63b884d47f 100644
--- a/src/plugins/cpptools/insertionpointlocator.cpp
+++ b/src/plugins/cpptools/insertionpointlocator.cpp
@@ -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;
}
};
diff --git a/src/plugins/cpptools/symbolfinder.cpp b/src/plugins/cpptools/symbolfinder.cpp
index 9d84339de6..ffcbb27d9f 100644
--- a/src/plugins/cpptools/symbolfinder.cpp
+++ b/src/plugins/cpptools/symbolfinder.cpp
@@ -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)