diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -99,6 +99,7 @@ check_cxx_compiler_flag(-Wno-missing-field-initializers HAVE_MFI_FLAG) check_cxx_compiler_flag(-Werror=undefined-bool-conversion HAVE_UBC_FLAG) check_cxx_compiler_flag(-Werror=tautological-undefined-compare HAVE_TUC_FLAG) +check_cxx_compiler_flag(-Werror=zero-as-null-pointer-constant HAVE_NULLPTR_FLAG) if (HAVE_MFI_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-missing-field-initializers") endif() @@ -108,6 +109,9 @@ if (HAVE_TUC_FLAG) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=tautological-undefined-compare") endif() +if (HAVE_NULLPTR_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror=zero-as-null-pointer-constant") +endif() configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/config-kdevplatform.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config-kdevplatform.h ) diff --git a/debugger/breakpoint/breakpointwidget.cpp b/debugger/breakpoint/breakpointwidget.cpp --- a/debugger/breakpoint/breakpointwidget.cpp +++ b/debugger/breakpoint/breakpointwidget.cpp @@ -274,7 +274,7 @@ QPoint p = m_breakpointsView->visualRect(index).topLeft(); p = m_breakpointsView->mapToGlobal(p); - KPassivePopup *pop = new KPassivePopup(m_breakpointsView); + KPassivePopup *pop = new KPassivePopup(m_breakpointsView, nullptr); pop->setPopupStyle(KPassivePopup::Boxed); pop->setAutoDelete(true); // FIXME: the icon, too. diff --git a/debugger/tests/test_ivariablecontroller.cpp b/debugger/tests/test_ivariablecontroller.cpp --- a/debugger/tests/test_ivariablecontroller.cpp +++ b/debugger/tests/test_ivariablecontroller.cpp @@ -52,9 +52,9 @@ void KDevelop::TestIVariableController::updateRightAfterEnableAutoUpdate_data() { - QTest::addColumn("startAt"); - QTest::addColumn("switchTo"); - QTest::addColumn("jumpTo"); + QTest::addColumn("startAt", nullptr); + QTest::addColumn("switchTo", nullptr); + QTest::addColumn("jumpTo", nullptr); QTest::newRow("jump to somewhere else") << 1 << 0 << 2; QTest::newRow("jump back") << 1 << 0 << 1; diff --git a/documentation/documentationfindwidget.h b/documentation/documentationfindwidget.h --- a/documentation/documentationfindwidget.h +++ b/documentation/documentationfindwidget.h @@ -39,7 +39,7 @@ }; Q_DECLARE_FLAGS(FindOptions, FindOption); - explicit DocumentationFindWidget(QWidget* parent = 0); + explicit DocumentationFindWidget(QWidget* parent = nullptr); virtual ~DocumentationFindWidget(); virtual void showEvent ( QShowEvent* ) override; diff --git a/interfaces/idocumentation.h b/interfaces/idocumentation.h --- a/interfaces/idocumentation.h +++ b/interfaces/idocumentation.h @@ -57,7 +57,7 @@ inside the documentation widget. The implementation will have to enable the widget if it means to support the search feature. */ - virtual QWidget* documentationWidget(DocumentationFindWidget* findWidget, QWidget* parent=0) = 0; + virtual QWidget* documentationWidget(DocumentationFindWidget* findWidget, QWidget* parent = nullptr) = 0; virtual IDocumentationProvider* provider() const = 0; diff --git a/interfaces/iplugincontroller.h b/interfaces/iplugincontroller.h --- a/interfaces/iplugincontroller.h +++ b/interfaces/iplugincontroller.h @@ -161,7 +161,7 @@ if (plugin) { return plugin->extension(); } - return 0L; + return nullptr; } /** diff --git a/interfaces/iuicontroller.h b/interfaces/iuicontroller.h --- a/interfaces/iuicontroller.h +++ b/interfaces/iuicontroller.h @@ -51,7 +51,7 @@ * @param parent the parent to use as parent for the widget * @returns the new widget for the toolview */ - virtual QWidget* create(QWidget *parent = 0) = 0; + virtual QWidget* create(QWidget *parent = nullptr) = 0; /** * @returns the identifier of this toolview. The identifier * is used to remember which areas the tool view should appear diff --git a/language/codegen/applychangeswidget.cpp b/language/codegen/applychangeswidget.cpp --- a/language/codegen/applychangeswidget.cpp +++ b/language/codegen/applychangeswidget.cpp @@ -168,7 +168,7 @@ QMimeType mimetype = QMimeDatabase().mimeTypeForUrl(url); - KParts::ReadWritePart* part=KMimeTypeTrader::self()->createPartInstanceFromQuery(mimetype.name(), widget, widget); + KParts::ReadWritePart* part=KMimeTypeTrader::self()->createPartInstanceFromQuery(mimetype.name(), widget, widget, QString(), QVariantList(), nullptr); KTextEditor::Document* document=qobject_cast(part); Q_ASSERT(document); diff --git a/language/codegen/tests/test_templaterenderer.cpp b/language/codegen/tests/test_templaterenderer.cpp --- a/language/codegen/tests/test_templaterenderer.cpp +++ b/language/codegen/tests/test_templaterenderer.cpp @@ -48,9 +48,9 @@ void TestTemplateRenderer::simpleVariables_data() { - QTest::addColumn("name"); - QTest::addColumn("content"); - QTest::addColumn("result"); + QTest::addColumn("name", nullptr); + QTest::addColumn("content", nullptr); + QTest::addColumn("result", nullptr); QTest::newRow("string") << "string" << "Hello, {{ name }}!" << "Hello, Tester!"; QTest::newRow("int") << "int" << "I am {{ age }} years old" << "I am 23 years old"; diff --git a/language/duchain/appendedlist.h b/language/duchain/appendedlist.h --- a/language/duchain/appendedlist.h +++ b/language/duchain/appendedlist.h @@ -121,14 +121,14 @@ //The only function that does not lock the mutex is getItem(..), because that function must be very efficient. //Since it's only a few instructions from the moment m_items is read to the moment it's used, //deleting the old data after a few seconds should be safe. - m_deleteLater.append(qMakePair(time(0), oldItems)); + m_deleteLater.append(qMakePair(time(nullptr), oldItems)); //We do this in this place so it isn't called too often. The result is that we will always have some additional data around. //However the index itself should anyway not consume too much data. if(!m_deleteLater.isEmpty()) { while(!m_deleteLater.isEmpty()) { //We delete after 5 seconds - if(time(0) - m_deleteLater.first().first > 5) { + if(time(nullptr) - m_deleteLater.first().first > 5) { m_deleteLater.removeFirst(); }else{ break; @@ -296,7 +296,7 @@ #define APPENDED_LIST_FIRST(container, type, name) \ APPENDED_LIST_COMMON(container, type, name) \ const type* name() const { \ - if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return 0; \ + if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return nullptr; \ if(!appendedListsDynamic()) return reinterpret_cast(reinterpret_cast(this) + classSize() + offsetBehindBase()); \ else return temporaryHash ## container ## name().getItem(name ## Data).data(); \ } \ @@ -309,7 +309,7 @@ #define APPENDED_LIST(container, type, name, predecessor) \ APPENDED_LIST_COMMON(container, type, name) \ const type* name() const {\ - if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return 0; \ + if((name ## Data & KDevelop::DynamicAppendedListRevertMask) == 0) return nullptr; \ if(!appendedListsDynamic()) return reinterpret_cast(reinterpret_cast(this) + classSize() + predecessor ## OffsetBehind()); \ else return temporaryHash ## container ## name().getItem(name ## Data).data(); \ } \ diff --git a/language/duchain/classdeclaration.h b/language/duchain/classdeclaration.h --- a/language/duchain/classdeclaration.h +++ b/language/duchain/classdeclaration.h @@ -112,7 +112,7 @@ /**Returns whether base is a public base-class of this class * @param baseConversionLevels If nonzero, this will count the distance of the classes. * */ - bool isPublicBaseClass( ClassDeclaration* base, const KDevelop::TopDUContext* topContext, int* baseConversionLevels = 0 ) const; + bool isPublicBaseClass( ClassDeclaration* base, const KDevelop::TopDUContext* topContext, int* baseConversionLevels = nullptr ) const; QString toString() const override; diff --git a/language/duchain/duchainlock.h b/language/duchain/duchainlock.h --- a/language/duchain/duchainlock.h +++ b/language/duchain/duchainlock.h @@ -115,7 +115,7 @@ * \param duChainLock lock to read-acquire. If this is left zero, DUChain::lock() is used. * \param timeout Timeout in milliseconds. If this is not zero, you've got to check locked() to see whether the lock succeeded. */ - explicit DUChainReadLocker(DUChainLock* duChainLock = 0, unsigned int timeout = 0); + explicit DUChainReadLocker(DUChainLock* duChainLock = nullptr, unsigned int timeout = 0); /// Destructor. ~DUChainReadLocker(); @@ -147,7 +147,7 @@ * \param duChainLock lock to write-acquire. If this is left zero, DUChain::lock() is used. * \param timeout Timeout in milliseconds. If this is not zero, you've got to check locked() to see whether the lock succeeded. */ - explicit DUChainWriteLocker(DUChainLock* duChainLock = 0, unsigned int timeout = 0); + explicit DUChainWriteLocker(DUChainLock* duChainLock = nullptr, unsigned int timeout = 0); /// Destructor. ~DUChainWriteLocker(); diff --git a/language/duchain/duchainpointer.h b/language/duchain/duchainpointer.h --- a/language/duchain/duchainpointer.h +++ b/language/duchain/duchainpointer.h @@ -159,7 +159,7 @@ Type* data() const { if( !d ) - return 0; + return nullptr; return static_cast(d->base()); } @@ -167,7 +167,7 @@ if( rhs ) d = rhs->weakPointer(); else - d = 0; + d = nullptr; return *this; } diff --git a/language/duchain/duchainregister.h b/language/duchain/duchainregister.h --- a/language/duchain/duchainregister.h +++ b/language/duchain/duchainregister.h @@ -117,7 +117,7 @@ Q_ASSERT(m_factories.size() > T::Identity); Q_ASSERT(m_factories[T::Identity]); delete m_factories[T::Identity]; - m_factories[T::Identity] = 0; + m_factories[T::Identity] = nullptr; m_dataClassSizes[T::Identity] = 0; } diff --git a/language/duchain/duchainutils.h b/language/duchain/duchainutils.h --- a/language/duchain/duchainutils.h +++ b/language/duchain/duchainutils.h @@ -79,7 +79,7 @@ KDEVPLATFORMLANGUAGE_EXPORT ItemUnderCursor itemUnderCursor(const QUrl& url, const KTextEditor::Cursor& cursor); /**If the given declaration is a definition, and has a real declaration *attached, returns that declarations. Else returns the given argument. */ - KDEVPLATFORMLANGUAGE_EXPORT Declaration* declarationForDefinition(Declaration* definition, TopDUContext* topContext = 0); + KDEVPLATFORMLANGUAGE_EXPORT Declaration* declarationForDefinition(Declaration* definition, TopDUContext* topContext = nullptr); ///Returns the first declaration in the given line. Searches the given context and all sub-contexts. ///Must only be called from the foreground or with the foreground lock held. KDEVPLATFORMLANGUAGE_EXPORT Declaration* declarationInLine(const KTextEditor::Cursor& cursor, KDevelop::DUContext* ctx); diff --git a/language/duchain/functiondefinition.h b/language/duchain/functiondefinition.h --- a/language/duchain/functiondefinition.h +++ b/language/duchain/functiondefinition.h @@ -44,7 +44,7 @@ * @param topContext the top-context from which to search * \returns the declaration matching this definition, otherwise null if no matching declaration has been found. * */ - Declaration* declaration(const TopDUContext* topContext = 0) const; + Declaration* declaration(const TopDUContext* topContext = nullptr) const; ///Returns true if a Declaration has been assigned to this Definition bool hasDeclaration() const; diff --git a/language/duchain/indexeddeclaration.h b/language/duchain/indexeddeclaration.h --- a/language/duchain/indexeddeclaration.h +++ b/language/duchain/indexeddeclaration.h @@ -33,7 +33,7 @@ */ class KDEVPLATFORMLANGUAGE_EXPORT IndexedDeclaration { public: - IndexedDeclaration(const Declaration* decl = 0); + IndexedDeclaration(const Declaration* decl = nullptr); IndexedDeclaration(uint topContext, uint declarationIndex); /** @@ -60,7 +60,7 @@ ///@warning The duchain needs to be locked when this is called inline bool isValid() const { - return !isDummy() && declaration() != 0; + return !isDummy() && declaration() != nullptr; } inline bool operator<(const IndexedDeclaration& rhs) const { diff --git a/language/duchain/indexedducontext.h b/language/duchain/indexedducontext.h --- a/language/duchain/indexedducontext.h +++ b/language/duchain/indexedducontext.h @@ -55,7 +55,7 @@ } bool isValid() const { - return !isDummy() && context() != 0; + return !isDummy() && context() != nullptr; } bool operator<(const IndexedDUContext& rhs) const { diff --git a/language/duchain/indexedtopducontext.h b/language/duchain/indexedtopducontext.h --- a/language/duchain/indexedtopducontext.h +++ b/language/duchain/indexedtopducontext.h @@ -40,7 +40,7 @@ if(!index) setIsDummy(true); } - IndexedTopDUContext(TopDUContext* context = 0); + IndexedTopDUContext(TopDUContext* context = nullptr); enum { DummyMask = 1u<<31u diff --git a/language/duchain/localindexeddeclaration.h b/language/duchain/localindexeddeclaration.h --- a/language/duchain/localindexeddeclaration.h +++ b/language/duchain/localindexeddeclaration.h @@ -33,7 +33,7 @@ class KDEVPLATFORMLANGUAGE_EXPORT LocalIndexedDeclaration { public: - LocalIndexedDeclaration(Declaration* decl = 0); + LocalIndexedDeclaration(Declaration* decl = nullptr); LocalIndexedDeclaration(uint declarationIndex); /** diff --git a/language/duchain/navigation/navigationaction.h b/language/duchain/navigation/navigationaction.h --- a/language/duchain/navigation/navigationaction.h +++ b/language/duchain/navigation/navigationaction.h @@ -42,16 +42,16 @@ }; ///When executed, this navigation-action calls the "executeKeyAction(QString) function in its navigation-context - NavigationAction(QString _key) : targetContext(0), type(ExecuteKey), key(_key) { + NavigationAction(QString _key) : targetContext(nullptr), type(ExecuteKey), key(_key) { } - NavigationAction() : targetContext(0), type(None) { + NavigationAction() : targetContext(nullptr), type(None) { } - NavigationAction( DeclarationPointer decl_, Type type_ ) : targetContext(0), decl(decl_), type(type_) { + NavigationAction( DeclarationPointer decl_, Type type_ ) : targetContext(nullptr), decl(decl_), type(type_) { } - NavigationAction( const QUrl& _document, const KTextEditor::Cursor& _cursor) : targetContext(0), document(_document), cursor(_cursor) { + NavigationAction( const QUrl& _document, const KTextEditor::Cursor& _cursor) : targetContext(nullptr), document(_document), cursor(_cursor) { type = JumpToSource; } diff --git a/language/duchain/parsingenvironment.h b/language/duchain/parsingenvironment.h --- a/language/duchain/parsingenvironment.h +++ b/language/duchain/parsingenvironment.h @@ -142,7 +142,7 @@ ///Can additionally use language-specific information to decide whether the top-context that has this data attached needs to be reparsed. ///The standard-implementation checks the modification-time of this file stored using setModificationRevision, and all other modification-times ///stored with addModificationRevision(..). - virtual bool needsUpdate(const ParsingEnvironment* environment = 0) const; + virtual bool needsUpdate(const ParsingEnvironment* environment = nullptr) const; /** * A language-specific flag used by C++ to mark one context as a proxy of another. diff --git a/language/duchain/tests/bench_hashes.cpp b/language/duchain/tests/bench_hashes.cpp --- a/language/duchain/tests/bench_hashes.cpp +++ b/language/duchain/tests/bench_hashes.cpp @@ -87,8 +87,8 @@ void BenchHashes::feedData() { - QTest::addColumn("useStl"); - QTest::addColumn("data"); + QTest::addColumn("useStl", nullptr); + QTest::addColumn("data", nullptr); InputData data; QVector sizes = QVector() << 100 << 1000 << 10000 << 100000; @@ -304,7 +304,7 @@ void BenchHashes::typeRepo_data() { - QTest::addColumn("type"); + QTest::addColumn("type", nullptr); QTest::newRow("noop") << 0; QTest::newRow("vector") << 1; diff --git a/language/duchain/tests/test_duchain.cpp b/language/duchain/tests/test_duchain.cpp --- a/language/duchain/tests/test_duchain.cpp +++ b/language/duchain/tests/test_duchain.cpp @@ -959,7 +959,7 @@ void TestDUChain::benchTypeRegistry_data() { - QTest::addColumn("func"); + QTest::addColumn("func", nullptr); QTest::newRow("dataClassSize") << 0; QTest::newRow("dynamicSize") << 1; QTest::newRow("create") << 2; @@ -1003,7 +1003,7 @@ void TestDUChain::benchDUChainItemFactory_copy_data() { - QTest::addColumn("constant"); + QTest::addColumn("constant", nullptr); QTest::newRow("non-const") << 0; QTest::newRow("const") << 1; QTest::newRow("flip") << 2; diff --git a/language/duchain/tests/test_identifier.cpp b/language/duchain/tests/test_identifier.cpp --- a/language/duchain/tests/test_identifier.cpp +++ b/language/duchain/tests/test_identifier.cpp @@ -101,7 +101,7 @@ void TestIdentifier::testIdentifier_data() { - QTest::addColumn("stringId"); + QTest::addColumn("stringId", nullptr); QTest::newRow("empty") << QString(); QTest::newRow("foo") << QStringLiteral("foo"); @@ -179,7 +179,7 @@ void TestIdentifier::testQualifiedIdentifier_data() { - QTest::addColumn("stringId"); + QTest::addColumn("stringId", nullptr); QTest::newRow("empty") << QString(); QTest::newRow("foo") << "foo"; diff --git a/language/duchain/tests/test_stringhelpers.cpp b/language/duchain/tests/test_stringhelpers.cpp --- a/language/duchain/tests/test_stringhelpers.cpp +++ b/language/duchain/tests/test_stringhelpers.cpp @@ -31,8 +31,8 @@ void TestDUChain::testFormatComment_data() { - QTest::addColumn("input"); - QTest::addColumn("output"); + QTest::addColumn("input", nullptr); + QTest::addColumn("output", nullptr); QTest::newRow("c-style") << QByteArrayLiteral("// foo\n// bar") << QByteArrayLiteral("foo\n bar"); QTest::newRow("doxy-c-style") << QByteArrayLiteral("/// foo\n/// bar") << QByteArrayLiteral("foo\n bar"); diff --git a/language/duchain/topducontext.h b/language/duchain/topducontext.h --- a/language/duchain/topducontext.h +++ b/language/duchain/topducontext.h @@ -58,7 +58,7 @@ ///keep a ReferencedTopDUContext. class KDEVPLATFORMLANGUAGE_EXPORT ReferencedTopDUContext { public: - ReferencedTopDUContext(TopDUContext* context = 0); + ReferencedTopDUContext(TopDUContext* context = nullptr); ReferencedTopDUContext(const ReferencedTopDUContext& rhs); ~ReferencedTopDUContext(); @@ -107,7 +107,7 @@ class KDEVPLATFORMLANGUAGE_EXPORT TopDUContext : public DUContext { public: - explicit TopDUContext(const IndexedString& url, const RangeInRevision& range, ParsingEnvironmentFile* file = 0); + explicit TopDUContext(const IndexedString& url, const RangeInRevision& range, ParsingEnvironmentFile* file = nullptr); explicit TopDUContext(TopDUContextData& data); TopDUContext* topContext() const override; diff --git a/language/duchain/topducontextutils.h b/language/duchain/topducontextutils.h --- a/language/duchain/topducontextutils.h +++ b/language/duchain/topducontextutils.h @@ -27,7 +27,7 @@ /// \todo move data to private d pointer classes struct KDEVPLATFORMLANGUAGE_EXPORT TopDUContext::DeclarationChecker { - DeclarationChecker(const TopDUContext* _top, const CursorInRevision& _position, const AbstractType::Ptr& _dataType, DUContext::SearchFlags _flags, KDevVarLengthArray* _createVisibleCache = 0); + DeclarationChecker(const TopDUContext* _top, const CursorInRevision& _position, const AbstractType::Ptr& _dataType, DUContext::SearchFlags _flags, KDevVarLengthArray* _createVisibleCache = nullptr); bool operator()(const Declaration* dec) const; mutable KDevVarLengthArray* createVisibleCache; diff --git a/language/duchain/types/arraytype.h b/language/duchain/types/arraytype.h --- a/language/duchain/types/arraytype.h +++ b/language/duchain/types/arraytype.h @@ -98,7 +98,7 @@ template<> inline ArrayType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeArray) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/constantintegraltype.h b/language/duchain/types/constantintegraltype.h --- a/language/duchain/types/constantintegraltype.h +++ b/language/duchain/types/constantintegraltype.h @@ -110,7 +110,7 @@ template<> inline ConstantIntegralType* fastCast(AbstractType* from) { if(!from || from->whichType() != KDevelop::AbstractType::TypeIntegral) - return 0; + return nullptr; else return dynamic_cast(from); } diff --git a/language/duchain/types/delayedtype.h b/language/duchain/types/delayedtype.h --- a/language/duchain/types/delayedtype.h +++ b/language/duchain/types/delayedtype.h @@ -97,7 +97,7 @@ template<> inline DelayedType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeDelayed) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/enumerationtype.h b/language/duchain/types/enumerationtype.h --- a/language/duchain/types/enumerationtype.h +++ b/language/duchain/types/enumerationtype.h @@ -65,7 +65,7 @@ template<> inline EnumerationType* fastCast(AbstractType* from) { if(!from || from->whichType() != KDevelop::AbstractType::TypeEnumeration) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/enumeratortype.h b/language/duchain/types/enumeratortype.h --- a/language/duchain/types/enumeratortype.h +++ b/language/duchain/types/enumeratortype.h @@ -67,7 +67,7 @@ template<> inline EnumeratorType* fastCast(AbstractType* from) { if(!from || from->whichType() != KDevelop::AbstractType::TypeEnumerator) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/functiontype.h b/language/duchain/types/functiontype.h --- a/language/duchain/types/functiontype.h +++ b/language/duchain/types/functiontype.h @@ -139,7 +139,7 @@ template<> inline FunctionType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeFunction) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/integraltype.h b/language/duchain/types/integraltype.h --- a/language/duchain/types/integraltype.h +++ b/language/duchain/types/integraltype.h @@ -118,7 +118,7 @@ template<> inline IntegralType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeIntegral) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/pointertype.h b/language/duchain/types/pointertype.h --- a/language/duchain/types/pointertype.h +++ b/language/duchain/types/pointertype.h @@ -88,7 +88,7 @@ template<> inline PointerType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypePointer) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/referencetype.h b/language/duchain/types/referencetype.h --- a/language/duchain/types/referencetype.h +++ b/language/duchain/types/referencetype.h @@ -102,7 +102,7 @@ template<> inline ReferenceType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeReference) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/structuretype.h b/language/duchain/types/structuretype.h --- a/language/duchain/types/structuretype.h +++ b/language/duchain/types/structuretype.h @@ -77,7 +77,7 @@ template<> inline StructureType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeStructure) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/typealiastype.h b/language/duchain/types/typealiastype.h --- a/language/duchain/types/typealiastype.h +++ b/language/duchain/types/typealiastype.h @@ -76,7 +76,7 @@ template<> inline TypeAliasType* fastCast(AbstractType* from) { if(!from || from->whichType() != AbstractType::TypeIntegral) - return 0; + return nullptr; else return static_cast(from); } diff --git a/language/duchain/types/typepointer.h b/language/duchain/types/typepointer.h --- a/language/duchain/types/typepointer.h +++ b/language/duchain/types/typepointer.h @@ -48,7 +48,7 @@ ///Uses dynamic_cast to cast this pointer to the given type template - TypePtr cast(U * /*dummy*/ = 0) const { + TypePtr cast(U * /*dummy*/ = nullptr) const { return TypePtr(dynamic_cast(Base::data())); } diff --git a/language/duchain/types/typeutils.h b/language/duchain/types/typeutils.h --- a/language/duchain/types/typeutils.h +++ b/language/duchain/types/typeutils.h @@ -41,12 +41,12 @@ * Modifiers of aliases ore references are pushed into the targets. * @return return-value will only be zero if type is zero */ - KDEVPLATFORMLANGUAGE_EXPORT KDevelop::AbstractType::Ptr targetType(const KDevelop::AbstractType::Ptr& type, const KDevelop::TopDUContext* topContext, bool* constant = 0); + KDEVPLATFORMLANGUAGE_EXPORT KDevelop::AbstractType::Ptr targetType(const KDevelop::AbstractType::Ptr& type, const KDevelop::TopDUContext* topContext, bool* constant = nullptr); /** * Same as targetType(..), ecept that it does not un-aliases TypeAliasTypes * Modifiers of aliases ore references are pushed into the targets. */ - KDEVPLATFORMLANGUAGE_EXPORT KDevelop::AbstractType::Ptr targetTypeKeepAliases(const KDevelop::AbstractType::Ptr& type, const KDevelop::TopDUContext* topContext, bool* constant = 0); + KDEVPLATFORMLANGUAGE_EXPORT KDevelop::AbstractType::Ptr targetTypeKeepAliases(const KDevelop::AbstractType::Ptr& type, const KDevelop::TopDUContext* topContext, bool* constant = nullptr); /** * Resolves all type-aliases, returning the effective aliased type * All modifiers are pushed from the aliases into the targets. diff --git a/language/util/basicsetrepository.h b/language/util/basicsetrepository.h --- a/language/util/basicsetrepository.h +++ b/language/util/basicsetrepository.h @@ -291,7 +291,7 @@ if(index) return dataRepository.itemFromIndex(index); else - return 0; + return nullptr; } inline QMutex* mutex() const { diff --git a/language/util/setrepository.h b/language/util/setrepository.h --- a/language/util/setrepository.h +++ b/language/util/setrepository.h @@ -108,14 +108,14 @@ if(m_data->leftNode()) return StaticRepository::repository()->nodeFromIndex(m_data->leftNode()); else - return 0; + return nullptr; } inline VirtualSetNode rightChild() const { if(m_data->rightNode()) return StaticRepository::repository()->nodeFromIndex(m_data->rightNode()); else - return 0; + return nullptr; } ///Returns the start of this node's range. If this is a final node, the length of the range is 1. diff --git a/outputview/tests/test_filteringstrategy.cpp b/outputview/tests/test_filteringstrategy.cpp --- a/outputview/tests/test_filteringstrategy.cpp +++ b/outputview/tests/test_filteringstrategy.cpp @@ -55,8 +55,8 @@ void TestFilteringStrategy::testNoFilterStrategy_data() { - QTest::addColumn("line"); - QTest::addColumn("expected"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expected", nullptr); QTest::newRow("cppcheck-info-line") << buildCppCheckInformationLine() << FilteredItem::InvalidItem; @@ -87,9 +87,9 @@ void TestFilteringStrategy::testCompilerFilterStrategy_data() { - QTest::addColumn("line"); - QTest::addColumn("expectedError"); - QTest::addColumn("expectedAction"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expectedError", nullptr); + QTest::addColumn("expectedAction", nullptr); QTest::newRow("cppcheck-info-line") << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; @@ -142,9 +142,9 @@ void TestFilteringStrategy::testCompilerFilterstrategyMultipleKeywords_data() { - QTest::addColumn("line"); - QTest::addColumn("expectedError"); - QTest::addColumn("expectedAction"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expectedError", nullptr); + QTest::addColumn("expectedAction", nullptr); QTest::newRow("warning-containing-error-word") << "RingBuffer.cpp:64:6: warning: unused parameter ‘errorItem’ [-Wunused-parameter]" @@ -175,9 +175,9 @@ void TestFilteringStrategy::testScriptErrorFilterStrategy_data() { - QTest::addColumn("line"); - QTest::addColumn("expectedError"); - QTest::addColumn("expectedAction"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expectedError", nullptr); + QTest::addColumn("expectedAction", nullptr); QTest::newRow("cppcheck-info-line") << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; @@ -207,11 +207,11 @@ void TestFilteringStrategy::testNativeAppErrorFilterStrategy_data() { - QTest::addColumn("line"); - QTest::addColumn("file"); - QTest::addColumn("lineNo"); - QTest::addColumn("column"); - QTest::addColumn("itemtype"); + QTest::addColumn("line", nullptr); + QTest::addColumn("file", nullptr); + QTest::addColumn("lineNo", nullptr); + QTest::addColumn("column", nullptr); + QTest::addColumn("itemtype", nullptr); // BEGIN: C++ QTest::newRow("cassert") @@ -299,9 +299,9 @@ void TestFilteringStrategy::testStaticAnalysisFilterStrategy_data() { - QTest::addColumn("line"); - QTest::addColumn("expectedError"); - QTest::addColumn("expectedAction"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expectedError", nullptr); + QTest::addColumn("expectedAction", nullptr); QTest::newRow("cppcheck-info-line") << buildCppCheckInformationLine() << FilteredItem::InvalidItem << FilteredItem::InvalidItem; @@ -344,8 +344,8 @@ void TestFilteringStrategy::testCompilerFilterstrategyUrlFromAction_data() { - QTest::addColumn("line"); - QTest::addColumn("expectedLastDir"); + QTest::addColumn("line", nullptr); + QTest::addColumn("expectedLastDir", nullptr); QString basepath = projectPath(); QTest::newRow("cmake-line1") @@ -427,11 +427,11 @@ void TestFilteringStrategy::testExtractionOfLineAndColumn_data() { - QTest::addColumn("line"); - QTest::addColumn("file"); - QTest::addColumn("lineNr"); - QTest::addColumn("column"); - QTest::addColumn("itemtype"); + QTest::addColumn("line", nullptr); + QTest::addColumn("file", nullptr); + QTest::addColumn("lineNr", nullptr); + QTest::addColumn("column", nullptr); + QTest::addColumn("itemtype", nullptr); #ifdef Q_OS_WIN QTest::newRow("msvc-compiler-error-line") diff --git a/outputview/tests/test_outputmodel.cpp b/outputview/tests/test_outputmodel.cpp --- a/outputview/tests/test_outputmodel.cpp +++ b/outputview/tests/test_outputmodel.cpp @@ -95,8 +95,8 @@ void TestOutputModel::bench_data() { - QTest::addColumn("strategy"); - QTest::addColumn("lines"); + QTest::addColumn("strategy", nullptr); + QTest::addColumn("lines", nullptr); const QStringList lines = generateLines(); const QStringList longLine = generateLongLine(); diff --git a/plugins/appwizard/appwizarddialog.h b/plugins/appwizard/appwizarddialog.h --- a/plugins/appwizard/appwizarddialog.h +++ b/plugins/appwizard/appwizarddialog.h @@ -44,7 +44,7 @@ Q_OBJECT public: AppWizardDialog( KDevelop::IPluginController*, ProjectTemplatesModel*, - QWidget *parent = 0, Qt::WindowFlags flags = 0); + QWidget *parent = nullptr, Qt::WindowFlags flags = nullptr); ApplicationInfo appInfo() const; diff --git a/plugins/appwizard/appwizardpagewidget.h b/plugins/appwizard/appwizardpagewidget.h --- a/plugins/appwizard/appwizardpagewidget.h +++ b/plugins/appwizard/appwizardpagewidget.h @@ -26,7 +26,7 @@ { Q_OBJECT public: - explicit AppWizardPageWidget(QWidget* parent = 0); + explicit AppWizardPageWidget(QWidget* parent = nullptr); virtual ~AppWizardPageWidget(); virtual bool shouldContinue(); diff --git a/plugins/filetemplates/templateclassassistant.cpp b/plugins/filetemplates/templateclassassistant.cpp --- a/plugins/filetemplates/templateclassassistant.cpp +++ b/plugins/filetemplates/templateclassassistant.cpp @@ -58,17 +58,17 @@ #include #include -#define REMOVE_PAGE(name) \ -if (d->name##Page) \ -{ \ - removePage(d->name##Page); \ - d->name##Page = 0; \ - d->name##PageWidget = 0; \ +#define REMOVE_PAGE(name) \ +if (d->name##Page) \ +{ \ + removePage(d->name##Page); \ + d->name##Page = nullptr; \ + d->name##PageWidget = nullptr; \ } -#define ZERO_PAGE(name) \ -d->name##Page = 0; \ -d->name##PageWidget = 0; +#define ZERO_PAGE(name) \ +d->name##Page = nullptr; \ +d->name##PageWidget = nullptr; using namespace KDevelop; diff --git a/plugins/grepview/tests/test_findreplace.cpp b/plugins/grepview/tests/test_findreplace.cpp --- a/plugins/grepview/tests/test_findreplace.cpp +++ b/plugins/grepview/tests/test_findreplace.cpp @@ -37,9 +37,9 @@ void FindReplaceTest::testFind_data() { - QTest::addColumn("subject"); - QTest::addColumn("search"); - QTest::addColumn("matches"); + QTest::addColumn("subject", nullptr); + QTest::addColumn("search", nullptr); + QTest::addColumn("matches", nullptr); QTest::newRow("Basic") << "foobar" << QRegExp("foo") << (MatchList() << Match(0, 0, 3)); @@ -96,12 +96,12 @@ void FindReplaceTest::testReplace_data() { - QTest::addColumn("subject"); - QTest::addColumn("searchPattern"); - QTest::addColumn("searchTemplate"); - QTest::addColumn("replace"); - QTest::addColumn("replaceTemplate"); - QTest::addColumn("result"); + QTest::addColumn("subject", nullptr); + QTest::addColumn("searchPattern", nullptr); + QTest::addColumn("searchTemplate", nullptr); + QTest::addColumn("replace", nullptr); + QTest::addColumn("replaceTemplate", nullptr); + QTest::addColumn("result", nullptr); QTest::newRow("Raw replace") << (FileList() << File(QStringLiteral("myfile.txt"), QStringLiteral("some text\nreplacement\nsome other test\n")) diff --git a/plugins/projectfilter/tests/test_projectfilter.cpp b/plugins/projectfilter/tests/test_projectfilter.cpp --- a/plugins/projectfilter/tests/test_projectfilter.cpp +++ b/plugins/projectfilter/tests/test_projectfilter.cpp @@ -117,10 +117,10 @@ void TestProjectFilter::match_data() { - QTest::addColumn("filter"); - QTest::addColumn("path"); - QTest::addColumn("isFolder"); - QTest::addColumn("expectedIsValid"); + QTest::addColumn("filter", nullptr); + QTest::addColumn("path", nullptr); + QTest::addColumn("isFolder", nullptr); + QTest::addColumn("expectedIsValid", nullptr); { // test default filters @@ -370,8 +370,8 @@ void TestProjectFilter::bench_data() { - QTest::addColumn("filter"); - QTest::addColumn >("data"); + QTest::addColumn("filter", nullptr); + QTest::addColumn >("data", nullptr); const TestProject project; diff --git a/plugins/quickopen/tests/bench_quickopen.cpp b/plugins/quickopen/tests/bench_quickopen.cpp --- a/plugins/quickopen/tests/bench_quickopen.cpp +++ b/plugins/quickopen/tests/bench_quickopen.cpp @@ -37,8 +37,8 @@ void BenchQuickOpen::getData() { - QTest::addColumn("files"); - QTest::addColumn("filter"); + QTest::addColumn("files", nullptr); + QTest::addColumn("filter", nullptr); QTest::newRow("0100-___") << 100 << ""; QTest::newRow("0500-___") << 500 << ""; diff --git a/plugins/quickopen/tests/test_quickopen.cpp b/plugins/quickopen/tests/test_quickopen.cpp --- a/plugins/quickopen/tests/test_quickopen.cpp +++ b/plugins/quickopen/tests/test_quickopen.cpp @@ -61,9 +61,9 @@ { using ItemList = QList; - QTest::addColumn("items"); - QTest::addColumn("filter"); - QTest::addColumn("filtered"); + QTest::addColumn("items", nullptr); + QTest::addColumn("filter", nullptr); + QTest::addColumn("filtered", nullptr); auto i = [](const QString& text) { auto item = DUChainItem(); @@ -104,9 +104,9 @@ void TestQuickOpen::testAbbreviations_data() { - QTest::addColumn("items"); - QTest::addColumn("filter"); - QTest::addColumn("filtered"); + QTest::addColumn("items", nullptr); + QTest::addColumn("filter", nullptr); + QTest::addColumn("filtered", nullptr); const QStringList items = QStringList() << QStringLiteral("/foo/bar/caz/a.h") @@ -134,9 +134,9 @@ void TestQuickOpen::testSorting_data() { - QTest::addColumn("items"); - QTest::addColumn("filter"); - QTest::addColumn("filtered"); + QTest::addColumn("items", nullptr); + QTest::addColumn("filter", nullptr); + QTest::addColumn("filtered", nullptr); const QStringList items = QStringList() << QStringLiteral("/foo/a.h") diff --git a/plugins/standardoutputview/tests/test_standardoutputview.cpp b/plugins/standardoutputview/tests/test_standardoutputview.cpp --- a/plugins/standardoutputview/tests/test_standardoutputview.cpp +++ b/plugins/standardoutputview/tests/test_standardoutputview.cpp @@ -224,7 +224,7 @@ void StandardOutputViewTest::testStandardToolViews_data() { - QTest::addColumn("view"); + QTest::addColumn("view", nullptr); QTest::newRow("build") << KDevelop::IOutputView::BuildView; QTest::newRow("run") << KDevelop::IOutputView::RunView; diff --git a/plugins/subversion/CMakeLists.txt b/plugins/subversion/CMakeLists.txt --- a/plugins/subversion/CMakeLists.txt +++ b/plugins/subversion/CMakeLists.txt @@ -5,6 +5,10 @@ # but for now, we won't spend time on it... add_definitions(-DSVN_DEPRECATED=) +if (HAVE_NULLPTR_FLAG) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error=zero-as-null-pointer-constant") +endif() + project(KDevSubversionPlugin) add_subdirectory(tests) diff --git a/plugins/subversion/kdevsvncpp/client.hpp b/plugins/subversion/kdevsvncpp/client.hpp --- a/plugins/subversion/kdevsvncpp/client.hpp +++ b/plugins/subversion/kdevsvncpp/client.hpp @@ -112,7 +112,7 @@ /** * Initializes the primary memory pool. */ - Client(Context * context = 0); + Client(Context * context = nullptr); virtual ~Client(); diff --git a/plugins/subversion/kdevsvncpp/entry.hpp b/plugins/subversion/kdevsvncpp/entry.hpp --- a/plugins/subversion/kdevsvncpp/entry.hpp +++ b/plugins/subversion/kdevsvncpp/entry.hpp @@ -50,7 +50,7 @@ * * @param src another entry to copy from */ - Entry(const svn_wc_entry_t * src = 0); + Entry(const svn_wc_entry_t * src = nullptr); /** * copy constructor diff --git a/plugins/subversion/kdevsvncpp/info.hpp b/plugins/subversion/kdevsvncpp/info.hpp --- a/plugins/subversion/kdevsvncpp/info.hpp +++ b/plugins/subversion/kdevsvncpp/info.hpp @@ -49,7 +49,7 @@ * * @param src another entry to copy from */ - Info(const Path & path, const svn_info_t * src = 0); + Info(const Path & path, const svn_info_t * src = nullptr); /** * copy constructor diff --git a/plugins/subversion/kdevsvncpp/pool.hpp b/plugins/subversion/kdevsvncpp/pool.hpp --- a/plugins/subversion/kdevsvncpp/pool.hpp +++ b/plugins/subversion/kdevsvncpp/pool.hpp @@ -41,7 +41,7 @@ * * @param parent NULL -> global pool */ - Pool(apr_pool_t * parent = (apr_pool_t *)0); + Pool(apr_pool_t * parent = nullptr); virtual ~ Pool(); diff --git a/plugins/subversion/kdevsvncpp/property.hpp b/plugins/subversion/kdevsvncpp/property.hpp --- a/plugins/subversion/kdevsvncpp/property.hpp +++ b/plugins/subversion/kdevsvncpp/property.hpp @@ -64,7 +64,7 @@ class Property { public: - Property(Context * context = 0, + Property(Context * context = nullptr, const Path & path = ""); virtual ~Property(); diff --git a/plugins/subversion/kdevsvncpp/status.hpp b/plugins/subversion/kdevsvncpp/status.hpp --- a/plugins/subversion/kdevsvncpp/status.hpp +++ b/plugins/subversion/kdevsvncpp/status.hpp @@ -50,7 +50,7 @@ * @param path * @param status */ - Status(const char * path = 0, const svn_wc_status2_t * status = 0); + Status(const char * path = nullptr, const svn_wc_status2_t * status = nullptr); /** * copy constructor diff --git a/plugins/subversion/kdevsvncpp/targets.hpp b/plugins/subversion/kdevsvncpp/targets.hpp --- a/plugins/subversion/kdevsvncpp/targets.hpp +++ b/plugins/subversion/kdevsvncpp/targets.hpp @@ -64,7 +64,7 @@ * * @param target */ - Targets(const char * target = 0); + Targets(const char * target = nullptr); /** * Copy Constructor diff --git a/project/tests/test_projectmodel.cpp b/project/tests/test_projectmodel.cpp --- a/project/tests/test_projectmodel.cpp +++ b/project/tests/test_projectmodel.cpp @@ -114,12 +114,12 @@ void TestProjectModel::testCreateFileSystemItems_data() { - QTest::addColumn( "itemType" ); - QTest::addColumn( "itemPath" ); - QTest::addColumn( "expectedItemPath" ); - QTest::addColumn( "expectedItemText" ); - QTest::addColumn( "expectedRelativeItemPath" ); - QTest::addColumn( "expectedItemRow" ); + QTest::addColumn( "itemType", nullptr ); + QTest::addColumn( "itemPath", nullptr ); + QTest::addColumn( "expectedItemPath", nullptr ); + QTest::addColumn( "expectedItemText", nullptr ); + QTest::addColumn( "expectedRelativeItemPath", nullptr ); + QTest::addColumn( "expectedItemRow", nullptr ); QTest::newRow("RootFolder") << (int)ProjectBaseItem::Folder @@ -181,11 +181,11 @@ void TestProjectModel::testCreateTargetItems_data() { - QTest::addColumn( "itemType" ); - QTest::addColumn( "itemText" ); - QTest::addColumn( "expectedItemText" ); - QTest::addColumn( "expectedItemPath" ); - QTest::addColumn( "expectedItemRow" ); + QTest::addColumn( "itemType", nullptr ); + QTest::addColumn( "itemText", nullptr ); + QTest::addColumn( "expectedItemText", nullptr ); + QTest::addColumn( "expectedItemPath", nullptr ); + QTest::addColumn( "expectedItemRow", nullptr ); QTest::newRow("RootTarget") << (int)ProjectBaseItem::Target @@ -366,12 +366,12 @@ void TestProjectModel::testRename_data() { - QTest::addColumn( "itemType" ); - QTest::addColumn( "itemText" ); - QTest::addColumn( "newName" ); - QTest::addColumn( "datachangesignal" ); - QTest::addColumn( "expectedItemText" ); - QTest::addColumn( "expectedRenameCode" ); + QTest::addColumn( "itemType", nullptr ); + QTest::addColumn( "itemText", nullptr ); + QTest::addColumn( "newName", nullptr ); + QTest::addColumn( "datachangesignal", nullptr ); + QTest::addColumn( "expectedItemText", nullptr ); + QTest::addColumn( "expectedRenameCode", nullptr ); QTest::newRow("RenameableTarget") << (int)ProjectBaseItem::Target @@ -476,9 +476,9 @@ void TestProjectModel::testItemsForPath_data() { - QTest::addColumn("path"); - QTest::addColumn("root"); - QTest::addColumn("matches"); + QTest::addColumn("path", nullptr); + QTest::addColumn("root", nullptr); + QTest::addColumn("matches", nullptr); { ProjectFolderItem* root = new ProjectFolderItem(nullptr, Path(QUrl::fromLocalFile(QStringLiteral("/tmp/")))); diff --git a/serialization/itemrepository.h b/serialization/itemrepository.h --- a/serialization/itemrepository.h +++ b/serialization/itemrepository.h @@ -130,12 +130,12 @@ Bucket() : m_monsterBucketExtent(0) , m_available(0) - , m_data(0) - , m_mappedData(0) - , m_objectMap(0) + , m_data(nullptr) + , m_mappedData(nullptr) + , m_objectMap(nullptr) , m_largestFreeItem(0) , m_freeItemCount(0) - , m_nextBucketHash(0) + , m_nextBucketHash(nullptr) , m_dirty(false) , m_changed(false) , m_lastUsed(0) @@ -214,7 +214,7 @@ if(static_cast(file->pos()) != offset + (1+m_monsterBucketExtent)*DataSize) { - KMessageBox::error(0, i18n("Failed writing to %1, probably the disk is full", file->fileName())); + KMessageBox::error(nullptr, i18n("Failed writing to %1, probably the disk is full", file->fileName())); abort(); } @@ -1013,7 +1013,7 @@ DynamicItem(const DynamicItem& rhs) : m_item(rhs.m_item), m_start(rhs.m_start) { // qDebug() << "stealing" << m_item; Q_ASSERT(rhs.m_start); - rhs.m_start = 0; + rhs.m_start = nullptr; } Item* operator->() { @@ -1057,20 +1057,20 @@ /// If this is zero, you have to care about storing the data using store() and/or close() by yourself. It does not happen automatically. /// For the global standard registry, the storing/loading is triggered from within duchain, so you don't need to care about it. ItemRepository(const QString& repositoryName, ItemRepositoryRegistry* registry = &globalItemRepositoryRegistry(), - uint repositoryVersion = 1, AbstractRepositoryManager* manager = 0) + uint repositoryVersion = 1, AbstractRepositoryManager* manager = nullptr) : m_ownMutex(QMutex::Recursive) , m_mutex(&m_ownMutex) , m_repositoryName(repositoryName) , m_registry(registry) - , m_file(0) - , m_dynamicFile(0) + , m_file(nullptr) + , m_dynamicFile(nullptr) , m_repositoryVersion(repositoryVersion) , m_manager(manager) { m_unloadingEnabled = true; m_metaDataChanged = true; m_buckets.resize(10); - m_buckets.fill(0); + m_buckets.fill(nullptr); memset(m_firstBucketForHash, 0, bucketHashSize * sizeof(short unsigned int)); @@ -1695,7 +1695,7 @@ const int unloadAfterTicks = 2; if(m_buckets[a]->lastUsed() > unloadAfterTicks) { delete m_buckets[a]; - m_buckets[a] = 0; + m_buckets[a] = nullptr; }else{ m_buckets[a]->tick(); } @@ -1910,9 +1910,9 @@ m_dynamicFile = new QFile(dir.absoluteFilePath( m_repositoryName + QLatin1String("_dynamic") )); if(!m_file->open( QFile::ReadWrite ) || !m_dynamicFile->open( QFile::ReadWrite ) ) { delete m_file; - m_file = 0; + m_file = nullptr; delete m_dynamicFile; - m_dynamicFile = 0; + m_dynamicFile = nullptr; return false; } @@ -1932,7 +1932,7 @@ m_file->write((char*)&m_statItemCount, sizeof(uint)); m_buckets.resize(10); - m_buckets.fill(0); + m_buckets.fill(nullptr); uint bucketCount = m_buckets.size(); m_file->write((char*)&bucketCount, sizeof(uint)); @@ -1944,7 +1944,7 @@ //We have completely initialized the file now if(m_file->pos() != BucketStartOffset) { - KMessageBox::error(0, i18n("Failed writing to %1, probably the disk is full", m_file->fileName())); + KMessageBox::error(nullptr, i18n("Failed writing to %1, probably the disk is full", m_file->fileName())); abort(); } @@ -1967,9 +1967,9 @@ if(storedVersion != m_repositoryVersion || hashSize != bucketHashSize || itemRepositoryVersion != staticItemRepositoryVersion()) { qDebug() << "repository" << m_repositoryName << "version mismatch in" << m_file->fileName() << ", stored: version " << storedVersion << "hashsize" << hashSize << "repository-version" << itemRepositoryVersion << " current: version" << m_repositoryVersion << "hashsize" << bucketHashSize << "repository-version" << staticItemRepositoryVersion(); delete m_file; - m_file = 0; + m_file = nullptr; delete m_dynamicFile; - m_dynamicFile = 0; + m_dynamicFile = nullptr; return false; } m_metaDataChanged = false; @@ -1990,7 +1990,7 @@ } m_fileMapSize = 0; - m_fileMap = 0; + m_fileMap = nullptr; #ifdef ITEMREPOSITORY_USE_MMAP_LOADING if(m_file->size() > BucketStartOffset){ @@ -2020,14 +2020,14 @@ if(m_file) m_file->close(); delete m_file; - m_file = 0; - m_fileMap = 0; + m_file = nullptr; + m_fileMap = nullptr; m_fileMapSize = 0; if(m_dynamicFile) m_dynamicFile->close(); delete m_dynamicFile; - m_dynamicFile = 0; + m_dynamicFile = nullptr; qDeleteAll(m_buckets); m_buckets.clear(); @@ -2136,7 +2136,7 @@ Q_ASSERT(bucketForIndex(bucketNumber)->isEmpty()); Q_ASSERT(bucketForIndex(bucketNumber)->noNextBuckets()); delete m_buckets[bucketNumber]; - m_buckets[bucketNumber] = 0; + m_buckets[bucketNumber] = nullptr; } //m_file must be opened diff --git a/serialization/repositorymanager.h b/serialization/repositorymanager.h --- a/serialization/repositorymanager.h +++ b/serialization/repositorymanager.h @@ -32,7 +32,7 @@ ///@param shareMutex Option repository from where this repository should take the thread-safety mutex RepositoryManager(QString name, int version = 1, - AbstractRepositoryManager*(*shareMutex)() = 0, + AbstractRepositoryManager*(*shareMutex)() = nullptr, ItemRepositoryRegistry& registry = globalItemRepositoryRegistry()) : m_name(name), m_version(version), diff --git a/serialization/tests/test_indexedstring.cpp b/serialization/tests/test_indexedstring.cpp --- a/serialization/tests/test_indexedstring.cpp +++ b/serialization/tests/test_indexedstring.cpp @@ -47,8 +47,8 @@ void TestIndexedString::testUrl_data() { - QTest::addColumn("url"); - QTest::addColumn("string"); + QTest::addColumn("url", nullptr); + QTest::addColumn("string", nullptr); QTest::newRow("empty") << QUrl() << QString(); QTest::newRow("/") << QUrl::fromLocalFile(QStringLiteral("/")) << QStringLiteral("/"); QTest::newRow("/foo/bar") << QUrl::fromLocalFile(QStringLiteral("/foo/bar")) << QStringLiteral("/foo/bar"); @@ -234,7 +234,7 @@ void TestIndexedString::test_data() { - QTest::addColumn("data"); + QTest::addColumn("data", nullptr); QTest::newRow("empty") << QString(); QTest::newRow("char-ascii") << QStringLiteral("a"); diff --git a/shell/core.h b/shell/core.h --- a/shell/core.h +++ b/shell/core.h @@ -63,7 +63,7 @@ * @param session the name or uuid of the session to be loaded * */ - static bool initialize(QObject* splash = 0, Setup mode=Default, const QString& session = {} ); + static bool initialize(QObject* splash = nullptr, Setup mode=Default, const QString& session = {} ); /** * \brief Provide access an instance of Core @@ -123,11 +123,11 @@ protected: friend class CorePrivate; - Core( KDevelop::CorePrivate* dd, QObject* parent = 0 ); + Core( KDevelop::CorePrivate* dd, QObject* parent = nullptr ); KDevelop::CorePrivate *d; static Core *m_self; private: - Core(QObject *parent = 0); + Core(QObject *parent = nullptr); }; } diff --git a/shell/openprojectdialog.cpp b/shell/openprojectdialog.cpp --- a/shell/openprojectdialog.cpp +++ b/shell/openprojectdialog.cpp @@ -69,7 +69,7 @@ { OpenProjectDialog::OpenProjectDialog( bool fetch, const QUrl& startUrl, QWidget* parent ) - : KAssistantDialog( parent ) + : KAssistantDialog( parent, nullptr ) , sourcePage(nullptr) , openPage(nullptr) , projectInfoPage(nullptr) diff --git a/shell/tests/test_projectcontroller.cpp b/shell/tests/test_projectcontroller.cpp --- a/shell/tests/test_projectcontroller.cpp +++ b/shell/tests/test_projectcontroller.cpp @@ -477,7 +477,7 @@ void TestProjectController::prettyFileName_data() { - QTest::addColumn("relativeFilePath"); + QTest::addColumn("relativeFilePath", nullptr); QTest::newRow("basic") << "foobar.txt"; diff --git a/shell/tests/test_sessioncontroller.cpp b/shell/tests/test_sessioncontroller.cpp --- a/shell/tests/test_sessioncontroller.cpp +++ b/shell/tests/test_sessioncontroller.cpp @@ -94,7 +94,7 @@ void TestSessionController::createSession_data() { - QTest::addColumn( "sessionName" ); + QTest::addColumn( "sessionName", nullptr ); QTest::newRow("SimpleName") << "TestSession"; QTest::newRow("NonLetterChars") << "Test%$Session"; QTest::newRow("NonAsciiChars") << QStringLiteral("TöstSession"); diff --git a/shell/uicontroller.cpp b/shell/uicontroller.cpp --- a/shell/uicontroller.cpp +++ b/shell/uicontroller.cpp @@ -114,7 +114,7 @@ if(!(Core::self()->setupFlags() & Core::NoUi)) { - defaultMainWindow = new MainWindow(m_controller); + defaultMainWindow = new MainWindow(m_controller, nullptr); m_controller->addMainWindow(defaultMainWindow); activeSublimeWindow = defaultMainWindow; } @@ -254,7 +254,7 @@ return; } - MainWindow *main = new MainWindow(this); + MainWindow *main = new MainWindow(this, nullptr); addMainWindow(main); showArea(areaName, main); diff --git a/sublime/areaindex.h b/sublime/areaindex.h --- a/sublime/areaindex.h +++ b/sublime/areaindex.h @@ -126,7 +126,7 @@ Does nothing if the view is already split. @param after if not 0, new view will be placed after this one. @param view the view to be added.*/ - void add(View *view, View *after = 0); + void add(View *view, View *after = nullptr); /**Removes view and unsplits the parent index when no views are left at the current index.*/ void remove(View *view); diff --git a/sublime/examples/example1main.cpp b/sublime/examples/example1main.cpp --- a/sublime/examples/example1main.cpp +++ b/sublime/examples/example1main.cpp @@ -36,7 +36,7 @@ #include Example1Main::Example1Main() - :KXmlGuiWindow(nullptr) + : KXmlGuiWindow(nullptr, nullptr) { //documents m_controller = new Sublime::Controller(this); @@ -88,7 +88,7 @@ void Example1Main::selectArea1() { - Sublime::MainWindow *main = new Sublime::MainWindow(m_controller); + Sublime::MainWindow *main = new Sublime::MainWindow(m_controller, nullptr); connect(main, &Sublime::MainWindow::areaChanged, this, &Example1Main::updateTitle); m_controller->showArea(m_area1, main); main->show(); @@ -96,7 +96,7 @@ void Example1Main::selectArea2() { - Sublime::MainWindow *main = new Sublime::MainWindow(m_controller); + Sublime::MainWindow *main = new Sublime::MainWindow(m_controller, nullptr); connect(main, &Sublime::MainWindow::areaChanged, this, &Example1Main::updateTitle); m_controller->showArea(m_area2, main); main->show(); diff --git a/sublime/examples/example2.cpp b/sublime/examples/example2.cpp --- a/sublime/examples/example2.cpp +++ b/sublime/examples/example2.cpp @@ -35,7 +35,7 @@ controller->addDefaultArea(area); Sublime::Document *doc = new Sublime::UrlDocument(controller, QUrl::fromLocalFile(QStringLiteral("~/foo.cpp"))); area->addView(doc->createView()); - Example2Main *window = new Example2Main(controller); + Example2Main *window = new Example2Main(controller, nullptr); controller->showArea(area, window); window->resize(800, 600); window->show(); diff --git a/sublime/tests/test_areaoperation.cpp b/sublime/tests/test_areaoperation.cpp --- a/sublime/tests/test_areaoperation.cpp +++ b/sublime/tests/test_areaoperation.cpp @@ -195,13 +195,13 @@ void TestAreaOperation::mainWindowConstruction() { //====== check for m_area1 ====== - MainWindow mw1(m_controller); + MainWindow mw1(m_controller, nullptr); m_controller->showArea(m_area1, &mw1); checkArea1(&mw1); ///////////// //====== check for m_area2 ====== - MainWindow mw2(m_controller); + MainWindow mw2(m_controller, nullptr); m_controller->showArea(m_area2, &mw2); checkArea2(&mw2); } @@ -292,12 +292,12 @@ void TestAreaOperation::areaCloning() { //show m_area1 in MainWindow1 - MainWindow mw1(m_controller); + MainWindow mw1(m_controller, nullptr); m_controller->showArea(m_area1, &mw1); checkArea1(&mw1); //now try to show the same area in MainWindow2 and check that we get a clone - MainWindow mw2(m_controller); + MainWindow mw2(m_controller, nullptr); m_controller->showArea(m_area1, &mw2); //two mainwindows have different areas @@ -344,7 +344,7 @@ void TestAreaOperation::areaSwitchingInSameMainwindow() { - MainWindow mw(m_controller); + MainWindow mw(m_controller, nullptr); m_controller->showArea(m_area1, &mw); checkArea1(&mw); @@ -370,7 +370,7 @@ } m_controller->loadSettings(); - MainWindow mw(m_controller); + MainWindow mw(m_controller, nullptr); m_controller->addMainWindow(&mw); m_controller->showArea(m_area1, &mw); @@ -421,7 +421,7 @@ void TestAreaOperation::complexViewAdditionAndDeletion() { Area *area = m_area2; - MainWindow mw(m_controller); + MainWindow mw(m_controller, nullptr); m_controller->addMainWindow(&mw); m_controller->showArea(m_area2, &mw); @@ -503,7 +503,7 @@ void TestAreaOperation::toolViewAdditionAndDeletion() { - MainWindow mw(m_controller); + MainWindow mw(m_controller, nullptr); m_controller->showArea(m_area1, &mw); checkArea1(&mw); @@ -561,7 +561,7 @@ //////////////////////////////////////////////////////////////////////////////// void TestAreaOperation::splitViewActiveTabsTest() { - MainWindow mw(m_controller); + MainWindow mw(m_controller, nullptr); m_controller->showArea(m_area1, &mw); checkArea1(&mw); diff --git a/sublime/tests/test_toolviewtoolbar.cpp b/sublime/tests/test_toolviewtoolbar.cpp --- a/sublime/tests/test_toolviewtoolbar.cpp +++ b/sublime/tests/test_toolviewtoolbar.cpp @@ -53,7 +53,7 @@ // this is starting to become a GeneralFixture controller = new Controller(this); area = new Area( controller, QStringLiteral("Area") ); - MainWindow* mw = new MainWindow(controller); + MainWindow* mw = new MainWindow(controller, nullptr); // a horizontal tool with toolbar ToolViewToolBarFactory* factoryT1 = new ToolViewToolBarFactory(QStringLiteral("tool1factory")); diff --git a/sublime/tests/test_viewactivation.cpp b/sublime/tests/test_viewactivation.cpp --- a/sublime/tests/test_viewactivation.cpp +++ b/sublime/tests/test_viewactivation.cpp @@ -124,7 +124,7 @@ void TestViewActivation::viewActivation() { - MainWindow* mw = new MainWindow(controller); + MainWindow* mw = new MainWindow(controller, nullptr); controller->addDefaultArea(area); // Q_ASSERT without this. controller->addMainWindow(mw); @@ -179,12 +179,12 @@ void TestViewActivation::activationInMultipleMainWindows() { - MainWindow mw(controller); + MainWindow mw(controller, nullptr); controller->showArea(area, &mw); QCOMPARE(mw.activeView(), view211); //check that new mainwindow always have active view right after displaying area - MainWindow mw2(controller); + MainWindow mw2(controller, nullptr); controller->showArea(area, &mw2); QVERIFY(mw2.activeView()); QCOMPARE(mw2.activeView()->document(), doc1); @@ -192,7 +192,7 @@ void TestViewActivation::activationAfterViewRemoval() { - MainWindow mw(controller); + MainWindow mw(controller, nullptr); controller->showArea(area, &mw); QCOMPARE(mw.activeView(), view211); @@ -210,7 +210,7 @@ void TestViewActivation::activationAfterRemovalSimplestCase() { //we don't have split views - just two views in one area index - MainWindow mw(controller); + MainWindow mw(controller, nullptr); Area *area = new Area(controller, QStringLiteral("Area")); View *v1 = doc1->createView(); View *v2 = doc2->createView(); diff --git a/tests/json/jsondeclarationtests.h b/tests/json/jsondeclarationtests.h --- a/tests/json/jsondeclarationtests.h +++ b/tests/json/jsondeclarationtests.h @@ -182,7 +182,7 @@ const QString UN_ID_ERROR = QStringLiteral("Unable to identify declaration of type \"%1\"."); AbstractType::Ptr type = TypeUtils::targetType(decl->abstractType(), decl->topContext()); IdentifiedType* idType = dynamic_cast(type.data()); - Declaration* idDecl = idType ? idType->declaration(decl->topContext()) : 0; + Declaration* idDecl = idType ? idType->declaration(decl->topContext()) : nullptr; if (!idDecl) return UN_ID_ERROR.arg(type->toString()); @@ -238,7 +238,7 @@ DeclarationTest(definition) { KDevVarLengthArray definitions = DUChain::definitions()->definitions(decl->id()); - Declaration *declDef = 0; + Declaration *declDef = nullptr; if (!definitions.isEmpty()) declDef = definitions.at(0).declaration(); return testObject(declDef, value, QStringLiteral("Declaration's definition")); @@ -257,7 +257,7 @@ ///@returns whether the declaration's nullity matches the given value DeclarationTest(null) { - return compareValues(decl == 0, value, QStringLiteral("Declaration's nullity")); + return compareValues(decl == nullptr, value, QStringLiteral("Declaration's nullity")); } ///JSON type: bool ///@returns whether the declaration's default parameter matches the given value diff --git a/util/convenientfreelist.h b/util/convenientfreelist.h --- a/util/convenientfreelist.h +++ b/util/convenientfreelist.h @@ -36,7 +36,7 @@ template class ConstantConvenientEmbeddedSet { public: - ConstantConvenientEmbeddedSet() : m_data(0), m_dataSize(0), m_centralFreeItem(-1) { + ConstantConvenientEmbeddedSet() : m_data(nullptr), m_dataSize(0), m_centralFreeItem(-1) { } ConstantConvenientEmbeddedSet(const Data* data, uint count, int centralFreeItem) : m_data(data), m_dataSize(count), m_centralFreeItem(centralFreeItem) { } @@ -151,7 +151,7 @@ template class ConvenientEmbeddedSetIterator : public ConstantConvenientEmbeddedSet { public: - ConvenientEmbeddedSetIterator(const Data* data = 0, uint count = 0, int centralFreeItem = -1) : ConstantConvenientEmbeddedSet(data, count, centralFreeItem), m_pos(0) { + ConvenientEmbeddedSetIterator(const Data* data = nullptr, uint count = 0, int centralFreeItem = -1) : ConstantConvenientEmbeddedSet(data, count, centralFreeItem), m_pos(0) { //Move to first valid position moveToValid(); } diff --git a/util/embeddedfreetree.h b/util/embeddedfreetree.h --- a/util/embeddedfreetree.h +++ b/util/embeddedfreetree.h @@ -274,7 +274,7 @@ } ///Transfers the data into a new item-list. The size of the new item-list must equal newItemCount() - void transferData(Data* newItems, uint newCount, int* newCentralFree = 0) { + void transferData(Data* newItems, uint newCount, int* newCentralFree = nullptr) { DEBUG_FREEITEM_COUNT uint currentRealCount = m_itemCount - countFreeItems(*m_centralFreeItem); @@ -756,7 +756,7 @@ } ///Transfers the data into a new item-list. The size of the new item-list must equal newItemCount() - void transferData(Data* newItems, uint newCount, int* newCentralFree = 0) { + void transferData(Data* newItems, uint newCount, int* newCentralFree = nullptr) { DEBUG_FREEITEM_COUNT //We only transfer into a new list when all the free items are used up diff --git a/util/tests/test_environment.cpp b/util/tests/test_environment.cpp --- a/util/tests/test_environment.cpp +++ b/util/tests/test_environment.cpp @@ -31,8 +31,8 @@ void TestEnvironment::testExpandVariables_data() { - QTest::addColumn("env"); - QTest::addColumn("expectedEnv"); + QTest::addColumn("env", nullptr); + QTest::addColumn("expectedEnv", nullptr); QTest::newRow("no variables") << ProcEnv({}) << ProcEnv({}); QTest::newRow("simple variables") << ProcEnv{ diff --git a/util/tests/test_foregroundlock.cpp b/util/tests/test_foregroundlock.cpp --- a/util/tests/test_foregroundlock.cpp +++ b/util/tests/test_foregroundlock.cpp @@ -46,7 +46,7 @@ void TestForegroundLock::testTryLock_data() { - QTest::addColumn("numThreads"); + QTest::addColumn("numThreads", nullptr); for (int i = 1; i <= 10; ++i) { QTest::newRow(qPrintable(QString::number(i))) << i; } diff --git a/util/tests/test_path.cpp b/util/tests/test_path.cpp --- a/util/tests/test_path.cpp +++ b/util/tests/test_path.cpp @@ -161,7 +161,7 @@ void TestPath::bench_fromLocalPath_data() { - QTest::addColumn("variant"); + QTest::addColumn("variant", nullptr); QTest::newRow("QUrl::fromLocalFile") << 1; QTest::newRow("QString") << 2; @@ -315,7 +315,7 @@ void TestPath::testPath_data() { - QTest::addColumn("input"); + QTest::addColumn("input", nullptr); #ifndef Q_OS_WIN QTest::newRow("invalid") << ""; @@ -350,7 +350,7 @@ void TestPath::testPathInvalid_data() { - QTest::addColumn("input"); + QTest::addColumn("input", nullptr); QTest::newRow("empty") << ""; QTest::newRow("fragment") << "http://test.com/#hello"; @@ -388,10 +388,10 @@ void TestPath::testPathOperators_data() { - QTest::addColumn("left"); - QTest::addColumn("right"); - QTest::addColumn("equal"); - QTest::addColumn("less"); + QTest::addColumn("left", nullptr); + QTest::addColumn("right", nullptr); + QTest::addColumn("equal", nullptr); + QTest::addColumn("less", nullptr); Path a(QStringLiteral("/tmp/a")); Path b(QStringLiteral("/tmp/b")); @@ -450,7 +450,7 @@ void TestPath::testPathAddData_data() { - QTest::addColumn("pathToAdd"); + QTest::addColumn("pathToAdd", nullptr); const QStringList paths = QStringList() << QStringLiteral("file.txt") @@ -486,9 +486,9 @@ void TestPath::testPathBaseCtor_data() { - QTest::addColumn("base"); - QTest::addColumn("subPath"); - QTest::addColumn("expected"); + QTest::addColumn("base", nullptr); + QTest::addColumn("subPath", nullptr); + QTest::addColumn("expected", nullptr); QTest::newRow("empty") << "" << "" << ""; QTest::newRow("empty-relative") << "" << "foo" << ""; @@ -546,8 +546,8 @@ void TestPath::testPathCd_data() { - QTest::addColumn("base"); - QTest::addColumn("change"); + QTest::addColumn("base", nullptr); + QTest::addColumn("change", nullptr); const QVector bases{ QLatin1String(""), @@ -584,8 +584,8 @@ void TestPath::testHasParent_data() { - QTest::addColumn("input"); - QTest::addColumn("hasParent"); + QTest::addColumn("input", nullptr); + QTest::addColumn("hasParent", nullptr); QTest::newRow("empty") << QString() << false; QTest::newRow("/") << QStringLiteral("/") << false; diff --git a/util/tests/test_stringhandler.cpp b/util/tests/test_stringhandler.cpp --- a/util/tests/test_stringhandler.cpp +++ b/util/tests/test_stringhandler.cpp @@ -43,9 +43,9 @@ void TestStringHandler::testHtmlToPlainText_data() { - QTest::addColumn("html"); - QTest::addColumn("mode"); - QTest::addColumn("expectedPlainText"); + QTest::addColumn("html", nullptr); + QTest::addColumn("mode", nullptr); + QTest::addColumn("expectedPlainText", nullptr); QTest::newRow("simple-fast") << "

bar()

a
foo
" @@ -66,8 +66,8 @@ void TestStringHandler::testStripAnsiSequences_data() { - QTest::addColumn("input"); - QTest::addColumn("expectedOutput"); + QTest::addColumn("input", nullptr); + QTest::addColumn("expectedOutput", nullptr); QTest::newRow("simple") << QStringLiteral("foo bar:") diff --git a/util/tests/test_texteditorhelpers.cpp b/util/tests/test_texteditorhelpers.cpp --- a/util/tests/test_texteditorhelpers.cpp +++ b/util/tests/test_texteditorhelpers.cpp @@ -43,9 +43,9 @@ void TestKTextEditorHelpers::testExtractCursor_data() { - QTest::addColumn("input"); - QTest::addColumn("expectedCursor"); - QTest::addColumn("expectedPath"); + QTest::addColumn("input", nullptr); + QTest::addColumn("expectedCursor", nullptr); + QTest::addColumn("expectedPath", nullptr); // valid input QTest::newRow("file") diff --git a/vcs/vcsjob.h b/vcs/vcsjob.h --- a/vcs/vcsjob.h +++ b/vcs/vcsjob.h @@ -44,7 +44,7 @@ { Q_OBJECT public: - explicit VcsJob( QObject* parent = 0, OutputJobVerbosity verbosity = OutputJob::Verbose); + explicit VcsJob( QObject* parent = nullptr, OutputJobVerbosity verbosity = OutputJob::Verbose); virtual ~VcsJob(); /** * To easily check which type of job this is.