summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAlessandro Portale <alessandro.portale@qt.io>2019-01-14 01:40:53 +0100
committerAlessandro Portale <alessandro.portale@qt.io>2019-01-21 09:00:18 +0000
commit1d3d18a96988eb091b207103f18c9fbba505013a (patch)
treeea96a5524d5dbda96447455a9152484e54ea6e3b /src
parent845af928896ba1ef1bb7259766913ea7f4c35cd9 (diff)
downloadqt-creator-1d3d18a96988eb091b207103f18c9fbba505013a.tar.gz
CppTools: modernize
Change-Id: Iaf02e4d026f1ac8b216833d83cd7a735e21ff60a Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io> Reviewed-by: Orgad Shaneh <orgads@gmail.com>
Diffstat (limited to 'src')
-rw-r--r--src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp2
-rw-r--r--src/plugins/clangcodemodel/clangeditordocumentprocessor.h2
-rw-r--r--src/plugins/cpptools/abstracteditorsupport.cpp2
-rw-r--r--src/plugins/cpptools/baseeditordocumentparser.cpp4
-rw-r--r--src/plugins/cpptools/baseeditordocumentprocessor.cpp6
-rw-r--r--src/plugins/cpptools/baseeditordocumentprocessor.h6
-rw-r--r--src/plugins/cpptools/builtincursorinfo.cpp4
-rw-r--r--src/plugins/cpptools/builtineditordocumentprocessor.cpp12
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.cpp16
-rw-r--r--src/plugins/cpptools/builtinindexingsupport.h6
-rw-r--r--src/plugins/cpptools/clangdiagnosticconfigsmodel.h2
-rw-r--r--src/plugins/cpptools/compileroptionsbuilder.cpp6
-rw-r--r--src/plugins/cpptools/cppbuiltinmodelmanagersupport.cpp4
-rw-r--r--src/plugins/cpptools/cppbuiltinmodelmanagersupport.h2
-rw-r--r--src/plugins/cpptools/cppcanonicalsymbol.cpp14
-rw-r--r--src/plugins/cpptools/cppchecksymbols.cpp47
-rw-r--r--src/plugins/cpptools/cppchecksymbols.h8
-rw-r--r--src/plugins/cpptools/cppclassesfilter.cpp4
-rw-r--r--src/plugins/cpptools/cppclassesfilter.h2
-rw-r--r--src/plugins/cpptools/cppcodeformatter.cpp12
-rw-r--r--src/plugins/cpptools/cppcodeformatter.h2
-rw-r--r--src/plugins/cpptools/cppcodegen_test.cpp2
-rw-r--r--src/plugins/cpptools/cppcodemodelinspectordumper.cpp4
-rw-r--r--src/plugins/cpptools/cppcodemodelsettingspage.h10
-rw-r--r--src/plugins/cpptools/cppcodestylepreferencesfactory.cpp10
-rw-r--r--src/plugins/cpptools/cppcodestylepreferencesfactory.h14
-rw-r--r--src/plugins/cpptools/cppcodestylesettings.cpp6
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.cpp17
-rw-r--r--src/plugins/cpptools/cppcodestylesettingspage.h18
-rw-r--r--src/plugins/cpptools/cppcompletion_test.cpp13
-rw-r--r--src/plugins/cpptools/cppcompletionassist.cpp69
-rw-r--r--src/plugins/cpptools/cppcompletionassist.h8
-rw-r--r--src/plugins/cpptools/cppcompletionassistprocessor.cpp4
-rw-r--r--src/plugins/cpptools/cppcompletionassistprocessor.h6
-rw-r--r--src/plugins/cpptools/cppcompletionassistprovider.cpp2
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.cpp2
-rw-r--r--src/plugins/cpptools/cppcurrentdocumentfilter.h2
-rw-r--r--src/plugins/cpptools/cppelementevaluator.cpp16
-rw-r--r--src/plugins/cpptools/cppelementevaluator.h2
-rw-r--r--src/plugins/cpptools/cppfileiterationorder.cpp4
-rw-r--r--src/plugins/cpptools/cppfilesettingspage.h12
-rw-r--r--src/plugins/cpptools/cppfindreferences.cpp34
-rw-r--r--src/plugins/cpptools/cppfindreferences.h4
-rw-r--r--src/plugins/cpptools/cppfollowsymbolundercursor.cpp36
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.cpp4
-rw-r--r--src/plugins/cpptools/cppfunctionsfilter.h4
-rw-r--r--src/plugins/cpptools/cppincludesfilter.cpp12
-rw-r--r--src/plugins/cpptools/cppindexingsupport.cpp7
-rw-r--r--src/plugins/cpptools/cppindexingsupport.h4
-rw-r--r--src/plugins/cpptools/cppkitinfo.h2
-rw-r--r--src/plugins/cpptools/cpplocalsymbols.cpp4
-rw-r--r--src/plugins/cpptools/cpplocalsymbols_test.cpp17
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.cpp4
-rw-r--r--src/plugins/cpptools/cpplocatorfilter.h2
-rw-r--r--src/plugins/cpptools/cpplocatorfilter_test.cpp11
-rw-r--r--src/plugins/cpptools/cppmodelmanager.cpp10
-rw-r--r--src/plugins/cpptools/cppmodelmanager.h6
-rw-r--r--src/plugins/cpptools/cppmodelmanager_test.cpp36
-rw-r--r--src/plugins/cpptools/cppmodelmanagerinterface.h2
-rw-r--r--src/plugins/cpptools/cppmodelmanagersupport.cpp4
-rw-r--r--src/plugins/cpptools/cppmodelmanagersupport.h2
-rw-r--r--src/plugins/cpptools/cppoverviewmodel.cpp4
-rw-r--r--src/plugins/cpptools/cppoverviewmodel.h2
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter.h6
-rw-r--r--src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp4
-rw-r--r--src/plugins/cpptools/cppprojectfilecategorizer.cpp4
-rw-r--r--src/plugins/cpptools/cppprojectfilecategorizer.h4
-rw-r--r--src/plugins/cpptools/cppprojectpartchooser.cpp2
-rw-r--r--src/plugins/cpptools/cppqtstyleindenter.cpp7
-rw-r--r--src/plugins/cpptools/cppqtstyleindenter.h2
-rw-r--r--src/plugins/cpptools/cpprawprojectpart.cpp2
-rw-r--r--src/plugins/cpptools/cpprawprojectpart.h4
-rw-r--r--src/plugins/cpptools/cpprefactoringchanges.cpp4
-rw-r--r--src/plugins/cpptools/cpprefactoringchanges.h8
-rw-r--r--src/plugins/cpptools/cppselectionchanger.cpp23
-rw-r--r--src/plugins/cpptools/cppselectionchanger.h20
-rw-r--r--src/plugins/cpptools/cppsemanticinfoupdater.cpp14
-rw-r--r--src/plugins/cpptools/cppsemanticinfoupdater.h4
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.cpp11
-rw-r--r--src/plugins/cpptools/cppsourceprocessor.h4
-rw-r--r--src/plugins/cpptools/cppsourceprocessor_test.cpp4
-rw-r--r--src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp2
-rw-r--r--src/plugins/cpptools/cpptoolsjsextension.h2
-rw-r--r--src/plugins/cpptools/cpptoolsreuse.cpp4
-rw-r--r--src/plugins/cpptools/cpptoolssettings.cpp16
-rw-r--r--src/plugins/cpptools/cpptoolstestcase.cpp4
-rw-r--r--src/plugins/cpptools/cpptoolstestcase.h4
-rw-r--r--src/plugins/cpptools/cppvirtualfunctionassistprovider.cpp18
-rw-r--r--src/plugins/cpptools/cppvirtualfunctionproposalitem.h2
-rw-r--r--src/plugins/cpptools/cppworkingcopy.cpp4
-rw-r--r--src/plugins/cpptools/cppworkingcopy.h2
-rw-r--r--src/plugins/cpptools/doxygengenerator.cpp4
-rw-r--r--src/plugins/cpptools/editordocumenthandle.cpp4
-rw-r--r--src/plugins/cpptools/followsymbolinterface.h2
-rw-r--r--src/plugins/cpptools/functionutils.cpp8
-rw-r--r--src/plugins/cpptools/includeutils.cpp6
-rw-r--r--src/plugins/cpptools/includeutils.h6
-rw-r--r--src/plugins/cpptools/indexitem.h6
-rw-r--r--src/plugins/cpptools/insertionpointlocator.cpp43
-rw-r--r--src/plugins/cpptools/insertionpointlocator.h2
-rw-r--r--src/plugins/cpptools/modelmanagertesthelper.cpp2
-rw-r--r--src/plugins/cpptools/modelmanagertesthelper.h6
-rw-r--r--src/plugins/cpptools/projectinfo.h2
-rw-r--r--src/plugins/cpptools/refactoringengineinterface.h2
-rw-r--r--src/plugins/cpptools/searchsymbols.cpp4
-rw-r--r--src/plugins/cpptools/semantichighlighter.cpp5
-rw-r--r--src/plugins/cpptools/semantichighlighter.h4
-rw-r--r--src/plugins/cpptools/stringtable.cpp2
-rw-r--r--src/plugins/cpptools/symbolfinder.cpp28
-rw-r--r--src/plugins/cpptools/symbolsearcher_test.cpp26
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.cpp18
-rw-r--r--src/plugins/cpptools/symbolsfindfilter.h18
-rw-r--r--src/plugins/cpptools/typehierarchybuilder.cpp5
-rw-r--r--src/plugins/cpptools/typehierarchybuilder.h4
-rw-r--r--src/plugins/cpptools/typehierarchybuilder_test.cpp27
-rw-r--r--src/plugins/cpptools/usages.h2
116 files changed, 461 insertions, 555 deletions
diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
index b5893947b7..f7bf55a242 100644
--- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
+++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.cpp
@@ -323,7 +323,7 @@ void ClangEditorDocumentProcessor::invalidateDiagnostics()
}
void ClangEditorDocumentProcessor::setParserConfig(
- const CppTools::BaseEditorDocumentParser::Configuration config)
+ const CppTools::BaseEditorDocumentParser::Configuration &config)
{
m_parser->setConfiguration(config);
m_builtinProcessor.parser()->setConfiguration(config);
diff --git a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h
index 78d777ddfa..a7da1bb2e1 100644
--- a/src/plugins/clangcodemodel/clangeditordocumentprocessor.h
+++ b/src/plugins/clangcodemodel/clangeditordocumentprocessor.h
@@ -88,7 +88,7 @@ public:
void editorDocumentTimerRestarted() override;
- void setParserConfig(const CppTools::BaseEditorDocumentParser::Configuration config) override;
+ void setParserConfig(const CppTools::BaseEditorDocumentParser::Configuration &config) override;
QFuture<CppTools::CursorInfo> cursorInfo(const CppTools::CursorInfoParams &params) override;
QFuture<CppTools::CursorInfo> requestLocalReferences(const QTextCursor &cursor) override;
diff --git a/src/plugins/cpptools/abstracteditorsupport.cpp b/src/plugins/cpptools/abstracteditorsupport.cpp
index c2f435b171..22a4c304d5 100644
--- a/src/plugins/cpptools/abstracteditorsupport.cpp
+++ b/src/plugins/cpptools/abstracteditorsupport.cpp
@@ -65,7 +65,7 @@ QString AbstractEditorSupport::licenseTemplate(const QString &file, const QStrin
expander.registerVariable("Cpp:License:ClassName", tr("The class name."),
[className]() { return className; });
- return Utils::TemplateEngine::processText(&expander, license, 0);
+ return Utils::TemplateEngine::processText(&expander, license, nullptr);
}
} // namespace CppTools
diff --git a/src/plugins/cpptools/baseeditordocumentparser.cpp b/src/plugins/cpptools/baseeditordocumentparser.cpp
index 1068a90e9f..f0c7d9f680 100644
--- a/src/plugins/cpptools/baseeditordocumentparser.cpp
+++ b/src/plugins/cpptools/baseeditordocumentparser.cpp
@@ -58,9 +58,7 @@ BaseEditorDocumentParser::BaseEditorDocumentParser(const QString &filePath)
Q_UNUSED(meta);
}
-BaseEditorDocumentParser::~BaseEditorDocumentParser()
-{
-}
+BaseEditorDocumentParser::~BaseEditorDocumentParser() = default;
QString BaseEditorDocumentParser::filePath() const
{
diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.cpp b/src/plugins/cpptools/baseeditordocumentprocessor.cpp
index 20632289c6..8c869ee51f 100644
--- a/src/plugins/cpptools/baseeditordocumentprocessor.cpp
+++ b/src/plugins/cpptools/baseeditordocumentprocessor.cpp
@@ -52,9 +52,7 @@ BaseEditorDocumentProcessor::BaseEditorDocumentProcessor(QTextDocument *textDocu
{
}
-BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor()
-{
-}
+BaseEditorDocumentProcessor::~BaseEditorDocumentProcessor() = default;
void BaseEditorDocumentProcessor::run(bool projectsUpdated)
{
@@ -92,7 +90,7 @@ void BaseEditorDocumentProcessor::invalidateDiagnostics()
}
void BaseEditorDocumentProcessor::setParserConfig(
- const BaseEditorDocumentParser::Configuration config)
+ const BaseEditorDocumentParser::Configuration &config)
{
parser()->setConfiguration(config);
}
diff --git a/src/plugins/cpptools/baseeditordocumentprocessor.h b/src/plugins/cpptools/baseeditordocumentprocessor.h
index 4c61a3c746..3fcf363046 100644
--- a/src/plugins/cpptools/baseeditordocumentprocessor.h
+++ b/src/plugins/cpptools/baseeditordocumentprocessor.h
@@ -86,7 +86,7 @@ public:
virtual void editorDocumentTimerRestarted();
- virtual void setParserConfig(const BaseEditorDocumentParser::Configuration config);
+ virtual void setParserConfig(const BaseEditorDocumentParser::Configuration &config);
virtual QFuture<CursorInfo> cursorInfo(const CursorInfoParams &params) = 0;
virtual QFuture<CursorInfo> requestLocalReferences(const QTextCursor &cursor) = 0;
@@ -103,12 +103,12 @@ signals:
void projectPartInfoUpdated(const CppTools::ProjectPartInfo &projectPartInfo);
void codeWarningsUpdated(unsigned revision,
- const QList<QTextEdit::ExtraSelection> selections,
+ const QList<QTextEdit::ExtraSelection> &selections,
const HeaderErrorDiagnosticWidgetCreator &creator,
const TextEditor::RefactorMarkers &refactorMarkers);
void ifdefedOutBlocksUpdated(unsigned revision,
- const QList<TextEditor::BlockRange> ifdefedOutBlocks);
+ const QList<TextEditor::BlockRange> &ifdefedOutBlocks);
void cppDocumentUpdated(const CPlusPlus::Document::Ptr document); // TODO: Remove me
void semanticInfoUpdated(const CppTools::SemanticInfo semanticInfo); // TODO: Remove me
diff --git a/src/plugins/cpptools/builtincursorinfo.cpp b/src/plugins/cpptools/builtincursorinfo.cpp
index 85603ba090..ffbe196760 100644
--- a/src/plugins/cpptools/builtincursorinfo.cpp
+++ b/src/plugins/cpptools/builtincursorinfo.cpp
@@ -91,7 +91,7 @@ CursorInfo::Ranges toRanges(const SemanticUses &uses)
return ranges;
}
-CursorInfo::Ranges toRanges(const QList<int> tokenIndices, TranslationUnit *translationUnit)
+CursorInfo::Ranges toRanges(const QList<int> &tokenIndices, TranslationUnit *translationUnit)
{
CursorInfo::Ranges ranges;
ranges.reserve(tokenIndices.size());
@@ -109,7 +109,7 @@ class FunctionDefinitionUnderCursor: protected ASTVisitor
DeclarationAST *m_functionDefinition = nullptr;
public:
- FunctionDefinitionUnderCursor(TranslationUnit *translationUnit)
+ explicit FunctionDefinitionUnderCursor(TranslationUnit *translationUnit)
: ASTVisitor(translationUnit)
{ }
diff --git a/src/plugins/cpptools/builtineditordocumentprocessor.cpp b/src/plugins/cpptools/builtineditordocumentprocessor.cpp
index 42daa67963..9232750684 100644
--- a/src/plugins/cpptools/builtineditordocumentprocessor.cpp
+++ b/src/plugins/cpptools/builtineditordocumentprocessor.cpp
@@ -95,14 +95,14 @@ CppTools::CheckSymbols *createHighlighter(const CPlusPlus::Document::Ptr &doc,
const CPlusPlus::Snapshot &snapshot,
QTextDocument *textDocument)
{
- QTC_ASSERT(doc, return 0);
- QTC_ASSERT(doc->translationUnit(), return 0);
- QTC_ASSERT(doc->translationUnit()->ast(), return 0);
- QTC_ASSERT(textDocument, return 0);
+ QTC_ASSERT(doc, return nullptr);
+ QTC_ASSERT(doc->translationUnit(), return nullptr);
+ QTC_ASSERT(doc->translationUnit()->ast(), return nullptr);
+ QTC_ASSERT(textDocument, return nullptr);
using namespace CPlusPlus;
using namespace CppTools;
- typedef TextEditor::HighlightingResult Result;
+ using Result = TextEditor::HighlightingResult;
QList<Result> macroUses;
using Utils::Text::convertPosition;
@@ -168,7 +168,7 @@ BuiltinEditorDocumentProcessor::BuiltinEditorDocumentProcessor(
, m_codeWarningsUpdated(false)
, m_semanticHighlighter(enableSemanticHighlighter
? new CppTools::SemanticHighlighter(document)
- : 0)
+ : nullptr)
{
using namespace Internal;
diff --git a/src/plugins/cpptools/builtinindexingsupport.cpp b/src/plugins/cpptools/builtinindexingsupport.cpp
index 0387d4d9ac..ff21e85500 100644
--- a/src/plugins/cpptools/builtinindexingsupport.cpp
+++ b/src/plugins/cpptools/builtinindexingsupport.cpp
@@ -70,7 +70,6 @@ class WriteTaskFileForDiagnostics
public:
WriteTaskFileForDiagnostics()
- : m_processedDiagnostics(0)
{
const QString fileName = Utils::TemporaryDirectory::masterDirectoryPath()
+ "/qtc_findErrorsIndexing.diagnostics."
@@ -120,7 +119,7 @@ public:
private:
QFile m_file;
QTextStream m_out;
- int m_processedDiagnostics;
+ int m_processedDiagnostics = 0;
};
void classifyFiles(const QSet<QString> &files, QStringList *headers, QStringList *sources)
@@ -262,16 +261,15 @@ class BuiltinSymbolSearcher: public SymbolSearcher
{
public:
BuiltinSymbolSearcher(const CPlusPlus::Snapshot &snapshot,
- Parameters parameters, QSet<QString> fileNames)
+ const Parameters &parameters, const QSet<QString> &fileNames)
: m_snapshot(snapshot)
, m_parameters(parameters)
, m_fileNames(fileNames)
{}
- ~BuiltinSymbolSearcher()
- {}
+ ~BuiltinSymbolSearcher() override = default;
- void runSearch(QFutureInterface<Core::SearchResultItem> &future)
+ void runSearch(QFutureInterface<Core::SearchResultItem> &future) override
{
future.setProgressRange(0, m_snapshot.size());
future.setProgressValue(0);
@@ -343,8 +341,7 @@ BuiltinIndexingSupport::BuiltinIndexingSupport()
m_synchronizer.setCancelOnWait(true);
}
-BuiltinIndexingSupport::~BuiltinIndexingSupport()
-{}
+BuiltinIndexingSupport::~BuiltinIndexingSupport() = default;
QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
const QFutureInterface<void> &superFuture,
@@ -382,7 +379,8 @@ QFuture<void> BuiltinIndexingSupport::refreshSourceFiles(
return result;
}
-SymbolSearcher *BuiltinIndexingSupport::createSymbolSearcher(SymbolSearcher::Parameters parameters, QSet<QString> fileNames)
+SymbolSearcher *BuiltinIndexingSupport::createSymbolSearcher(
+ const SymbolSearcher::Parameters &parameters, const QSet<QString> &fileNames)
{
return new BuiltinSymbolSearcher(CppModelManager::instance()->snapshot(), parameters, fileNames);
}
diff --git a/src/plugins/cpptools/builtinindexingsupport.h b/src/plugins/cpptools/builtinindexingsupport.h
index ad4f06d52e..26e0a22dd3 100644
--- a/src/plugins/cpptools/builtinindexingsupport.h
+++ b/src/plugins/cpptools/builtinindexingsupport.h
@@ -36,13 +36,13 @@ namespace Internal {
class BuiltinIndexingSupport: public CppIndexingSupport {
public:
BuiltinIndexingSupport();
- ~BuiltinIndexingSupport();
+ ~BuiltinIndexingSupport() override;
QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode) override;
- SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
- QSet<QString> fileNames) override;
+ SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters &parameters,
+ const QSet<QString> &fileNames) override;
public:
static bool isFindErrorsIndexingActive();
diff --git a/src/plugins/cpptools/clangdiagnosticconfigsmodel.h b/src/plugins/cpptools/clangdiagnosticconfigsmodel.h
index 5b0f850f79..d698611cd7 100644
--- a/src/plugins/cpptools/clangdiagnosticconfigsmodel.h
+++ b/src/plugins/cpptools/clangdiagnosticconfigsmodel.h
@@ -37,7 +37,7 @@ class CPPTOOLS_EXPORT ClangDiagnosticConfigsModel
{
public:
ClangDiagnosticConfigsModel() = default;
- ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs);
+ explicit ClangDiagnosticConfigsModel(const ClangDiagnosticConfigs &customConfigs);
int size() const;
const ClangDiagnosticConfig &at(int index) const;
diff --git a/src/plugins/cpptools/compileroptionsbuilder.cpp b/src/plugins/cpptools/compileroptionsbuilder.cpp
index 8398bbd687..426a96b534 100644
--- a/src/plugins/cpptools/compileroptionsbuilder.cpp
+++ b/src/plugins/cpptools/compileroptionsbuilder.cpp
@@ -303,13 +303,13 @@ void CompilerOptionsBuilder::addHeaderPathOptions()
}
- for (const HeaderPath &headerPath : filter.userHeaderPaths)
+ for (const HeaderPath &headerPath : qAsConst(filter.userHeaderPaths))
addIncludeDirOptionForPath(headerPath);
- for (const HeaderPath &headerPath : filter.systemHeaderPaths)
+ for (const HeaderPath &headerPath : qAsConst(filter.systemHeaderPaths))
addIncludeDirOptionForPath(headerPath);
- for (const HeaderPath &headerPath : filter.builtInHeaderPaths)
+ for (const HeaderPath &headerPath : qAsConst(filter.builtInHeaderPaths))
addIncludeDirOptionForPath(headerPath);
}
diff --git a/src/plugins/cpptools/cppbuiltinmodelmanagersupport.cpp b/src/plugins/cpptools/cppbuiltinmodelmanagersupport.cpp
index 8aead44395..0fad49c15f 100644
--- a/src/plugins/cpptools/cppbuiltinmodelmanagersupport.cpp
+++ b/src/plugins/cpptools/cppbuiltinmodelmanagersupport.cpp
@@ -61,9 +61,7 @@ BuiltinModelManagerSupport::BuiltinModelManagerSupport()
{
}
-BuiltinModelManagerSupport::~BuiltinModelManagerSupport()
-{
-}
+BuiltinModelManagerSupport::~BuiltinModelManagerSupport() = default;
BaseEditorDocumentProcessor *BuiltinModelManagerSupport::createEditorDocumentProcessor(
TextEditor::TextDocument *baseTextDocument)
diff --git a/src/plugins/cpptools/cppbuiltinmodelmanagersupport.h b/src/plugins/cpptools/cppbuiltinmodelmanagersupport.h
index 49b0756690..3e6587ce8a 100644
--- a/src/plugins/cpptools/cppbuiltinmodelmanagersupport.h
+++ b/src/plugins/cpptools/cppbuiltinmodelmanagersupport.h
@@ -38,7 +38,7 @@ class BuiltinModelManagerSupport: public ModelManagerSupport
public:
BuiltinModelManagerSupport();
- virtual ~BuiltinModelManagerSupport();
+ ~BuiltinModelManagerSupport() override;
CppCompletionAssistProvider *completionAssistProvider() final;
TextEditor::BaseHoverHandler *createHoverHandler() final;
diff --git a/src/plugins/cpptools/cppcanonicalsymbol.cpp b/src/plugins/cpptools/cppcanonicalsymbol.cpp
index fa5d074921..50eb9a3544 100644
--- a/src/plugins/cpptools/cppcanonicalsymbol.cpp
+++ b/src/plugins/cpptools/cppcanonicalsymbol.cpp
@@ -55,7 +55,7 @@ const LookupContext &CanonicalSymbol::context() const
Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString *code)
{
if (!m_document)
- return 0;
+ return nullptr;
QTextCursor tc = cursor;
int line, column;
@@ -65,7 +65,7 @@ Scope *CanonicalSymbol::getScopeAndExpression(const QTextCursor &cursor, QString
QTextDocument *textDocument = cursor.document();
if (!CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
if (!(pos > 0 && CppTools::isValidIdentifierChar(textDocument->characterAt(pos - 1))))
- return 0;
+ return nullptr;
while (CppTools::isValidIdentifierChar(textDocument->characterAt(pos)))
++pos;
@@ -83,7 +83,7 @@ Symbol *CanonicalSymbol::operator()(const QTextCursor &cursor)
if (Scope *scope = getScopeAndExpression(cursor, &code))
return operator()(scope, code);
- return 0;
+ return nullptr;
}
Symbol *CanonicalSymbol::operator()(Scope *scope, const QString &code)
@@ -118,14 +118,12 @@ Symbol *CanonicalSymbol::canonicalSymbol(Scope *scope, const QString &code,
}
}
- for (int i = 0; i < results.size(); ++i) {
- const LookupItem &r = results.at(i);
-
- if (r.declaration())
+ for (const auto &r : results) {
+ if (r.declaration())
return r.declaration();
}
- return 0;
+ return nullptr;
}
} // namespace CppEditor
diff --git a/src/plugins/cpptools/cppchecksymbols.cpp b/src/plugins/cpptools/cppchecksymbols.cpp
index ab2adc104f..ea534531e6 100644
--- a/src/plugins/cpptools/cppchecksymbols.cpp
+++ b/src/plugins/cpptools/cppchecksymbols.cpp
@@ -185,7 +185,7 @@ protected:
bool visit(Declaration *symbol) override
{
- if (symbol->enclosingEnum() != 0)
+ if (symbol->enclosingEnum() != nullptr)
addStatic(symbol->name());
if (symbol->type()->isFunctionType())
@@ -303,9 +303,9 @@ CheckSymbols::Future CheckSymbols::go(Document::Ptr doc, const LookupContext &co
CheckSymbols * CheckSymbols::create(Document::Ptr doc, const LookupContext &context,
const QList<CheckSymbols::Result> &macroUses)
{
- QTC_ASSERT(doc, return NULL);
- QTC_ASSERT(doc->translationUnit(), return NULL);
- QTC_ASSERT(doc->translationUnit()->ast(), return NULL);
+ QTC_ASSERT(doc, return nullptr);
+ QTC_ASSERT(doc->translationUnit(), return nullptr);
+ QTC_ASSERT(doc->translationUnit()->ast(), return nullptr);
return new CheckSymbols(doc, context, macroUses);
}
@@ -315,7 +315,7 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
, _lineOfLastUsage(0), _macroUses(macroUses)
{
unsigned line = 0;
- getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, 0);
+ getTokenEndPosition(translationUnit()->ast()->lastToken(), &line, nullptr);
_chunkSize = qMax(50U, line / 200);
_usages.reserve(_chunkSize);
@@ -326,8 +326,7 @@ CheckSymbols::CheckSymbols(Document::Ptr doc, const LookupContext &context, cons
typeOfExpression.setExpandTemplates(true);
}
-CheckSymbols::~CheckSymbols()
-{ }
+CheckSymbols::~CheckSymbols() = default;
void CheckSymbols::run()
{
@@ -385,7 +384,7 @@ FunctionDefinitionAST *CheckSymbols::enclosingFunctionDefinition(bool skipTopOfS
return funDef;
}
- return 0;
+ return nullptr;
}
TemplateDeclarationAST *CheckSymbols::enclosingTemplateDeclaration() const
@@ -397,7 +396,7 @@ TemplateDeclarationAST *CheckSymbols::enclosingTemplateDeclaration() const
return funDef;
}
- return 0;
+ return nullptr;
}
Scope *CheckSymbols::enclosingScope() const
@@ -508,7 +507,7 @@ bool CheckSymbols::visit(DotDesignatorAST *ast)
bool CheckSymbols::visit(SimpleDeclarationAST *ast)
{
- NameAST *declrIdNameAST = 0;
+ NameAST *declrIdNameAST = nullptr;
if (ast->declarator_list && !ast->declarator_list->next) {
if (ast->symbols && !ast->symbols->next && !ast->symbols->value->isGenerated()) {
Symbol *decl = ast->symbols->value;
@@ -606,7 +605,7 @@ bool CheckSymbols::visit(ObjCClassForwardDeclarationAST *ast)
{
accept(ast->attribute_list);
accept(ast->identifier_list);
- for (NameListAST *i = ast->identifier_list ; i != 0; i = i->next)
+ for (NameListAST *i = ast->identifier_list; i; i = i->next)
addUse(i->value, SemanticHighlighter::TypeUse);
return false;
}
@@ -680,7 +679,7 @@ bool CheckSymbols::visit(CallAST *ast)
} else if (IdExpressionAST *idExpr = ast->base_expression->asIdExpression()) {
if (const Name *name = idExpr->name->name) {
if (maybeFunction(name)) {
- expr = 0;
+ expr = nullptr;
NameAST *exprName = idExpr->name;
if (QualifiedNameAST *q = exprName->asQualifiedName()) {
@@ -723,8 +722,8 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
if (highlightCtorDtorAsType) {
accept(ast->new_type_id);
} else {
- ClassOrNamespace *binding = 0;
- NameAST *nameAST = 0;
+ ClassOrNamespace *binding = nullptr;
+ NameAST *nameAST = nullptr;
if (ast->new_type_id) {
for (SpecifierListAST *it = ast->new_type_id->type_specifier_list; it; it = it->next) {
if (NamedTypeSpecifierAST *spec = it->value->asNamedTypeSpecifier()) {
@@ -746,7 +745,7 @@ bool CheckSymbols::visit(NewExpressionAST *ast)
if (binding && nameAST) {
int arguments = 0;
if (ast->new_initializer) {
- ExpressionListAST *list = 0;
+ ExpressionListAST *list = nullptr;
if (ExpressionListParenAST *exprListParen = ast->new_initializer->asExpressionListParen())
list = exprListParen->expression_list;
else if (BracedInitializerAST *braceInit = ast->new_initializer->asBracedInitializer())
@@ -853,7 +852,7 @@ void CheckSymbols::checkName(NameAST *ast, Scope *scope)
if (!scope)
scope = enclosingScope();
- if (ast->asDestructorName() != 0) {
+ if (ast->asDestructorName() != nullptr) {
Class *klass = scope->asClass();
if (!klass && scope->asFunction())
klass = scope->asFunction()->enclosingScope()->asClass();
@@ -915,7 +914,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
ClassOrNamespace *binding = checkNestedName(ast);
if (binding && ast->unqualified_name) {
- if (ast->unqualified_name->asDestructorName() != 0) {
+ if (ast->unqualified_name->asDestructorName() != nullptr) {
if (hasVirtualDestructor(binding)) {
addUse(ast->unqualified_name, SemanticHighlighter::VirtualFunctionDeclarationUse);
} else {
@@ -943,7 +942,7 @@ bool CheckSymbols::visit(QualifiedNameAST *ast)
ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
{
- ClassOrNamespace *binding = 0;
+ ClassOrNamespace *binding = nullptr;
if (ast->name) {
if (NestedNameSpecifierListAST *it = ast->nested_name_specifier_list) {
@@ -969,7 +968,7 @@ ClassOrNamespace *CheckSymbols::checkNestedName(QualifiedNameAST *ast)
if (TemplateIdAST *template_id = class_or_namespace_name->asTemplateId()) {
if (template_id->template_token) {
addUse(template_id, SemanticHighlighter::TypeUse);
- binding = 0; // there's no way we can find a binding.
+ binding = nullptr; // there's no way we can find a binding.
}
accept(template_id->template_argument_list);
@@ -1026,7 +1025,7 @@ bool CheckSymbols::visit(MemInitializerAST *ast)
// It's a constructor, count the number of arguments
unsigned arguments = 0;
if (ast->expression) {
- ExpressionListAST *expr_list = 0;
+ ExpressionListAST *expr_list = nullptr;
if (ExpressionListParenAST *parenExprList = ast->expression->asExpressionListParen())
expr_list = parenExprList->expression_list;
else if (BracedInitializerAST *bracedInitList = ast->expression->asBracedInitializer())
@@ -1165,7 +1164,7 @@ void CheckSymbols::addUse(NameAST *ast, Kind kind)
if (!ast)
return; // nothing to do
- else if (ast->asOperatorFunctionId() != 0 || ast->asConversionFunctionId() != 0)
+ else if (ast->asOperatorFunctionId() != nullptr || ast->asConversionFunctionId() != nullptr)
return; // nothing to do
unsigned startToken = ast->firstToken();
@@ -1262,14 +1261,14 @@ bool CheckSymbols::maybeAddTypeOrStatic(const QList<LookupItem> &candidates, Nam
else if (c->isTypedef() || c->isNamespace() ||
c->isStatic() || //consider also static variable
c->isClass() || c->isEnum() || isTemplateClass(c) ||
- c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != 0) {
+ c->isForwardClassDeclaration() || c->isTypenameArgument() || c->enclosingEnum() != nullptr) {
unsigned line, column;
getTokenStartPosition(startToken, &line, &column);
const unsigned length = tok.utf16chars();
Kind kind = SemanticHighlighter::TypeUse;
- if (c->enclosingEnum() != 0)
+ if (c->enclosingEnum() != nullptr)
kind = SemanticHighlighter::EnumerationUse;
else if (c->isStatic())
// treat static variable as a field(highlighting)
@@ -1428,7 +1427,7 @@ NameAST *CheckSymbols::declaratorId(DeclaratorAST *ast) const
return declId->name;
}
- return 0;
+ return nullptr;
}
bool CheckSymbols::maybeType(const Name *name) const
diff --git a/src/plugins/cpptools/cppchecksymbols.h b/src/plugins/cpptools/cppchecksymbols.h
index a32886cef5..9a686c2995 100644
--- a/src/plugins/cpptools/cppchecksymbols.h
+++ b/src/plugins/cpptools/cppchecksymbols.h
@@ -47,12 +47,12 @@ class CPPTOOLS_EXPORT CheckSymbols:
public:
~CheckSymbols() override;
- typedef TextEditor::HighlightingResult Result;
- typedef SemanticHighlighter::Kind Kind;
+ using Result = TextEditor::HighlightingResult;
+ using Kind = SemanticHighlighter::Kind;
void run() override;
- typedef QFuture<Result> Future;
+ using Future = QFuture<Result>;
Future start()
{
@@ -88,7 +88,7 @@ public:
signals:
void codeWarningsUpdated(CPlusPlus::Document::Ptr document,
- const QList<CPlusPlus::Document::DiagnosticMessage> selections);
+ const QList<CPlusPlus::Document::DiagnosticMessage> &selections);
protected:
using ASTVisitor::visit;
diff --git a/src/plugins/cpptools/cppclassesfilter.cpp b/src/plugins/cpptools/cppclassesfilter.cpp
index f4f29a3522..1306a155a4 100644
--- a/src/plugins/cpptools/cppclassesfilter.cpp
+++ b/src/plugins/cpptools/cppclassesfilter.cpp
@@ -39,9 +39,7 @@ CppClassesFilter::CppClassesFilter(CppLocatorData *locatorData)
setIncludedByDefault(false);
}
-CppClassesFilter::~CppClassesFilter()
-{
-}
+CppClassesFilter::~CppClassesFilter() = default;
Core::LocatorFilterEntry CppClassesFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
diff --git a/src/plugins/cpptools/cppclassesfilter.h b/src/plugins/cpptools/cppclassesfilter.h
index 0c77493e5a..1b68ac7e4b 100644
--- a/src/plugins/cpptools/cppclassesfilter.h
+++ b/src/plugins/cpptools/cppclassesfilter.h
@@ -38,7 +38,7 @@ class CPPTOOLS_EXPORT CppClassesFilter : public Internal::CppLocatorFilter
Q_OBJECT
public:
- CppClassesFilter(CppLocatorData *locatorData);
+ explicit CppClassesFilter(CppLocatorData *locatorData);
~CppClassesFilter() override;
protected:
diff --git a/src/plugins/cpptools/cppcodeformatter.cpp b/src/plugins/cpptools/cppcodeformatter.cpp
index 99e28529c1..03a7da9180 100644
--- a/src/plugins/cpptools/cppcodeformatter.cpp
+++ b/src/plugins/cpptools/cppcodeformatter.cpp
@@ -40,9 +40,7 @@ using namespace CppTools;
using namespace TextEditor;
using namespace CppTools::Internal;
-CodeFormatter::~CodeFormatter()
-{
-}
+CodeFormatter::~CodeFormatter() = default;
void CodeFormatter::setTabSize(int tabSize)
{
@@ -1098,9 +1096,7 @@ namespace Internal {
}
}
-QtStyleCodeFormatter::QtStyleCodeFormatter()
-{
-}
+QtStyleCodeFormatter::QtStyleCodeFormatter() = default;
QtStyleCodeFormatter::QtStyleCodeFormatter(const TabSettings &tabSettings,
const CppCodeStyleSettings &settings)
@@ -1124,7 +1120,7 @@ void QtStyleCodeFormatter::setCodeStyleSettings(const CppCodeStyleSettings &sett
void QtStyleCodeFormatter::saveBlockData(QTextBlock *block, const BlockData &data) const
{
TextBlockUserData *userData = TextDocumentLayout::userData(*block);
- CppCodeFormatterData *cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
+ auto cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
if (!cppData) {
cppData = new CppCodeFormatterData;
userData->setCodeFormatterData(cppData);
@@ -1137,7 +1133,7 @@ bool QtStyleCodeFormatter::loadBlockData(const QTextBlock &block, BlockData *dat
TextBlockUserData *userData = TextDocumentLayout::testUserData(block);
if (!userData)
return false;
- CppCodeFormatterData *cppData = static_cast<CppCodeFormatterData *>(userData->codeFormatterData());
+ auto cppData = static_cast<const CppCodeFormatterData *>(userData->codeFormatterData());
if (!cppData)
return false;
diff --git a/src/plugins/cpptools/cppcodeformatter.h b/src/plugins/cpptools/cppcodeformatter.h
index 02fb12833f..b55724dc65 100644
--- a/src/plugins/cpptools/cppcodeformatter.h
+++ b/src/plugins/cpptools/cppcodeformatter.h
@@ -175,7 +175,7 @@ public: // must be public to make Q_GADGET introspection work
string_open
};
- Q_ENUMS(StateType)
+ Q_ENUM(StateType)
protected:
class State {
diff --git a/src/plugins/cpptools/cppcodegen_test.cpp b/src/plugins/cpptools/cppcodegen_test.cpp
index 5ec22942a5..01d8973904 100644
--- a/src/plugins/cpptools/cppcodegen_test.cpp
+++ b/src/plugins/cpptools/cppcodegen_test.cpp
@@ -44,7 +44,7 @@ using namespace CppTools::Internal;
namespace {
-Document::Ptr createDocument(const QString filePath, const QByteArray text,
+Document::Ptr createDocument(const QString &filePath, const QByteArray &text,
unsigned expectedGlobalSymbolCount)
{
Document::Ptr document = Document::create(filePath);
diff --git a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
index 89d447208f..b06d26315e 100644
--- a/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
+++ b/src/plugins/cpptools/cppcodemodelinspectordumper.cpp
@@ -665,8 +665,8 @@ void Dumper::dumpDocuments(const QList<CPlusPlus::Document::Ptr> &documents, boo
if (!diagnosticMessages.isEmpty()) {
m_out << i3 << "Diagnostic Messages:{{{4\n";
foreach (const CPlusPlus::Document::DiagnosticMessage &msg, diagnosticMessages) {
- const CPlusPlus::Document::DiagnosticMessage::Level level
- = static_cast<CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
+ auto level =
+ static_cast<const CPlusPlus::Document::DiagnosticMessage::Level>(msg.level());
m_out << i4 << "at " << msg.line() << ":" << msg.column() << ", " << Utils::toString(level)
<< ": " << msg.text() << "\n";
}
diff --git a/src/plugins/cpptools/cppcodemodelsettingspage.h b/src/plugins/cpptools/cppcodemodelsettingspage.h
index 54547bc026..5ccb5fb37f 100644
--- a/src/plugins/cpptools/cppcodemodelsettingspage.h
+++ b/src/plugins/cpptools/cppcodemodelsettingspage.h
@@ -46,7 +46,7 @@ class CppCodeModelSettingsWidget: public QWidget
Q_OBJECT
public:
- explicit CppCodeModelSettingsWidget(QWidget *parent = 0);
+ explicit CppCodeModelSettingsWidget(QWidget *parent = nullptr);
~CppCodeModelSettingsWidget() override;
void setSettings(const QSharedPointer<CppCodeModelSettings> &s);
@@ -68,11 +68,11 @@ class CppCodeModelSettingsPage: public Core::IOptionsPage
{
public:
explicit CppCodeModelSettingsPage(QSharedPointer<CppCodeModelSettings> &settings,
- QObject *parent = 0);
+ QObject *parent = nullptr);
- QWidget *widget();
- void apply();
- void finish();
+ QWidget *widget() override;
+ void apply() override;
+ void finish() override;
private:
const QSharedPointer<CppCodeModelSettings> m_settings;
diff --git a/src/plugins/cpptools/cppcodestylepreferencesfactory.cpp b/src/plugins/cpptools/cppcodestylepreferencesfactory.cpp
index 6eb401f3ec..00da046edc 100644
--- a/src/plugins/cpptools/cppcodestylepreferencesfactory.cpp
+++ b/src/plugins/cpptools/cppcodestylepreferencesfactory.cpp
@@ -82,9 +82,7 @@ static const char *defaultPreviewText =
;
-CppCodeStylePreferencesFactory::CppCodeStylePreferencesFactory()
-{
-}
+CppCodeStylePreferencesFactory::CppCodeStylePreferencesFactory() = default;
Core::Id CppCodeStylePreferencesFactory::languageId()
{
@@ -104,10 +102,10 @@ TextEditor::ICodeStylePreferences *CppCodeStylePreferencesFactory::createCodeSty
QWidget *CppCodeStylePreferencesFactory::createEditor(TextEditor::ICodeStylePreferences *preferences,
QWidget *parent) const
{
- CppCodeStylePreferences *cppPreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
+ auto cppPreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
if (!cppPreferences)
- return 0;
- Internal::CppCodeStylePreferencesWidget *widget = new Internal::CppCodeStylePreferencesWidget(parent);
+ return nullptr;
+ auto widget = new Internal::CppCodeStylePreferencesWidget(parent);
widget->layout()->setMargin(0);
widget->setCodeStyle(cppPreferences);
return widget;
diff --git a/src/plugins/cpptools/cppcodestylepreferencesfactory.h b/src/plugins/cpptools/cppcodestylepreferencesfactory.h
index 13d602a08d..233022a31a 100644
--- a/src/plugins/cpptools/cppcodestylepreferencesfactory.h
+++ b/src/plugins/cpptools/cppcodestylepreferencesfactory.h
@@ -36,14 +36,14 @@ class CPPTOOLS_EXPORT CppCodeStylePreferencesFactory : public TextEditor::ICodeS
public:
CppCodeStylePreferencesFactory();
- Core::Id languageId();
- QString displayName();
- TextEditor::ICodeStylePreferences *createCodeStyle() const;
+ Core::Id languageId() override;
+ QString displayName() override;
+ TextEditor::ICodeStylePreferences *createCodeStyle() const override;
QWidget *createEditor(TextEditor::ICodeStylePreferences *settings,
- QWidget *parent) const;
- TextEditor::Indenter *createIndenter() const;
- QString snippetProviderGroupId() const;
- QString previewText() const;
+ QWidget *parent) const override;
+ TextEditor::Indenter *createIndenter() const override;
+ QString snippetProviderGroupId() const override;
+ QString previewText() const override;
};
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppcodestylesettings.cpp b/src/plugins/cpptools/cppcodestylesettings.cpp
index 565c969689..745ea3ab62 100644
--- a/src/plugins/cpptools/cppcodestylesettings.cpp
+++ b/src/plugins/cpptools/cppcodestylesettings.cpp
@@ -214,8 +214,8 @@ Utils::optional<CppCodeStyleSettings> CppCodeStyleSettings::currentProjectCodeSt
= editorConfiguration->codeStyle(Constants::CPP_SETTINGS_ID);
QTC_ASSERT(codeStylePreferences, return OptSettings());
- CppCodeStylePreferences *cppCodeStylePreferences
- = dynamic_cast<CppCodeStylePreferences *>(codeStylePreferences);
+ auto cppCodeStylePreferences =
+ dynamic_cast<const CppCodeStylePreferences *>(codeStylePreferences);
if (!cppCodeStylePreferences)
return OptSettings();
@@ -258,7 +258,7 @@ TextEditor::TabSettings CppCodeStyleSettings::currentGlobalTabSettings()
static void configureOverviewWithCodeStyleSettings(CPlusPlus::Overview &overview,
const CppCodeStyleSettings &settings)
{
- overview.starBindFlags = CPlusPlus::Overview::StarBindFlags(0);
+ overview.starBindFlags = CPlusPlus::Overview::StarBindFlags(nullptr);
if (settings.bindStarToIdentifier)
overview.starBindFlags |= CPlusPlus::Overview::BindToIdentifier;
if (settings.bindStarToTypeName)
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.cpp b/src/plugins/cpptools/cppcodestylesettingspage.cpp
index 26a0edaa6f..c80537db9b 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.cpp
+++ b/src/plugins/cpptools/cppcodestylesettingspage.cpp
@@ -224,7 +224,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
{
// Preprocess source
Environment env;
- Preprocessor preprocess(0, &env);
+ Preprocessor preprocess(nullptr, &env);
const QByteArray preprocessedSource
= preprocess.run(QLatin1String("<no-file>"), textDocument->toPlainText());
@@ -238,7 +238,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
// Run the formatter
Overview overview;
overview.showReturnTypes = true;
- overview.starBindFlags = Overview::StarBindFlags(0);
+ overview.starBindFlags = Overview::StarBindFlags(nullptr);
if (settings.bindStarToIdentifier)
overview.starBindFlags |= Overview::BindToIdentifier;
@@ -261,9 +261,7 @@ static void applyRefactorings(QTextDocument *textDocument, TextEditorWidget *edi
CppCodeStylePreferencesWidget::CppCodeStylePreferencesWidget(QWidget *parent)
: QWidget(parent),
- m_preferences(0),
- m_ui(new Ui::CppCodeStyleSettingsPage),
- m_blockUpdates(false)
+ m_ui(new Ui::CppCodeStyleSettingsPage)
{
m_ui->setupUi(this);
m_ui->categoryTab->setProperty("_q_custom_style_disabled", true);
@@ -442,7 +440,7 @@ void CppCodeStylePreferencesWidget::slotCodeStyleSettingsChanged()
return;
if (m_preferences) {
- CppCodeStylePreferences *current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
+ auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
if (current)
current->setCodeStyleSettings(cppCodeStyleSettings());
}
@@ -456,7 +454,7 @@ void CppCodeStylePreferencesWidget::slotTabSettingsChanged(const TabSettings &se
return;
if (m_preferences) {
- CppCodeStylePreferences *current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
+ auto current = qobject_cast<CppCodeStylePreferences *>(m_preferences->currentPreferences());
if (current)
current->setTabSettings(settings);
}
@@ -512,9 +510,8 @@ void CppCodeStylePreferencesWidget::setVisualizeWhitespace(bool on)
// ------------------ CppCodeStyleSettingsPage
-CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent) :
- Core::IOptionsPage(parent),
- m_pageCppCodeStylePreferences(0)
+CppCodeStyleSettingsPage::CppCodeStyleSettingsPage(QWidget *parent)
+ : Core::IOptionsPage(parent)
{
setId(Constants::CPP_CODE_STYLE_SETTINGS_ID);
setDisplayName(QCoreApplication::translate("CppTools", Constants::CPP_CODE_STYLE_SETTINGS_NAME));
diff --git a/src/plugins/cpptools/cppcodestylesettingspage.h b/src/plugins/cpptools/cppcodestylesettingspage.h
index 9f29d783ba..b8f82fc302 100644
--- a/src/plugins/cpptools/cppcodestylesettingspage.h
+++ b/src/plugins/cpptools/cppcodestylesettingspage.h
@@ -54,8 +54,8 @@ class CppCodeStylePreferencesWidget : public QWidget
{
Q_OBJECT
public:
- explicit CppCodeStylePreferencesWidget(QWidget *parent = 0);
- virtual ~CppCodeStylePreferencesWidget();
+ explicit CppCodeStylePreferencesWidget(QWidget *parent = nullptr);
+ ~CppCodeStylePreferencesWidget() override;
void setCodeStyle(CppTools::CppCodeStylePreferences *codeStylePreferences);
@@ -71,10 +71,10 @@ private:
CppCodeStyleSettings cppCodeStyleSettings() const;
- CppCodeStylePreferences *m_preferences;
+ CppCodeStylePreferences *m_preferences = nullptr;
Ui::CppCodeStyleSettingsPage *m_ui;
QList<TextEditor::SnippetEditorWidget *> m_previews;
- bool m_blockUpdates;
+ bool m_blockUpdates = false;
};
@@ -83,14 +83,14 @@ class CppCodeStyleSettingsPage : public Core::IOptionsPage
Q_OBJECT
public:
- explicit CppCodeStyleSettingsPage(QWidget *parent = 0);
+ explicit CppCodeStyleSettingsPage(QWidget *parent = nullptr);
- QWidget *widget();
- void apply();
- void finish();
+ QWidget *widget() override;
+ void apply() override;
+ void finish() override;
private:
- CppCodeStylePreferences *m_pageCppCodeStylePreferences;
+ CppCodeStylePreferences *m_pageCppCodeStylePreferences = nullptr;
QPointer<QWidget> m_widget;
};
diff --git a/src/plugins/cpptools/cppcompletion_test.cpp b/src/plugins/cpptools/cppcompletion_test.cpp
index 41a2865011..b8dd817835 100644
--- a/src/plugins/cpptools/cppcompletion_test.cpp
+++ b/src/plugins/cpptools/cppcompletion_test.cpp
@@ -54,14 +54,13 @@ using namespace Core;
namespace {
-typedef QByteArray _;
+using _ = QByteArray;
class CompletionTestCase : public Tests::TestCase
{
public:
CompletionTestCase(const QByteArray &sourceText, const QByteArray &textToInsert = QByteArray(),
bool isObjC = false)
- : m_position(-1), m_editorWidget(0), m_textDocument(0), m_editor(0)
{
QVERIFY(succeededSoFar());
m_succeededSoFar = false;
@@ -100,7 +99,7 @@ public:
m_succeededSoFar = true;
}
- QStringList getCompletions(bool *replaceAccessOperator = 0) const
+ QStringList getCompletions(bool *replaceAccessOperator = nullptr) const
{
QStringList completions;
LanguageFeatures languageFeatures = LanguageFeatures::defaultFeatures();
@@ -153,12 +152,12 @@ public:
private:
QByteArray m_source;
- int m_position;
+ int m_position = -1;
Snapshot m_snapshot;
QScopedPointer<Tests::TemporaryDir> m_temporaryDir;
- TextEditorWidget *m_editorWidget;
- QTextDocument *m_textDocument;
- IEditor *m_editor;
+ TextEditorWidget *m_editorWidget = nullptr;
+ QTextDocument *m_textDocument = nullptr;
+ IEditor *m_editor = nullptr;
};
bool isProbablyGlobalCompletion(const QStringList &list)
diff --git a/src/plugins/cpptools/cppcompletionassist.cpp b/src/plugins/cpptools/cppcompletionassist.cpp
index 87bc2df0b4..ab125a86c7 100644
--- a/src/plugins/cpptools/cppcompletionassist.cpp
+++ b/src/plugins/cpptools/cppcompletionassist.cpp
@@ -70,7 +70,7 @@ namespace Internal {
struct CompleteFunctionDeclaration
{
- explicit CompleteFunctionDeclaration(Function *f = 0)
+ explicit CompleteFunctionDeclaration(Function *f = nullptr)
: function(f)
{}
@@ -83,7 +83,7 @@ struct CompleteFunctionDeclaration
class CppAssistProposalItem final : public AssistProposalItem
{
public:
- ~CppAssistProposalItem() noexcept {}
+ ~CppAssistProposalItem() noexcept override = default;
bool prematurelyApplies(const QChar &c) const override;
void applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const override;
@@ -120,7 +120,7 @@ AssistProposalItemInterface *CppAssistProposalModel::proposalItem(int index) con
{
AssistProposalItemInterface *item = GenericProposalModel::proposalItem(index);
if (!item->isSnippet()) {
- CppAssistProposalItem *cppItem = static_cast<CppAssistProposalItem *>(item);
+ auto cppItem = static_cast<CppAssistProposalItem *>(item);
cppItem->keepCompletionOperator(m_completionOperator);
cppItem->keepTypeOfExpression(m_typeOfExpression);
}
@@ -191,7 +191,7 @@ quint64 CppAssistProposalItem::hash() const
void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterface &manipulator, int basePosition) const
{
- Symbol *symbol = 0;
+ Symbol *symbol = nullptr;
if (data().isValid())
symbol = data().value<Symbol *>();
@@ -347,7 +347,7 @@ void CppAssistProposalItem::applyContextualContent(TextDocumentManipulatorInterf
class CppFunctionHintModel : public IFunctionHintProposalModel
{
public:
- CppFunctionHintModel(QList<Function *> functionSymbols,
+ CppFunctionHintModel(const QList<Function *> &functionSymbols,
const QSharedPointer<TypeOfExpression> &typeOfExp)
: m_functionSymbols(functionSymbols)
, m_currentArg(-1)
@@ -426,7 +426,7 @@ AssistInterface *InternalCompletionAssistProvider::createAssistInterface(const Q
int position,
AssistReason reason) const
{
- QTC_ASSERT(textEditorWidget, return 0);
+ QTC_ASSERT(textEditorWidget, return nullptr);
return new CppCompletionAssistInterface(filePath,
textEditorWidget,
@@ -469,18 +469,16 @@ namespace {
class ConvertToCompletionItem: protected NameVisitor
{
// The completion item.
- AssistProposalItem *_item;
+ AssistProposalItem *_item = nullptr;
// The current symbol.
- Symbol *_symbol;
+ Symbol *_symbol = nullptr;
// The pretty printer.
Overview overview;
public:
ConvertToCompletionItem()
- : _item(0)
- , _symbol(0)
{
overview.showReturnTypes = true;
overview.showArgumentNames = true;
@@ -491,9 +489,9 @@ public:
//using declaration can be qualified
if (!symbol || !symbol->name() || (symbol->name()->isQualifiedNameId()
&& !symbol->asUsingDeclaration()))
- return 0;
+ return nullptr;
- AssistProposalItem *previousItem = switchCompletionItem(0);
+ AssistProposalItem *previousItem = switchCompletionItem(nullptr);
Symbol *previousSymbol = switchSymbol(symbol);
accept(symbol->unqualifiedName());
if (_item)
@@ -524,32 +522,32 @@ protected:
return item;
}
- void visit(const Identifier *name)
+ void visit(const Identifier *name) override
{
_item = newCompletionItem(name);
if (!_symbol->isScope() || _symbol->isFunction())
_item->setDetail(overview.prettyType(_symbol->type(), name));
}
- void visit(const TemplateNameId *name)
+ void visit(const TemplateNameId *name) override
{
_item = newCompletionItem(name);
_item->setText(QString::fromUtf8(name->identifier()->chars(), name->identifier()->size()));
}
- void visit(const DestructorNameId *name)
+ void visit(const DestructorNameId *name) override
{ _item = newCompletionItem(name); }
- void visit(const OperatorNameId *name)
+ void visit(const OperatorNameId *name) override
{
_item = newCompletionItem(name);
_item->setDetail(overview.prettyType(_symbol->type(), name));
}
- void visit(const ConversionNameId *name)
+ void visit(const ConversionNameId *name) override
{ _item = newCompletionItem(name); }
- void visit(const QualifiedNameId *name)
+ void visit(const QualifiedNameId *name) override
{ _item = newCompletionItem(name->name()); }
};
@@ -561,7 +559,7 @@ Class *asClassOrTemplateClassType(FullySpecifiedType ty)
if (Symbol *decl = templ->declaration())
return decl->asClass();
}
- return 0;
+ return nullptr;
}
Scope *enclosingNonTemplateScope(Symbol *symbol)
@@ -573,7 +571,7 @@ Scope *enclosingNonTemplateScope(Symbol *symbol)
return scope;
}
}
- return 0;
+ return nullptr;
}
Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
@@ -584,7 +582,7 @@ Function *asFunctionOrTemplateFunctionType(FullySpecifiedType ty)
if (Symbol *decl = templ->declaration())
return decl->asFunction();
}
- return 0;
+ return nullptr;
}
bool isQPrivateSignal(const Symbol *symbol)
@@ -758,7 +756,7 @@ bool canCompleteClassNameAt2ndOr4thConnectArgument(
ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
const LookupContext &context)
{
- const Name *name = 0;
+ const Name *name = nullptr;
if (Symbol *d = lookupItem.declaration()) {
if (Class *k = d->asClass())
@@ -771,29 +769,29 @@ ClassOrNamespace *classOrNamespaceFromLookupItem(const LookupItem &lookupItem,
if (PointerType *pointerType = type->asPointerType())
type = pointerType->elementType().simplified();
else
- return 0; // not a pointer or a reference to a pointer.
+ return nullptr; // not a pointer or a reference to a pointer.
NamedType *namedType = type->asNamedType();
if (!namedType) // not a class name.
- return 0;
+ return nullptr;
name = namedType->name();
}
- return name ? context.lookupType(name, lookupItem.scope()) : 0;
+ return name ? context.lookupType(name, lookupItem.scope()) : nullptr;
}
Class *classFromLookupItem(const LookupItem &lookupItem, const LookupContext &context)
{
ClassOrNamespace *b = classOrNamespaceFromLookupItem(lookupItem, context);
if (!b)
- return 0;
+ return nullptr;
foreach (Symbol *s, b->symbols()) {
if (Class *klass = s->asClass())
return klass;
}
- return 0;
+ return nullptr;
}
const Name *minimalName(Symbol *symbol, Scope *targetScope, const LookupContext &context)
@@ -814,15 +812,14 @@ InternalCppCompletionAssistProcessor::InternalCppCompletionAssistProcessor()
{
}
-InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor()
-{}
+InternalCppCompletionAssistProcessor::~InternalCppCompletionAssistProcessor() = default;
IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInterface *interface)
{
m_interface.reset(static_cast<const CppCompletionAssistInterface *>(interface));
if (interface->reason() != ExplicitlyInvoked && !accepts())
- return 0;
+ return nullptr;
int index = startCompletionHelper();
if (index != -1) {
@@ -832,7 +829,7 @@ IAssistProposal * InternalCppCompletionAssistProcessor::perform(const AssistInte
return createContentProposal();
}
- return 0;
+ return nullptr;
}
bool InternalCppCompletionAssistProcessor::accepts() const
@@ -901,13 +898,13 @@ IAssistProposal *InternalCppCompletionAssistProcessor::createContentProposal()
QSet<QString> processed;
auto it = m_completions.begin();
while (it != m_completions.end()) {
- CppAssistProposalItem *item = static_cast<CppAssistProposalItem *>(*it);
+ auto item = static_cast<CppAssistProposalItem *>(*it);
if (!processed.contains(item->text()) || item->isSnippet()) {
++it;
if (!item->isSnippet()) {
processed.insert(item->text());
if (!item->isOverloaded()) {
- if (Symbol *symbol = qvariant_cast<Symbol *>(item->data())) {
+ if (auto symbol = qvariant_cast<Symbol *>(item->data())) {
if (Function *funTy = symbol->type()->asFunctionType()) {
if (funTy->hasArguments())
item->markAsOverloaded();
@@ -1333,7 +1330,7 @@ int InternalCppCompletionAssistProcessor::startCompletionInternal(const QString
m_model->m_typeOfExpression->init(thisDocument, m_interface->snapshot());
Scope *scope = thisDocument->scopeAt(line, positionInBlock);
- QTC_ASSERT(scope != 0, return -1);
+ QTC_ASSERT(scope, return -1);
if (expression.isEmpty()) {
if (m_model->m_completionOperator == T_EOF_SYMBOL || m_model->m_completionOperator == T_COLON_COLON) {
@@ -1461,7 +1458,7 @@ bool InternalCppCompletionAssistProcessor::globalCompletion(Scope *currentScope)
}
QList<ClassOrNamespace *> usingBindings;
- ClassOrNamespace *currentBinding = 0;
+ ClassOrNamespace *currentBinding = nullptr;
for (Scope *scope = currentScope; scope; scope = scope->enclosingScope()) {
if (Block *block = scope->asBlock()) {
@@ -1543,7 +1540,7 @@ bool InternalCppCompletionAssistProcessor::completeMember(const QList<LookupItem
ResolveExpression resolveExpression(context);
- bool *replaceDotForArrow = 0;
+ bool *replaceDotForArrow = nullptr;
if (!m_interface->languageFeatures().objCEnabled)
replaceDotForArrow = &m_model->m_replaceDotForArrow;
diff --git a/src/plugins/cpptools/cppcompletionassist.h b/src/plugins/cpptools/cppcompletionassist.h
index 7bb7776940..e22ea38607 100644
--- a/src/plugins/cpptools/cppcompletionassist.h
+++ b/src/plugins/cpptools/cppcompletionassist.h
@@ -62,8 +62,6 @@ class CppAssistProposalModel : public TextEditor::GenericProposalModel
public:
CppAssistProposalModel()
: TextEditor::GenericProposalModel()
- , m_completionOperator(CPlusPlus::T_EOF_SYMBOL)
- , m_replaceDotForArrow(false)
, m_typeOfExpression(new CPlusPlus::TypeOfExpression)
{
m_typeOfExpression->setExpandTemplates(true);
@@ -72,8 +70,8 @@ public:
bool isSortable(const QString &prefix) const override;
TextEditor::AssistProposalItemInterface *proposalItem(int index) const override;
- unsigned m_completionOperator;
- bool m_replaceDotForArrow;
+ unsigned m_completionOperator = CPlusPlus::T_EOF_SYMBOL;
+ bool m_replaceDotForArrow = false;
QSharedPointer<CPlusPlus::TypeOfExpression> m_typeOfExpression;
};
@@ -98,7 +96,7 @@ class InternalCppCompletionAssistProcessor : public CppCompletionAssistProcessor
{
public:
InternalCppCompletionAssistProcessor();
- ~InternalCppCompletionAssistProcessor();
+ ~InternalCppCompletionAssistProcessor() override;
TextEditor::IAssistProposal *perform(const TextEditor::AssistInterface *interface) override;
diff --git a/src/plugins/cpptools/cppcompletionassistprocessor.cpp b/src/plugins/cpptools/cppcompletionassistprocessor.cpp
index 527fd586ab..cf945301ce 100644
--- a/src/plugins/cpptools/cppcompletionassistprocessor.cpp
+++ b/src/plugins/cpptools/cppcompletionassistprocessor.cpp
@@ -41,8 +41,7 @@ using namespace CPlusPlus;
namespace CppTools {
CppCompletionAssistProcessor::CppCompletionAssistProcessor(int snippetItemOrder)
- : m_positionForProposal(-1)
- , m_preprocessorCompletions(
+ : m_preprocessorCompletions(
QStringList({"define", "error", "include", "line", "pragma", "pragma once",
"pragma omp atomic", "pragma omp parallel", "pragma omp for",
"pragma omp ordered", "pragma omp parallel for", "pragma omp section",
@@ -50,7 +49,6 @@ CppCompletionAssistProcessor::CppCompletionAssistProcessor(int snippetItemOrder)
"pragma omp master", "pragma omp critical", "pragma omp barrier",
"pragma omp flush", "pragma omp threadprivate", "undef", "if", "ifdef",
"ifndef", "elif", "else", "endif"}))
- , m_hintProposal(0)
, m_snippetCollector(QLatin1String(CppEditor::Constants::CPP_SNIPPETS_GROUP_ID),
QIcon(QLatin1String(":/texteditor/images/snippet.png")),
snippetItemOrder)
diff --git a/src/plugins/cpptools/cppcompletionassistprocessor.h b/src/plugins/cpptools/cppcompletionassistprocessor.h
index 535ce62a5e..4d63bb5dec 100644
--- a/src/plugins/cpptools/cppcompletionassistprocessor.h
+++ b/src/plugins/cpptools/cppcompletionassistprocessor.h
@@ -45,7 +45,7 @@ namespace CppTools {
class CPPTOOLS_EXPORT CppCompletionAssistProcessor : public TextEditor::IAssistProcessor
{
public:
- CppCompletionAssistProcessor(int snippetItemOrder = 0);
+ explicit CppCompletionAssistProcessor(int snippetItemOrder = 0);
protected:
void addSnippets();
@@ -60,10 +60,10 @@ protected:
DotAtIncludeCompletionHandler dotAtIncludeCompletionHandler
= DotAtIncludeCompletionHandler());
- int m_positionForProposal;
+ int m_positionForProposal = -1;
QList<TextEditor::AssistProposalItemInterface *> m_completions;
QStringList m_preprocessorCompletions;
- TextEditor::IAssistProposal *m_hintProposal;
+ TextEditor::IAssistProposal *m_hintProposal = nullptr;
private:
TextEditor::SnippetAssistCollector m_snippetCollector;
diff --git a/src/plugins/cpptools/cppcompletionassistprovider.cpp b/src/plugins/cpptools/cppcompletionassistprovider.cpp
index b5f4ca51ab..a06c4c7b42 100644
--- a/src/plugins/cpptools/cppcompletionassistprovider.cpp
+++ b/src/plugins/cpptools/cppcompletionassistprovider.cpp
@@ -51,7 +51,7 @@ bool CppCompletionAssistProvider::isActivationCharSequence(const QString &sequen
const QChar &ch = sequence.at(2);
const QChar &ch2 = sequence.at(1);
const QChar &ch3 = sequence.at(0);
- if (activationSequenceChar(ch, ch2, ch3, 0, true, false) != 0)
+ if (activationSequenceChar(ch, ch2, ch3, nullptr, true, false) != 0)
return true;
return false;
}
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
index c1a0b9f5e4..be1163d168 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.cpp
@@ -70,7 +70,7 @@ QList<Core::LocatorFilterEntry> CppCurrentDocumentFilter::matchesFor(
return goodEntries;
const QList<IndexItem::Ptr> items = itemsOfCurrentDocument();
- for (IndexItem::Ptr info : items) {
+ for (const IndexItem::Ptr &info : items) {
if (future.isCanceled())
break;
diff --git a/src/plugins/cpptools/cppcurrentdocumentfilter.h b/src/plugins/cpptools/cppcurrentdocumentfilter.h
index 147bb66309..51dd801d84 100644
--- a/src/plugins/cpptools/cppcurrentdocumentfilter.h
+++ b/src/plugins/cpptools/cppcurrentdocumentfilter.h
@@ -43,7 +43,7 @@ class CppCurrentDocumentFilter : public Core::ILocatorFilter
public:
explicit CppCurrentDocumentFilter(CppModelManager *manager);
- ~CppCurrentDocumentFilter() {}
+ ~CppCurrentDocumentFilter() override = default;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
const QString &entry) override;
diff --git a/src/plugins/cpptools/cppelementevaluator.cpp b/src/plugins/cpptools/cppelementevaluator.cpp
index afd8944bde..95932c0e2c 100644
--- a/src/plugins/cpptools/cppelementevaluator.cpp
+++ b/src/plugins/cpptools/cppelementevaluator.cpp
@@ -57,11 +57,9 @@ static QStringList stripName(const QString &name)
return all;
}
-CppElement::CppElement() : helpCategory(TextEditor::HelpItem::Unknown)
-{}
+CppElement::CppElement() = default;
-CppElement::~CppElement()
-{}
+CppElement::~CppElement() = default;
CppClass *CppElement::toCppClass()
{
@@ -168,7 +166,7 @@ CppClass *CppClass::toCppClass()
void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
{
- typedef QPair<ClassOrNamespace *, CppClass *> Data;
+ using Data = QPair<ClassOrNamespace*, CppClass*>;
if (ClassOrNamespace *clazz = context.lookupType(declaration)) {
QSet<ClassOrNamespace *> visited;
@@ -199,7 +197,7 @@ void CppClass::lookupBases(Symbol *declaration, const LookupContext &context)
void CppClass::lookupDerived(Symbol *declaration, const Snapshot &snapshot)
{
- typedef QPair<CppClass *, CppTools::TypeHierarchy> Data;
+ using Data = QPair<CppClass*, CppTools::TypeHierarchy>;
CppTools::TypeHierarchyBuilder builder(declaration, snapshot);
const CppTools::TypeHierarchy &completeHierarchy = builder.buildDerivedTypeHierarchy();
@@ -268,7 +266,7 @@ public:
{
const FullySpecifiedType &type = declaration->type();
- const Name *typeName = 0;
+ const Name *typeName = nullptr;
if (type->isNamedType()) {
typeName = type->asNamedType()->name();
} else if (type->isPointerType() || type->isReferenceType()) {
@@ -462,7 +460,7 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
}
}
- CppClass *cppClass = new CppClass(declaration);
+ auto cppClass = new CppClass(declaration);
if (m_lookupBaseClasses)
cppClass->lookupBases(declaration, contextToUse);
if (m_lookupDerivedClasses)
@@ -470,7 +468,7 @@ void CppElementEvaluator::handleLookupItemMatch(const Snapshot &snapshot,
m_element = QSharedPointer<CppElement>(cppClass);
} else if (Enum *enumDecl = declaration->asEnum()) {
m_element = QSharedPointer<CppElement>(new CppEnum(enumDecl));
- } else if (EnumeratorDeclaration *enumerator = dynamic_cast<EnumeratorDeclaration *>(declaration)) {
+ } else if (auto enumerator = dynamic_cast<EnumeratorDeclaration *>(declaration)) {
m_element = QSharedPointer<CppElement>(new CppEnumerator(enumerator));
} else if (declaration->isTypedef()) {
m_element = QSharedPointer<CppElement>(new CppTypedef(declaration));
diff --git a/src/plugins/cpptools/cppelementevaluator.h b/src/plugins/cpptools/cppelementevaluator.h
index 0bececefaf..04143738c7 100644
--- a/src/plugins/cpptools/cppelementevaluator.h
+++ b/src/plugins/cpptools/cppelementevaluator.h
@@ -93,7 +93,7 @@ public:
virtual CppClass *toCppClass();
- TextEditor::HelpItem::Category helpCategory;
+ TextEditor::HelpItem::Category helpCategory = TextEditor::HelpItem::Unknown;
QStringList helpIdCandidates;
QString helpMark;
Utils::Link link;
diff --git a/src/plugins/cpptools/cppfileiterationorder.cpp b/src/plugins/cpptools/cppfileiterationorder.cpp
index 738106f3d7..dd040e9976 100644
--- a/src/plugins/cpptools/cppfileiterationorder.cpp
+++ b/src/plugins/cpptools/cppfileiterationorder.cpp
@@ -86,9 +86,7 @@ bool operator<(const FileIterationOrder::Entry &first, const FileIterationOrder:
}
}
-FileIterationOrder::FileIterationOrder()
-{
-}
+FileIterationOrder::FileIterationOrder() = default;
FileIterationOrder::FileIterationOrder(const QString &referenceFilePath,
const QString &referenceProjectPartId)
diff --git a/src/plugins/cpptools/cppfilesettingspage.h b/src/plugins/cpptools/cppfilesettingspage.h
index 4731adc7c9..e5d8faafa8 100644
--- a/src/plugins/cpptools/cppfilesettingspage.h
+++ b/src/plugins/cpptools/cppfilesettingspage.h
@@ -71,8 +71,8 @@ class CppFileSettingsWidget : public QWidget
Q_OBJECT
public:
- explicit CppFileSettingsWidget(QWidget *parent = 0);
- virtual ~CppFileSettingsWidget();
+ explicit CppFileSettingsWidget(QWidget *parent = nullptr);
+ ~CppFileSettingsWidget() override;
CppFileSettings settings() const;
void setSettings(const CppFileSettings &s);
@@ -89,11 +89,11 @@ class CppFileSettingsPage : public Core::IOptionsPage
{
public:
explicit CppFileSettingsPage(QSharedPointer<CppFileSettings> &settings,
- QObject *parent = 0);
+ QObject *parent = nullptr);
- QWidget *widget();
- void apply();
- void finish();
+ QWidget *widget() override;
+ void apply() override;
+ void finish() override;
private:
const QSharedPointer<CppFileSettings> m_settings;
diff --git a/src/plugins/cpptools/cppfindreferences.cpp b/src/plugins/cpptools/cppfindreferences.cpp
index 00f46399ec..867b3d395a 100644
--- a/src/plugins/cpptools/cppfindreferences.cpp
+++ b/src/plugins/cpptools/cppfindreferences.cpp
@@ -218,7 +218,7 @@ public:
}
CPlusPlus::Control *control = doc->control();
- if (control->findIdentifier(symbolId->chars(), symbolId->size()) != 0) {
+ if (control->findIdentifier(symbolId->chars(), symbolId->size()) != nullptr) {
if (doc != symbolDocument)
doc->check();
@@ -239,7 +239,7 @@ class UpdateUI
QFutureInterface<CPlusPlus::Usage> *future;
public:
- UpdateUI(QFutureInterface<CPlusPlus::Usage> *future): future(future) {}
+ explicit UpdateUI(QFutureInterface<CPlusPlus::Usage> *future): future(future) {}
void operator()(QList<CPlusPlus::Usage> &, const QList<CPlusPlus::Usage> &usages)
{
@@ -258,9 +258,7 @@ CppFindReferences::CppFindReferences(CppModelManager *modelManager)
{
}
-CppFindReferences::~CppFindReferences()
-{
-}
+CppFindReferences::~CppFindReferences() = default;
QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
const CPlusPlus::LookupContext &context) const
@@ -276,11 +274,11 @@ QList<int> CppFindReferences::references(CPlusPlus::Symbol *symbol,
static void find_helper(QFutureInterface<CPlusPlus::Usage> &future,
const WorkingCopy workingCopy,
- const CPlusPlus::LookupContext context,
+ const CPlusPlus::LookupContext &context,
CPlusPlus::Symbol *symbol)
{
const CPlusPlus::Identifier *symbolId = symbol->identifier();
- QTC_ASSERT(symbolId != 0, return);
+ QTC_ASSERT(symbolId != nullptr, return);
const CPlusPlus::Snapshot snapshot = context.snapshot();
@@ -465,7 +463,7 @@ void CppFindReferences::onReplaceButtonClicked(const QString &text,
void CppFindReferences::searchAgain()
{
- SearchResult *search = qobject_cast<SearchResult *>(sender());
+ auto search = qobject_cast<SearchResult *>(sender());
CppFindReferencesParameters parameters = search->userData().value<CppFindReferencesParameters>();
parameters.filesToRename.clear();
CPlusPlus::Snapshot snapshot = CppModelManager::instance()->snapshot();
@@ -483,10 +481,10 @@ namespace {
class UidSymbolFinder : public CPlusPlus::SymbolVisitor
{
public:
- UidSymbolFinder(const QList<QByteArray> &uid) : m_uid(uid), m_index(0), m_result(0) { }
+ explicit UidSymbolFinder(const QList<QByteArray> &uid) : m_uid(uid) { }
CPlusPlus::Symbol *result() const { return m_result; }
- bool preVisit(CPlusPlus::Symbol *symbol)
+ bool preVisit(CPlusPlus::Symbol *symbol) override
{
if (m_result)
return false;
@@ -505,7 +503,7 @@ public:
return true;
}
- void postVisit(CPlusPlus::Symbol *symbol)
+ void postVisit(CPlusPlus::Symbol *symbol) override
{
if (symbol->asScope())
--m_index;
@@ -513,8 +511,8 @@ public:
private:
QList<QByteArray> m_uid;
- int m_index;
- CPlusPlus::Symbol *m_result;
+ int m_index = 0;
+ CPlusPlus::Symbol *m_result = nullptr;
};
}
@@ -522,10 +520,10 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
const CPlusPlus::Snapshot &snapshot,
CPlusPlus::LookupContext *context)
{
- QTC_ASSERT(context, return 0);
+ QTC_ASSERT(context, return nullptr);
QString symbolFile = QLatin1String(parameters.symbolFileName);
if (!snapshot.contains(symbolFile))
- return 0;
+ return nullptr;
CPlusPlus::Document::Ptr newSymbolDocument = snapshot.document(symbolFile);
// document is not parsed and has no bindings yet, do it
@@ -542,7 +540,7 @@ CPlusPlus::Symbol *CppFindReferences::findSymbol(const CppFindReferencesParamete
*context = CPlusPlus::LookupContext(doc, snapshot);
return finder.result();
}
- return 0;
+ return nullptr;
}
static void displayResults(SearchResult *search, QFutureWatcher<CPlusPlus::Usage> *watcher,
@@ -661,7 +659,7 @@ restart_search:
}
static QString matchingLine(unsigned bytesOffsetOfUseStart, const QByteArray &utf8Source,
- unsigned *columnOfUseStart = 0)
+ unsigned *columnOfUseStart = nullptr)
{
int lineBegin = utf8Source.lastIndexOf('\n', bytesOffsetOfUseStart) + 1;
int lineEnd = utf8Source.indexOf('\n', bytesOffsetOfUseStart);
@@ -765,7 +763,7 @@ void CppFindReferences::renameMacroUses(const CPlusPlus::Macro &macro, const QSt
void CppFindReferences::createWatcher(const QFuture<CPlusPlus::Usage> &future, SearchResult *search)
{
- QFutureWatcher<CPlusPlus::Usage> *watcher = new QFutureWatcher<CPlusPlus::Usage>();
+ auto watcher = new QFutureWatcher<CPlusPlus::Usage>();
// auto-delete:
connect(watcher, &QFutureWatcherBase::finished, watcher, [search, watcher]() {
searchFinished(search, watcher);
diff --git a/src/plugins/cpptools/cppfindreferences.h b/src/plugins/cpptools/cppfindreferences.h
index 2dece06883..ce83173444 100644
--- a/src/plugins/cpptools/cppfindreferences.h
+++ b/src/plugins/cpptools/cppfindreferences.h
@@ -63,8 +63,8 @@ class CppFindReferences: public QObject
Q_OBJECT
public:
- CppFindReferences(CppModelManager *modelManager);
- virtual ~CppFindReferences();
+ explicit CppFindReferences(CppModelManager *modelManager);
+ ~CppFindReferences() override;
QList<int> references(CPlusPlus::Symbol *symbol, const CPlusPlus::LookupContext &context) const;
diff --git a/src/plugins/cpptools/cppfollowsymbolundercursor.cpp b/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
index 9633bfb6dd..5ec6b572a2 100644
--- a/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
+++ b/src/plugins/cpptools/cppfollowsymbolundercursor.cpp
@@ -59,6 +59,7 @@ public:
const Document::Ptr &document,
const Snapshot &snapshot,
SymbolFinder *symbolFinder);
+ VirtualFunctionHelper() = delete;
bool canLookupVirtualFunctionOverrides(Function *function);
@@ -67,7 +68,6 @@ public:
{ return m_staticClassOfFunctionCallExpression; }
private:
- VirtualFunctionHelper();
Q_DISABLE_COPY(VirtualFunctionHelper)
Class *staticClassOfFunctionCallExpression_internal() const;
@@ -82,10 +82,10 @@ private:
SymbolFinder *m_finder;
// Determined
- ExpressionAST *m_baseExpressionAST;
- Function *m_function;
- int m_accessTokenKind;
- Class *m_staticClassOfFunctionCallExpression; // Output
+ ExpressionAST *m_baseExpressionAST = nullptr;
+ Function *m_function = nullptr;
+ int m_accessTokenKind = 0;
+ Class *m_staticClassOfFunctionCallExpression = nullptr; // Output
};
VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression,
@@ -99,10 +99,6 @@ VirtualFunctionHelper::VirtualFunctionHelper(TypeOfExpression &typeOfExpression,
, m_snapshot(snapshot)
, m_typeOfExpression(typeOfExpression)
, m_finder(finder)
- , m_baseExpressionAST(0)
- , m_function(0)
- , m_accessTokenKind(0)
- , m_staticClassOfFunctionCallExpression(0)
{
if (ExpressionAST *expressionAST = typeOfExpression.expressionAST()) {
if (CallAST *callAST = expressionAST->asCall()) {
@@ -160,9 +156,9 @@ bool VirtualFunctionHelper::canLookupVirtualFunctionOverrides(Function *function
Class *VirtualFunctionHelper::staticClassOfFunctionCallExpression_internal() const
{
if (!m_finder)
- return 0;
+ return nullptr;
- Class *result = 0;
+ Class *result = nullptr;
if (m_baseExpressionAST->asIdExpression()) {
for (Scope *s = m_scope; s ; s = s->enclosingScope()) {
@@ -323,14 +319,14 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
for (int i = path.size() - 1; i != -1; --i) {
AST *node = path.at(i);
- if (node->asParameterDeclaration() != 0)
+ if (node->asParameterDeclaration() != nullptr)
return result;
}
- AST *declParent = 0;
- DeclaratorAST *decl = 0;
+ AST *declParent = nullptr;
+ DeclaratorAST *decl = nullptr;
for (int i = path.size() - 2; i > 0; --i) {
- if ((decl = path.at(i)->asDeclarator()) != 0) {
+ if ((decl = path.at(i)->asDeclarator()) != nullptr) {
declParent = path.at(i - 1);
break;
}
@@ -343,7 +339,7 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
if (!funcDecl)
return result;
- Symbol *target = 0;
+ Symbol *target = nullptr;
if (FunctionDefinitionAST *funDef = declParent->asFunctionDefinition()) {
QList<Declaration *> candidates =
symbolFinder->findMatchingDeclaration(LookupContext(document, snapshot),
@@ -376,10 +372,10 @@ Link attemptFuncDeclDef(const QTextCursor &cursor, Snapshot snapshot,
Symbol *findDefinition(Symbol *symbol, const Snapshot &snapshot, SymbolFinder *symbolFinder)
{
if (symbol->isFunction())
- return 0; // symbol is a function definition.
+ return nullptr; // symbol is a function definition.
else if (!symbol->type()->isFunctionType())
- return 0; // not a function declaration
+ return nullptr; // not a function declaration
return symbolFinder->findMatchingDefinition(symbol, snapshot);
}
@@ -724,7 +720,7 @@ void FollowSymbolUnderCursor::findLink(
}
if (Symbol *symbol = result.declaration()) {
- Symbol *def = 0;
+ Symbol *def = nullptr;
if (resolveTarget) {
// Consider to show a pop-up displaying overrides for the function
@@ -759,7 +755,7 @@ void FollowSymbolUnderCursor::findLink(
def = findDefinition(symbol, snapshot, symbolFinder);
if (def == lastVisibleSymbol)
- def = 0; // jump to declaration then.
+ def = nullptr; // jump to declaration then.
if (symbol->isForwardClassDeclaration()) {
def = symbolFinder->findMatchingClassDeclaration(symbol, snapshot);
diff --git a/src/plugins/cpptools/cppfunctionsfilter.cpp b/src/plugins/cpptools/cppfunctionsfilter.cpp
index c7c29fdca1..f2897215df 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.cpp
+++ b/src/plugins/cpptools/cppfunctionsfilter.cpp
@@ -41,9 +41,7 @@ CppFunctionsFilter::CppFunctionsFilter(CppLocatorData *locatorData)
setIncludedByDefault(false);
}
-CppFunctionsFilter::~CppFunctionsFilter()
-{
-}
+CppFunctionsFilter::~CppFunctionsFilter() = default;
Core::LocatorFilterEntry CppFunctionsFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
diff --git a/src/plugins/cpptools/cppfunctionsfilter.h b/src/plugins/cpptools/cppfunctionsfilter.h
index f052a7a2d2..04ba9b8612 100644
--- a/src/plugins/cpptools/cppfunctionsfilter.h
+++ b/src/plugins/cpptools/cppfunctionsfilter.h
@@ -37,8 +37,8 @@ class CppFunctionsFilter : public CppLocatorFilter
Q_OBJECT
public:
- CppFunctionsFilter(CppLocatorData *locatorData);
- ~CppFunctionsFilter();
+ explicit CppFunctionsFilter(CppLocatorData *locatorData);
+ ~CppFunctionsFilter() override;
protected:
IndexItem::ItemType matchTypes() const override { return IndexItem::Function; }
diff --git a/src/plugins/cpptools/cppincludesfilter.cpp b/src/plugins/cpptools/cppincludesfilter.cpp
index 679d37b72a..8675a9747a 100644
--- a/src/plugins/cpptools/cppincludesfilter.cpp
+++ b/src/plugins/cpptools/cppincludesfilter.cpp
@@ -48,11 +48,11 @@ class CppIncludesIterator : public BaseFileFilter::Iterator
public:
CppIncludesIterator(CPlusPlus::Snapshot snapshot, const QSet<QString> &seedPaths);
- void toFront();
- bool hasNext() const;
- QString next();
- QString filePath() const;
- QString fileName() const;
+ void toFront() override;
+ bool hasNext() const override;
+ QString next() override;
+ QString filePath() const override;
+ QString fileName() const override;
private:
void fetchMore();
@@ -184,5 +184,5 @@ void CppIncludesFilter::refresh(QFutureInterface<void> &future)
void CppIncludesFilter::markOutdated()
{
m_needsUpdate = true;
- setFileIterator(0); // clean up
+ setFileIterator(nullptr); // clean up
}
diff --git a/src/plugins/cpptools/cppindexingsupport.cpp b/src/plugins/cpptools/cppindexingsupport.cpp
index ea8bee6c7f..cf721301cc 100644
--- a/src/plugins/cpptools/cppindexingsupport.cpp
+++ b/src/plugins/cpptools/cppindexingsupport.cpp
@@ -27,16 +27,13 @@
namespace CppTools {
-CppIndexingSupport::~CppIndexingSupport()
-{
-}
+CppIndexingSupport::~CppIndexingSupport() = default;
SymbolSearcher::SymbolSearcher(QObject *parent)
: QObject(parent)
{
}
-SymbolSearcher::~SymbolSearcher()
-{}
+SymbolSearcher::~SymbolSearcher() = default;
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppindexingsupport.h b/src/plugins/cpptools/cppindexingsupport.h
index 58b0b26298..e3d9eb257e 100644
--- a/src/plugins/cpptools/cppindexingsupport.h
+++ b/src/plugins/cpptools/cppindexingsupport.h
@@ -81,8 +81,8 @@ public:
virtual QFuture<void> refreshSourceFiles(const QFutureInterface<void> &superFuture,
const QSet<QString> &sourceFiles,
CppModelManager::ProgressNotificationMode mode) = 0;
- virtual SymbolSearcher *createSymbolSearcher(SymbolSearcher::Parameters parameters,
- QSet<QString> fileNames) = 0;
+ virtual SymbolSearcher *createSymbolSearcher(const SymbolSearcher::Parameters &parameters,
+ const QSet<QString> &fileNames) = 0;
};
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppkitinfo.h b/src/plugins/cpptools/cppkitinfo.h
index 30ff300859..d2f9a871bd 100644
--- a/src/plugins/cpptools/cppkitinfo.h
+++ b/src/plugins/cpptools/cppkitinfo.h
@@ -40,7 +40,7 @@ namespace CppTools {
class CPPTOOLS_EXPORT KitInfo
{
public:
- KitInfo(ProjectExplorer::Project *project);
+ explicit KitInfo(ProjectExplorer::Project *project);
bool isValid() const;
diff --git a/src/plugins/cpptools/cpplocalsymbols.cpp b/src/plugins/cpptools/cpplocalsymbols.cpp
index 49dd63f700..feec5dc606 100644
--- a/src/plugins/cpptools/cpplocalsymbols.cpp
+++ b/src/plugins/cpptools/cpplocalsymbols.cpp
@@ -36,7 +36,7 @@ namespace {
class FindLocalSymbols: protected ASTVisitor
{
public:
- FindLocalSymbols(Document::Ptr doc)
+ explicit FindLocalSymbols(Document::Ptr doc)
: ASTVisitor(doc->translationUnit())
{ }
@@ -65,7 +65,7 @@ protected:
using ASTVisitor::visit;
using ASTVisitor::endVisit;
- typedef TextEditor::HighlightingResult HighlightingResult;
+ using HighlightingResult = TextEditor::HighlightingResult;
void enterScope(Scope *scope)
{
diff --git a/src/plugins/cpptools/cpplocalsymbols_test.cpp b/src/plugins/cpptools/cpplocalsymbols_test.cpp
index 9183c9bfcd..7ee8ad1723 100644
--- a/src/plugins/cpptools/cpplocalsymbols_test.cpp
+++ b/src/plugins/cpptools/cpplocalsymbols_test.cpp
@@ -38,9 +38,8 @@ namespace {
class FindFirstFunctionDefinition: protected CPlusPlus::ASTVisitor
{
public:
- FindFirstFunctionDefinition(CPlusPlus::TranslationUnit *translationUnit)
+ explicit FindFirstFunctionDefinition(CPlusPlus::TranslationUnit *translationUnit)
: ASTVisitor(translationUnit)
- , m_definition(0)
{}
CPlusPlus::FunctionDefinitionAST *operator()()
@@ -50,7 +49,7 @@ public:
}
private:
- bool preVisit(CPlusPlus::AST *ast)
+ bool preVisit(CPlusPlus::AST *ast) override
{
if (CPlusPlus::FunctionDefinitionAST *f = ast->asFunctionDefinition()) {
m_definition = f;
@@ -60,20 +59,20 @@ private:
}
private:
- CPlusPlus::FunctionDefinitionAST *m_definition;
+ CPlusPlus::FunctionDefinitionAST *m_definition = nullptr;
};
struct Result
{
- Result() : line(0), column(0), length(0) {}
+ Result() = default;
Result(const QByteArray &name, unsigned line, unsigned column, unsigned length)
: name(name), line(line), column(column), length(length)
{}
QByteArray name;
- unsigned line;
- unsigned column;
- unsigned length;
+ unsigned line = 0;
+ unsigned column = 0;
+ unsigned length = 0;
bool operator==(const Result &other) const
{
@@ -139,7 +138,7 @@ void CppToolsPlugin::test_cpplocalsymbols_data()
QTest::addColumn<QByteArray>("source");
QTest::addColumn<QList<Result>>("expectedUses");
- typedef QByteArray _;
+ using _ = QByteArray;
QTest::newRow("basic")
<< _("int f(int arg)\n"
diff --git a/src/plugins/cpptools/cpplocatorfilter.cpp b/src/plugins/cpptools/cpplocatorfilter.cpp
index ee2a2db395..6865cbe5a2 100644
--- a/src/plugins/cpptools/cpplocatorfilter.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter.cpp
@@ -46,9 +46,7 @@ CppLocatorFilter::CppLocatorFilter(CppLocatorData *locatorData)
setIncludedByDefault(false);
}
-CppLocatorFilter::~CppLocatorFilter()
-{
-}
+CppLocatorFilter::~CppLocatorFilter() = default;
Core::LocatorFilterEntry CppLocatorFilter::filterEntryFromIndexItem(IndexItem::Ptr info)
{
diff --git a/src/plugins/cpptools/cpplocatorfilter.h b/src/plugins/cpptools/cpplocatorfilter.h
index 971fec9e33..129c5cc08a 100644
--- a/src/plugins/cpptools/cpplocatorfilter.h
+++ b/src/plugins/cpptools/cpplocatorfilter.h
@@ -38,7 +38,7 @@ class CppLocatorFilter : public Core::ILocatorFilter
Q_OBJECT
public:
- CppLocatorFilter(CppLocatorData *locatorData);
+ explicit CppLocatorFilter(CppLocatorData *locatorData);
~CppLocatorFilter() override;
QList<Core::LocatorFilterEntry> matchesFor(QFutureInterface<Core::LocatorFilterEntry> &future,
diff --git a/src/plugins/cpptools/cpplocatorfilter_test.cpp b/src/plugins/cpptools/cpplocatorfilter_test.cpp
index e7a1775fd7..8c6f50390f 100644
--- a/src/plugins/cpptools/cpplocatorfilter_test.cpp
+++ b/src/plugins/cpptools/cpplocatorfilter_test.cpp
@@ -82,8 +82,8 @@ public:
}
private:
- void doBeforeLocatorRun() { QVERIFY(parseFiles(m_fileName)); }
- void doAfterLocatorRun() { QVERIFY(garbageCollectGlobalSnapshot()); }
+ void doBeforeLocatorRun() override { QVERIFY(parseFiles(m_fileName)); }
+ void doAfterLocatorRun() override { QVERIFY(garbageCollectGlobalSnapshot()); }
private:
const QString m_fileName;
@@ -97,7 +97,6 @@ public:
CppCurrentDocumentFilterTestCase(const QString &fileName,
const ResultDataList &expectedResults)
: BasicLocatorFilterTest(CppTools::CppModelManager::instance()->currentDocumentFilter())
- , m_editor(0)
, m_fileName(fileName)
{
QVERIFY(succeededSoFar());
@@ -113,7 +112,7 @@ public:
}
private:
- void doBeforeLocatorRun()
+ void doBeforeLocatorRun() override
{
QVERIFY(DocumentModel::openedDocuments().isEmpty());
QVERIFY(garbageCollectGlobalSnapshot());
@@ -124,7 +123,7 @@ private:
QVERIFY(waitForFileInGlobalSnapshot(m_fileName));
}
- void doAfterLocatorRun()
+ void doAfterLocatorRun() override
{
QVERIFY(closeEditorWithoutGarbageCollectorInvocation(m_editor));
QCoreApplication::processEvents();
@@ -133,7 +132,7 @@ private:
}
private:
- IEditor *m_editor;
+ IEditor *m_editor = nullptr;
const QString m_fileName;
};
diff --git a/src/plugins/cpptools/cppmodelmanager.cpp b/src/plugins/cpptools/cppmodelmanager.cpp
index 4db2cbb1b9..45ab82efec 100644
--- a/src/plugins/cpptools/cppmodelmanager.cpp
+++ b/src/plugins/cpptools/cppmodelmanager.cpp
@@ -95,7 +95,7 @@ class DumpAST: protected ASTVisitor
public:
int depth;
- DumpAST(Control *control)
+ explicit DumpAST(Control *control)
: ASTVisitor(control), depth(0)
{ }
@@ -511,7 +511,7 @@ CppModelManager::CppModelManager()
: CppModelManagerBase(nullptr)
, d(new CppModelManagerPrivate)
{
- d->m_indexingSupporter = 0;
+ d->m_indexingSupporter = nullptr;
d->m_enableGC = true;
qRegisterMetaType<QSet<QString> >();
@@ -696,7 +696,7 @@ void CppModelManager::removeExtraEditorSupport(AbstractEditorSupport *editorSupp
CppEditorDocumentHandle *CppModelManager::cppEditorDocument(const QString &filePath) const
{
if (filePath.isEmpty())
- return 0;
+ return nullptr;
QMutexLocker locker(&d->m_cppEditorDocumentsMutex);
return d->m_cppEditorDocuments.value(filePath, 0);
@@ -987,7 +987,7 @@ void CppModelManager::watchForCanceledProjectIndexer(const QVector<QFuture<void>
if (future.isCanceled() || future.isFinished())
continue;
- QFutureWatcher<void> *watcher = new QFutureWatcher<void>();
+ auto watcher = new QFutureWatcher<void>();
connect(watcher, &QFutureWatcher<void>::canceled, this, [this, project, watcher]() {
if (d->m_projectToIndexerCanceled.contains(project)) // Project not yet removed
d->m_projectToIndexerCanceled.insert(project, true);
@@ -1411,7 +1411,7 @@ void CppModelManager::setIndexingSupport(CppIndexingSupport *indexingSupport)
{
if (indexingSupport) {
if (dynamic_cast<BuiltinIndexingSupport *>(indexingSupport))
- d->m_indexingSupporter = 0;
+ d->m_indexingSupporter = nullptr;
else
d->m_indexingSupporter = indexingSupport;
}
diff --git a/src/plugins/cpptools/cppmodelmanager.h b/src/plugins/cpptools/cppmodelmanager.h
index 9726c8086f..0eac5abf87 100644
--- a/src/plugins/cpptools/cppmodelmanager.h
+++ b/src/plugins/cpptools/cppmodelmanager.h
@@ -90,7 +90,7 @@ class CPPTOOLS_EXPORT CppModelManager final : public CPlusPlus::CppModelManagerB
Q_OBJECT
public:
- typedef CPlusPlus::Document Document;
+ using Document = CPlusPlus::Document;
public:
CppModelManager();
@@ -136,7 +136,7 @@ public:
Document::Ptr document(const QString &fileName) const;
bool replaceDocument(Document::Ptr newDoc);
- void emitDocumentUpdated(CPlusPlus::Document::Ptr doc);
+ void emitDocumentUpdated(Document::Ptr doc);
void emitAbstractEditorSupportContentsUpdated(const QString &filePath,
const QByteArray &contents);
void emitAbstractEditorSupportRemoved(const QString &filePath);
@@ -165,7 +165,7 @@ public:
void globalFollowSymbol(const CursorInEditor &data,
Utils::ProcessLinkCallback &&processLinkCallback,
const CPlusPlus::Snapshot &snapshot,
- const CPlusPlus::Document::Ptr &documentFromSemanticInfo,
+ const Document::Ptr &documentFromSemanticInfo,
SymbolFinder *symbolFinder,
bool inNextSplit) const final;
diff --git a/src/plugins/cpptools/cppmodelmanager_test.cpp b/src/plugins/cpptools/cppmodelmanager_test.cpp
index e3d40ecc5f..aac046745b 100644
--- a/src/plugins/cpptools/cppmodelmanager_test.cpp
+++ b/src/plugins/cpptools/cppmodelmanager_test.cpp
@@ -55,7 +55,7 @@ using namespace CppTools::Internal;
using namespace CppTools::Tests;
using namespace ProjectExplorer;
-typedef CPlusPlus::Document Document;
+using CPlusPlus::Document;
Q_DECLARE_METATYPE(ProjectFile)
@@ -66,7 +66,7 @@ inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size(
class MyTestDataDir : public Core::Tests::TestDataDir
{
public:
- MyTestDataDir(const QString &dir)
+ explicit MyTestDataDir(const QString &dir)
: TestDataDir(_(SRCDIR "/../../../tests/cppmodelmanager/") + dir)
{}
@@ -93,7 +93,7 @@ QStringList toAbsolutePaths(const QStringList &relativePathList,
class ProjectCreator
{
public:
- ProjectCreator(ModelManagerTestHelper *modelManagerTestHelper)
+ explicit ProjectCreator(ModelManagerTestHelper *modelManagerTestHelper)
: modelManagerTestHelper(modelManagerTestHelper)
{}
@@ -125,7 +125,7 @@ public:
class FileChangerAndRestorer
{
public:
- FileChangerAndRestorer(const QString &filePath)
+ explicit FileChangerAndRestorer(const QString &filePath)
: m_filePath(filePath)
{
}
@@ -328,7 +328,7 @@ void CppToolsPlugin::test_modelmanager_refresh_several_times()
CPlusPlus::Snapshot snapshot;
QSet<QString> refreshedFiles;
- CPlusPlus::Document::Ptr document;
+ Document::Ptr document;
ProjectExplorer::Macros macros = {{"FIRST_DEFINE"}};
for (int i = 0; i < 2; ++i) {
@@ -714,7 +714,7 @@ void CppToolsPlugin::test_modelmanager_dont_gc_opened_files()
namespace {
struct EditorCloser {
Core::IEditor *editor;
- EditorCloser(Core::IEditor *editor): editor(editor) {}
+ explicit EditorCloser(Core::IEditor *editor): editor(editor) {}
~EditorCloser()
{
using namespace CppTools;
@@ -785,10 +785,10 @@ void CppToolsPlugin::test_modelmanager_defines_per_project()
{_("one"), main1File},
{_("two"), main2File}
};
- const int size = sizeof(d) / sizeof(d[0]);
- for (int i = 0; i < size; ++i) {
- const QString firstDeclarationName = d[i].firstDeclarationName;
- const QString fileName = d[i].fileName;
+
+ for (auto &i : d) {
+ const QString firstDeclarationName = i.firstDeclarationName;
+ const QString fileName = i.fileName;
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
EditorCloser closer(editor);
@@ -852,11 +852,10 @@ void CppToolsPlugin::test_modelmanager_precompiled_headers()
{_("one"), _("ClassInPch1"), main1File},
{_("two"), _("ClassInPch2"), main2File}
};
- const int size = sizeof(d) / sizeof(d[0]);
- for (int i = 0; i < size; ++i) {
- const QString firstDeclarationName = d[i].firstDeclarationName;
- const QByteArray firstClassInPchFile = d[i].firstClassInPchFile.toUtf8();
- const QString fileName = d[i].fileName;
+ for (auto &i : d) {
+ const QString firstDeclarationName = i.firstDeclarationName;
+ const QByteArray firstClassInPchFile = i.firstClassInPchFile.toUtf8();
+ const QString fileName = i.fileName;
Core::IEditor *editor = Core::EditorManager::openEditor(fileName);
EditorCloser closer(editor);
@@ -929,10 +928,9 @@ void CppToolsPlugin::test_modelmanager_defines_per_editor()
{_("#define SUB1\n"), _("one")},
{_("#define SUB2\n"), _("two")}
};
- const int size = sizeof(d) / sizeof(d[0]);
- for (int i = 0; i < size; ++i) {
- const QString editorDefines = d[i].editorDefines;
- const QString firstDeclarationName = d[i].firstDeclarationName;
+ for (auto &i : d) {
+ const QString editorDefines = i.editorDefines;
+ const QString firstDeclarationName = i.firstDeclarationName;
Core::IEditor *editor = Core::EditorManager::openEditor(main1File);
EditorCloser closer(editor);
diff --git a/src/plugins/cpptools/cppmodelmanagerinterface.h b/src/plugins/cpptools/cppmodelmanagerinterface.h
index cd3fbc615a..e8f72f7394 100644
--- a/src/plugins/cpptools/cppmodelmanagerinterface.h
+++ b/src/plugins/cpptools/cppmodelmanagerinterface.h
@@ -35,6 +35,6 @@ public:
virtual ProjectPart::Ptr projectPartForId(const QString &projectPartId) const = 0;
protected:
- ~CppModelManagerInterface() = default;
+ virtual ~CppModelManagerInterface() = default;
};
}
diff --git a/src/plugins/cpptools/cppmodelmanagersupport.cpp b/src/plugins/cpptools/cppmodelmanagersupport.cpp
index 81d745d6d1..efc1a1c518 100644
--- a/src/plugins/cpptools/cppmodelmanagersupport.cpp
+++ b/src/plugins/cpptools/cppmodelmanagersupport.cpp
@@ -27,6 +27,4 @@
using namespace CppTools;
-ModelManagerSupport::~ModelManagerSupport()
-{
-}
+ModelManagerSupport::~ModelManagerSupport() = default;
diff --git a/src/plugins/cpptools/cppmodelmanagersupport.h b/src/plugins/cpptools/cppmodelmanagersupport.h
index c5457cd51f..462060a5a9 100644
--- a/src/plugins/cpptools/cppmodelmanagersupport.h
+++ b/src/plugins/cpptools/cppmodelmanagersupport.h
@@ -65,7 +65,7 @@ public:
class CPPTOOLS_EXPORT ModelManagerSupportProvider
{
public:
- virtual ~ModelManagerSupportProvider() {}
+ virtual ~ModelManagerSupportProvider() = default;
virtual QString id() const = 0;
virtual QString displayName() const = 0;
diff --git a/src/plugins/cpptools/cppoverviewmodel.cpp b/src/plugins/cpptools/cppoverviewmodel.cpp
index 8c720b75ca..e0fc805698 100644
--- a/src/plugins/cpptools/cppoverviewmodel.cpp
+++ b/src/plugins/cpptools/cppoverviewmodel.cpp
@@ -50,7 +50,7 @@ QVariant SymbolItem::data(int /*column*/, int role) const
}
}
- OverviewModel *overviewModel = qobject_cast<OverviewModel *>(model());
+ auto overviewModel = qobject_cast<const OverviewModel*>(model());
if (!symbol || !overviewModel)
return QVariant();
@@ -150,7 +150,7 @@ Symbol *OverviewModel::symbolFromIndex(const QModelIndex &index) const
{
if (!index.isValid())
return nullptr;
- SymbolItem *item = static_cast<SymbolItem *>(itemForIndex(index));
+ auto item = static_cast<const SymbolItem*>(itemForIndex(index));
return item ? item->symbol : nullptr;
}
diff --git a/src/plugins/cpptools/cppoverviewmodel.h b/src/plugins/cpptools/cppoverviewmodel.h
index 0a7870ed28..44a45ace36 100644
--- a/src/plugins/cpptools/cppoverviewmodel.h
+++ b/src/plugins/cpptools/cppoverviewmodel.h
@@ -36,7 +36,7 @@ class SymbolItem : public Utils::TreeItem
{
public:
SymbolItem() = default;
- SymbolItem(CPlusPlus::Symbol *symbol) : symbol(symbol) {}
+ explicit SymbolItem(CPlusPlus::Symbol *symbol) : symbol(symbol) {}
QVariant data(int column, int role) const override;
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter.h b/src/plugins/cpptools/cpppointerdeclarationformatter.h
index 8eab4a88a8..20ed9557bc 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter.h
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter.h
@@ -100,10 +100,10 @@ protected:
private:
class TokenRange {
public:
- TokenRange() : start(0), end(0) {}
+ TokenRange() = default;
TokenRange(unsigned start, unsigned end) : start(start), end(end) {}
- unsigned start;
- unsigned end;
+ unsigned start = 0;
+ unsigned end = 0;
};
void processIfWhileForStatement(ExpressionAST *expression, Symbol *symbol);
diff --git a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
index 405967b062..f412c9ab69 100644
--- a/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
+++ b/src/plugins/cpptools/cpppointerdeclarationformatter_test.cpp
@@ -91,7 +91,7 @@ public:
// Preprocess source
Environment env;
- Preprocessor preprocess(0, &env);
+ Preprocessor preprocess(nullptr, &env);
const QByteArray preprocessedSource = preprocess.run(filePath, sourceWithoutCursorMarker);
Document::Ptr document = Document::create(filePath);
@@ -122,7 +122,7 @@ public:
Overview overview;
overview.showReturnTypes = true;
overview.showArgumentNames = true;
- overview.starBindFlags = Overview::StarBindFlags(0);
+ overview.starBindFlags = Overview::StarBindFlags(nullptr);
// Run the formatter
PointerDeclarationFormatter formatter(cppRefactoringFile, overview, cursorHandling);
diff --git a/src/plugins/cpptools/cppprojectfilecategorizer.cpp b/src/plugins/cpptools/cppprojectfilecategorizer.cpp
index d0f4940052..ddb841f9de 100644
--- a/src/plugins/cpptools/cppprojectfilecategorizer.cpp
+++ b/src/plugins/cpptools/cppprojectfilecategorizer.cpp
@@ -31,7 +31,7 @@ namespace CppTools {
ProjectFileCategorizer::ProjectFileCategorizer(const QString &projectPartName,
const QStringList &filePaths,
- FileClassifier fileClassifier)
+ const FileClassifier &fileClassifier)
: m_partName(projectPartName)
{
const ProjectFiles ambiguousHeaders = classifyFiles(filePaths, fileClassifier);
@@ -53,7 +53,7 @@ QString ProjectFileCategorizer::partName(const QString &languageName) const
}
ProjectFiles ProjectFileCategorizer::classifyFiles(const QStringList &filePaths,
- FileClassifier fileClassifier)
+ const FileClassifier &fileClassifier)
{
ProjectFiles ambiguousHeaders;
diff --git a/src/plugins/cpptools/cppprojectfilecategorizer.h b/src/plugins/cpptools/cppprojectfilecategorizer.h
index cecf279174..48cd2438c6 100644
--- a/src/plugins/cpptools/cppprojectfilecategorizer.h
+++ b/src/plugins/cpptools/cppprojectfilecategorizer.h
@@ -41,7 +41,7 @@ public:
public:
ProjectFileCategorizer(const QString &projectPartName,
const QStringList &filePaths,
- FileClassifier fileClassifier = FileClassifier());
+ const FileClassifier &fileClassifier = FileClassifier());
bool hasCSources() const { return !m_cSources.isEmpty(); }
bool hasCxxSources() const { return !m_cxxSources.isEmpty(); }
@@ -59,7 +59,7 @@ public:
QString partName(const QString &languageName) const;
private:
- ProjectFiles classifyFiles(const QStringList &filePaths, FileClassifier fileClassifier);
+ ProjectFiles classifyFiles(const QStringList &filePaths, const FileClassifier &fileClassifier);
void expandSourcesWithAmbiguousHeaders(const ProjectFiles &ambiguousHeaders);
private:
diff --git a/src/plugins/cpptools/cppprojectpartchooser.cpp b/src/plugins/cpptools/cppprojectpartchooser.cpp
index ebdb8c696e..548ccbe6f2 100644
--- a/src/plugins/cpptools/cppprojectpartchooser.cpp
+++ b/src/plugins/cpptools/cppprojectpartchooser.cpp
@@ -77,7 +77,7 @@ public:
}
private:
- QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts)
+ QList<PrioritizedProjectPart> prioritize(const QList<ProjectPart::Ptr> &projectParts) const
{
// Prioritize
QList<PrioritizedProjectPart> prioritized = Utils::transform(projectParts,
diff --git a/src/plugins/cpptools/cppqtstyleindenter.cpp b/src/plugins/cpptools/cppqtstyleindenter.cpp
index 2c8f06336f..54cb3cc9ed 100644
--- a/src/plugins/cpptools/cppqtstyleindenter.cpp
+++ b/src/plugins/cpptools/cppqtstyleindenter.cpp
@@ -37,15 +37,13 @@
using namespace CppTools;
CppQtStyleIndenter::CppQtStyleIndenter()
- : m_cppCodeStylePreferences(0)
{
// Just for safety. setCodeStylePreferences should be called when the editor the
// indenter belongs to gets initialized.
m_cppCodeStylePreferences = CppToolsSettings::instance()->cppCodeStyle();
}
-CppQtStyleIndenter::~CppQtStyleIndenter()
-{}
+CppQtStyleIndenter::~CppQtStyleIndenter() = default;
bool CppQtStyleIndenter::isElectricCharacter(const QChar &ch) const
{
@@ -157,8 +155,7 @@ void CppQtStyleIndenter::indent(QTextDocument *doc,
void CppQtStyleIndenter::setCodeStylePreferences(TextEditor::ICodeStylePreferences *preferences)
{
- CppCodeStylePreferences *cppCodeStylePreferences
- = qobject_cast<CppCodeStylePreferences *>(preferences);
+ auto cppCodeStylePreferences = qobject_cast<CppCodeStylePreferences *>(preferences);
if (cppCodeStylePreferences)
m_cppCodeStylePreferences = cppCodeStylePreferences;
}
diff --git a/src/plugins/cpptools/cppqtstyleindenter.h b/src/plugins/cpptools/cppqtstyleindenter.h
index 110e055908..05a36c883e 100644
--- a/src/plugins/cpptools/cppqtstyleindenter.h
+++ b/src/plugins/cpptools/cppqtstyleindenter.h
@@ -63,7 +63,7 @@ public:
const TextEditor::TabSettings &tabSettings) override;
private:
CppCodeStyleSettings codeStyleSettings() const;
- CppCodeStylePreferences *m_cppCodeStylePreferences;
+ CppCodeStylePreferences *m_cppCodeStylePreferences = nullptr;
};
} // CppTools
diff --git a/src/plugins/cpptools/cpprawprojectpart.cpp b/src/plugins/cpptools/cpprawprojectpart.cpp
index 5c9185f13b..ee18166c05 100644
--- a/src/plugins/cpptools/cpprawprojectpart.cpp
+++ b/src/plugins/cpptools/cpprawprojectpart.cpp
@@ -48,7 +48,7 @@ void RawProjectPart::setDisplayName(const QString &displayName)
this->displayName = displayName;
}
-void RawProjectPart::setFiles(const QStringList &files, FileClassifier fileClassifier)
+void RawProjectPart::setFiles(const QStringList &files, const FileClassifier &fileClassifier)
{
this->files = files;
this->fileClassifier = fileClassifier;
diff --git a/src/plugins/cpptools/cpprawprojectpart.h b/src/plugins/cpptools/cpprawprojectpart.h
index c62b6fcc1f..43e3067753 100644
--- a/src/plugins/cpptools/cpprawprojectpart.h
+++ b/src/plugins/cpptools/cpprawprojectpart.h
@@ -52,8 +52,6 @@ public:
class CPPTOOLS_EXPORT RawProjectPart
{
public:
- RawProjectPart() {}
-
void setDisplayName(const QString &displayName);
void setProjectFileLocation(const QString &projectFile, int line = -1, int column = -1);
@@ -62,7 +60,7 @@ public:
// FileClassifier must be thread-safe.
using FileClassifier = std::function<ProjectFile(const QString &filePath)>;
- void setFiles(const QStringList &files, FileClassifier fileClassifier = FileClassifier());
+ void setFiles(const QStringList &files, const FileClassifier &fileClassifier = FileClassifier());
void setHeaderPaths(const ProjectExplorer::HeaderPaths &headerPaths);
void setIncludePaths(const QStringList &includePaths);
void setPreCompiledHeaders(const QStringList &preCompiledHeaders);
diff --git a/src/plugins/cpptools/cpprefactoringchanges.cpp b/src/plugins/cpptools/cpprefactoringchanges.cpp
index c554c9d9f0..929a6ec020 100644
--- a/src/plugins/cpptools/cpprefactoringchanges.cpp
+++ b/src/plugins/cpptools/cpprefactoringchanges.cpp
@@ -43,7 +43,7 @@ namespace CppTools {
class CppRefactoringChangesData : public TextEditor::RefactoringChangesData
{
public:
- CppRefactoringChangesData(const Snapshot &snapshot)
+ explicit CppRefactoringChangesData(const Snapshot &snapshot)
: m_snapshot(snapshot)
, m_modelManager(CppModelManager::instance())
, m_workingCopy(m_modelManager->workingCopy())
@@ -107,7 +107,7 @@ CppRefactoringFilePtr CppRefactoringChanges::file(const QString &fileName) const
CppRefactoringFileConstPtr CppRefactoringChanges::fileNoEditor(const QString &fileName) const
{
- QTextDocument *document = 0;
+ QTextDocument *document = nullptr;
if (data()->m_workingCopy.contains(fileName))
document = new QTextDocument(QString::fromUtf8(data()->m_workingCopy.source(fileName)));
CppRefactoringFilePtr result(new CppRefactoringFile(document, fileName));
diff --git a/src/plugins/cpptools/cpprefactoringchanges.h b/src/plugins/cpptools/cpprefactoringchanges.h
index a227bdf42d..3a547a90c5 100644
--- a/src/plugins/cpptools/cpprefactoringchanges.h
+++ b/src/plugins/cpptools/cpprefactoringchanges.h
@@ -36,8 +36,8 @@ namespace CppTools {
class CppRefactoringChanges;
class CppRefactoringFile;
class CppRefactoringChangesData;
-typedef QSharedPointer<CppRefactoringFile> CppRefactoringFilePtr;
-typedef QSharedPointer<const CppRefactoringFile> CppRefactoringFileConstPtr;
+using CppRefactoringFilePtr = QSharedPointer<CppRefactoringFile>;
+using CppRefactoringFileConstPtr = QSharedPointer<const CppRefactoringFile>;
class CPPTOOLS_EXPORT CppRefactoringFile: public TextEditor::RefactoringFile
{
@@ -69,7 +69,7 @@ public:
protected:
CppRefactoringFile(const QString &fileName, const QSharedPointer<TextEditor::RefactoringChangesData> &data);
CppRefactoringFile(QTextDocument *document, const QString &fileName);
- CppRefactoringFile(TextEditor::TextEditorWidget *editor);
+ explicit CppRefactoringFile(TextEditor::TextEditorWidget *editor);
CppRefactoringChangesData *data() const;
void fileChanged() override;
@@ -82,7 +82,7 @@ protected:
class CPPTOOLS_EXPORT CppRefactoringChanges: public TextEditor::RefactoringChanges
{
public:
- CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
+ explicit CppRefactoringChanges(const CPlusPlus::Snapshot &snapshot);
static CppRefactoringFilePtr file(TextEditor::TextEditorWidget *editor,
const CPlusPlus::Document::Ptr &document);
diff --git a/src/plugins/cpptools/cppselectionchanger.cpp b/src/plugins/cpptools/cppselectionchanger.cpp
index 59ac0a1634..e19c1711a6 100644
--- a/src/plugins/cpptools/cppselectionchanger.cpp
+++ b/src/plugins/cpptools/cppselectionchanger.cpp
@@ -51,14 +51,8 @@ using namespace CppTools::Internal;
CppSelectionChanger::CppSelectionChanger(QObject *parent)
: QObject(parent)
- , m_initialChangeSelectionCursor()
- , m_workingCursor()
- , m_doc(0)
- , m_unit(0)
- , m_direction(ExpandSelection)
, m_changeSelectionNodeIndex(kChangeSelectionNodeIndexNotSet)
, m_nodeCurrentStep(kChangeSelectionNodeIndexNotSet)
- , m_inChangeSelection(false)
{
}
@@ -337,7 +331,7 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursor(
}
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
- const QList<AST *> astPath,
+ const QList<AST *> &astPath,
const QTextCursor &cursor)
{
// Find relevant AST node from cursor, when the user expands for the first time.
@@ -345,19 +339,18 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenNode
}
ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
- const QList<AST *> astPath,
+ const QList<AST *> &astPath,
const QTextCursor &cursor)
{
// Can't expand more, because whole document is selected.
if (m_direction == ExpandSelection)
- return 0;
+ return {};
// In case of shrink, select the next smaller selection.
return findRelevantASTPositionsFromCursor(astPath, cursor);
}
-ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPreviousNodeIndex(
- const QList<AST *> astPath,
+ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPreviousNodeIndex(const QList<AST *> &astPath,
const QTextCursor &cursor)
{
ASTNodePositions nodePositions;
@@ -377,13 +370,13 @@ ASTNodePositions CppSelectionChanger::findRelevantASTPositionsFromCursorFromPrev
if (newAstIndex < 0 || newAstIndex >= astPath.count()) {
if (debug)
qDebug() << "Skipping expansion because there is no available next AST node.";
- return 0;
+ return {};
}
// Switch to next AST and set the first step.
nodePositions = findRelevantASTPositionsFromCursor(astPath, cursor, newAstIndex);
if (!nodePositions)
- return 0;
+ return {};
if (debug)
qDebug() << "Moved to next AST node.";
@@ -419,7 +412,7 @@ ASTNodePositions CppSelectionChanger::findNextASTStepPositions(const QTextCursor
#endif
if (astPath.size() == 0)
- return 0;
+ return {};
ASTNodePositions currentNodePositions;
if (m_changeSelectionNodeIndex == kChangeSelectionNodeIndexNotSet) {
@@ -439,7 +432,7 @@ ASTNodePositions CppSelectionChanger::findNextASTStepPositions(const QTextCursor
<< "current step:" << m_nodeCurrentStep;
}
- QTC_ASSERT(m_nodeCurrentStep >= 1, return 0);
+ QTC_ASSERT(m_nodeCurrentStep >= 1, return {});
return currentNodePositions;
}
diff --git a/src/plugins/cpptools/cppselectionchanger.h b/src/plugins/cpptools/cppselectionchanger.h
index d205e2ce2e..487e8ff655 100644
--- a/src/plugins/cpptools/cppselectionchanger.h
+++ b/src/plugins/cpptools/cppselectionchanger.h
@@ -38,8 +38,8 @@ namespace CppTools {
class ASTNodePositions {
public:
- ASTNodePositions() {}
- ASTNodePositions(CPlusPlus::AST *_ast) : ast(_ast) {}
+ ASTNodePositions() = default;
+ explicit ASTNodePositions(CPlusPlus::AST *_ast) : ast(_ast) {}
operator bool() const { return ast; }
CPlusPlus::AST *ast = nullptr;
@@ -97,13 +97,13 @@ private:
const QTextCursor &cursor,
int startingFromNodeIndex = -1);
ASTNodePositions findRelevantASTPositionsFromCursorWhenNodeIndexNotSet(
- const QList<CPlusPlus::AST *> astPath,
+ const QList<CPlusPlus::AST *> &astPath,
const QTextCursor &cursor);
ASTNodePositions findRelevantASTPositionsFromCursorWhenWholeDocumentSelected(
- const QList<CPlusPlus::AST *> astPath,
+ const QList<CPlusPlus::AST *> &astPath,
const QTextCursor &cursor);
ASTNodePositions findRelevantASTPositionsFromCursorFromPreviousNodeIndex(
- const QList<CPlusPlus::AST *> astPath,
+ const QList<CPlusPlus::AST *> &astPath,
const QTextCursor &cursor);
bool shouldSkipASTNodeBasedOnPosition(const ASTNodePositions &positions,
const QTextCursor &cursor) const;
@@ -115,11 +115,11 @@ private:
QTextCursor m_initialChangeSelectionCursor;
QTextCursor m_workingCursor;
CPlusPlus::Document::Ptr m_doc;
- CPlusPlus::TranslationUnit *m_unit;
- Direction m_direction;
- int m_changeSelectionNodeIndex;
- int m_nodeCurrentStep;
- bool m_inChangeSelection;
+ CPlusPlus::TranslationUnit *m_unit = nullptr;
+ Direction m_direction = ExpandSelection;
+ int m_changeSelectionNodeIndex = -1;
+ int m_nodeCurrentStep = -1;
+ bool m_inChangeSelection = false;
};
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppsemanticinfoupdater.cpp b/src/plugins/cpptools/cppsemanticinfoupdater.cpp
index 5913c808cf..0c94c7715c 100644
--- a/src/plugins/cpptools/cppsemanticinfoupdater.cpp
+++ b/src/plugins/cpptools/cppsemanticinfoupdater.cpp
@@ -52,15 +52,15 @@ public:
class FuturizedTopLevelDeclarationProcessor: public TopLevelDeclarationProcessor
{
public:
- FuturizedTopLevelDeclarationProcessor(QFutureInterface<void> &future): m_future(future) {}
- bool processDeclaration(DeclarationAST *) { return !isCanceled(); }
+ explicit FuturizedTopLevelDeclarationProcessor(QFutureInterface<void> &future): m_future(future) {}
+ bool processDeclaration(DeclarationAST *) override { return !isCanceled(); }
bool isCanceled() { return m_future.isCanceled(); }
private:
QFutureInterface<void> m_future;
};
public:
- SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q);
+ explicit SemanticInfoUpdaterPrivate(SemanticInfoUpdater *q);
~SemanticInfoUpdaterPrivate();
SemanticInfo semanticInfo() const;
@@ -72,7 +72,7 @@ public:
bool reuseCurrentSemanticInfo(const SemanticInfo::Source &source, bool emitSignalWhenFinished);
- void update_helper(QFutureInterface<void> &future, const SemanticInfo::Source source);
+ void update_helper(QFutureInterface<void> &future, const SemanticInfo::Source &source);
public:
SemanticInfoUpdater *q;
@@ -159,7 +159,7 @@ bool SemanticInfoUpdaterPrivate::reuseCurrentSemanticInfo(const SemanticInfo::So
}
void SemanticInfoUpdaterPrivate::update_helper(QFutureInterface<void> &future,
- const SemanticInfo::Source source)
+ const SemanticInfo::Source &source)
{
FuturizedTopLevelDeclarationProcessor processor(future);
update(source, true, &processor);
@@ -187,10 +187,10 @@ SemanticInfo SemanticInfoUpdater::update(const SemanticInfo::Source &source)
return semanticInfo();
}
- return d->update(source, emitSignalWhenFinished, 0);
+ return d->update(source, emitSignalWhenFinished, nullptr);
}
-void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source source)
+void SemanticInfoUpdater::updateDetached(const SemanticInfo::Source &source)
{
qCDebug(log) << "updateDetached() - asynchronous";
d->m_future.cancel();
diff --git a/src/plugins/cpptools/cppsemanticinfoupdater.h b/src/plugins/cpptools/cppsemanticinfoupdater.h
index 2f9101f3e0..f967cc94e0 100644
--- a/src/plugins/cpptools/cppsemanticinfoupdater.h
+++ b/src/plugins/cpptools/cppsemanticinfoupdater.h
@@ -45,10 +45,10 @@ public:
SemanticInfo semanticInfo() const;
SemanticInfo update(const SemanticInfo::Source &source);
- void updateDetached(const SemanticInfo::Source source);
+ void updateDetached(const SemanticInfo::Source &source);
signals:
- void updated(CppTools::SemanticInfo semanticInfo);
+ void updated(const CppTools::SemanticInfo &semanticInfo);
private:
QScopedPointer<SemanticInfoUpdaterPrivate> d;
diff --git a/src/plugins/cpptools/cppsourceprocessor.cpp b/src/plugins/cpptools/cppsourceprocessor.cpp
index 2259b01f78..35a0ccf529 100644
--- a/src/plugins/cpptools/cppsourceprocessor.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor.cpp
@@ -56,7 +56,7 @@ using namespace CPlusPlus;
using namespace CppTools;
using namespace CppTools::Internal;
-typedef Document::DiagnosticMessage Message;
+using Message = Document::DiagnosticMessage;
static Q_LOGGING_CATEGORY(log, "qtc.cpptools.sourceprocessor", QtWarningMsg)
@@ -119,8 +119,7 @@ CppSourceProcessor::CppSourceProcessor(const Snapshot &snapshot, DocumentCallbac
m_preprocess.setKeepComments(true);
}
-CppSourceProcessor::~CppSourceProcessor()
-{ }
+CppSourceProcessor::~CppSourceProcessor() = default;
void CppSourceProcessor::setCancelChecker(const CppSourceProcessor::CancelChecker &cancelChecker)
{
@@ -135,10 +134,8 @@ void CppSourceProcessor::setHeaderPaths(const ProjectExplorer::HeaderPaths &head
using ProjectExplorer::HeaderPathType;
m_headerPaths.clear();
- for (int i = 0, ei = headerPaths.size(); i < ei; ++i) {
- const ProjectExplorer::HeaderPath &path = headerPaths.at(i);
-
- if (path.type == HeaderPathType::Framework )
+ for (const auto &path : headerPaths) {
+ if (path.type == HeaderPathType::Framework )
addFrameworkPath(path);
else
m_headerPaths.append({cleanPath(path.path), path.type});
diff --git a/src/plugins/cpptools/cppsourceprocessor.h b/src/plugins/cpptools/cppsourceprocessor.h
index b60e3c482a..de6ea7928a 100644
--- a/src/plugins/cpptools/cppsourceprocessor.h
+++ b/src/plugins/cpptools/cppsourceprocessor.h
@@ -51,13 +51,13 @@ class CppSourceProcessor: public CPlusPlus::Client
Q_DISABLE_COPY(CppSourceProcessor)
public:
- typedef std::function<void (const CPlusPlus::Document::Ptr &)> DocumentCallback;
+ using DocumentCallback = std::function<void (const CPlusPlus::Document::Ptr &)>;
public:
static QString cleanPath(const QString &path);
CppSourceProcessor(const CPlusPlus::Snapshot &snapshot, DocumentCallback documentFinished);
- ~CppSourceProcessor();
+ ~CppSourceProcessor() override;
using CancelChecker = std::function<bool()>;
void setCancelChecker(const CancelChecker &cancelChecker);
diff --git a/src/plugins/cpptools/cppsourceprocessor_test.cpp b/src/plugins/cpptools/cppsourceprocessor_test.cpp
index d0b9489593..009264cc3c 100644
--- a/src/plugins/cpptools/cppsourceprocessor_test.cpp
+++ b/src/plugins/cpptools/cppsourceprocessor_test.cpp
@@ -49,7 +49,7 @@ using namespace CppTools::Tests;
using namespace CppTools::Internal;
using ProjectExplorer::HeaderPathType;
-typedef Document::Include Include;
+using Include = Document::Include;
class SourcePreprocessor
{
@@ -60,7 +60,7 @@ public:
cleanUp();
}
- Document::Ptr run(const QString &filePath)
+ Document::Ptr run(const QString &filePath) const
{
QScopedPointer<CppSourceProcessor> sourceProcessor(
CppModelManager::createSourceProcessor());
diff --git a/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp
index e0b6b9fdab..c8acdb9918 100644
--- a/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp
+++ b/src/plugins/cpptools/cpptoolsbridgeqtcreatorimplementation.cpp
@@ -79,7 +79,7 @@ CppToolsBridgeQtCreatorImplementation::baseEditorDocumentProcessor(const QString
if (document)
return document->processor();
- return 0;
+ return nullptr;
}
void CppToolsBridgeQtCreatorImplementation::finishedRefreshingSourceFiles(
diff --git a/src/plugins/cpptools/cpptoolsjsextension.h b/src/plugins/cpptools/cpptoolsjsextension.h
index f009c6c259..16a4010f78 100644
--- a/src/plugins/cpptools/cpptoolsjsextension.h
+++ b/src/plugins/cpptools/cpptoolsjsextension.h
@@ -40,7 +40,7 @@ class CppToolsJsExtension : public QObject
Q_OBJECT
public:
- CppToolsJsExtension(QObject *parent = 0) : QObject(parent) { }
+ explicit CppToolsJsExtension(QObject *parent = nullptr) : QObject(parent) { }
// Generate header guard:
Q_INVOKABLE QString headerGuard(const QString &in) const;
diff --git a/src/plugins/cpptools/cpptoolsreuse.cpp b/src/plugins/cpptools/cpptoolsreuse.cpp
index c63a3cc293..63d0a0bbc8 100644
--- a/src/plugins/cpptools/cpptoolsreuse.cpp
+++ b/src/plugins/cpptools/cpptoolsreuse.cpp
@@ -213,7 +213,7 @@ QString identifierUnderCursor(QTextCursor *cursor)
const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr document)
{
- QTC_ASSERT(document, return 0);
+ QTC_ASSERT(document, return nullptr);
int line, column;
Utils::Text::convertPosition(cursor.document(), cursor.position(), &line, &column);
@@ -227,7 +227,7 @@ const Macro *findCanonicalMacro(const QTextCursor &cursor, Document::Ptr documen
return &use->macro();
}
- return 0;
+ return nullptr;
}
QSharedPointer<CppCodeModelSettings> codeModelSettings()
diff --git a/src/plugins/cpptools/cpptoolssettings.cpp b/src/plugins/cpptools/cpptoolssettings.cpp
index eb56c51722..b4978d06de 100644
--- a/src/plugins/cpptools/cpptoolssettings.cpp
+++ b/src/plugins/cpptools/cpptoolssettings.cpp
@@ -55,18 +55,14 @@ namespace Internal {
class CppToolsSettingsPrivate
{
public:
- CppToolsSettingsPrivate()
- : m_globalCodeStyle(0)
- {}
-
CommentsSettings m_commentsSettings;
- CppCodeStylePreferences *m_globalCodeStyle;
+ CppCodeStylePreferences *m_globalCodeStyle = nullptr;
};
} // namespace Internal
} // namespace CppTools
-CppToolsSettings *CppToolsSettings::m_instance = 0;
+CppToolsSettings *CppToolsSettings::m_instance = nullptr;
CppToolsSettings::CppToolsSettings(QObject *parent)
: QObject(parent)
@@ -86,7 +82,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
TextEditorSettings::registerCodeStyleFactory(factory);
// code style pool
- CodeStylePool *pool = new CodeStylePool(factory, this);
+ auto pool = new CodeStylePool(factory, this);
TextEditorSettings::registerCodeStylePool(Constants::CPP_SETTINGS_ID, pool);
// global code style settings
@@ -124,7 +120,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
// built-in settings
// Qt style
- CppCodeStylePreferences *qtCodeStyle = new CppCodeStylePreferences();
+ auto qtCodeStyle = new CppCodeStylePreferences;
qtCodeStyle->setId("qt");
qtCodeStyle->setDisplayName(tr("Qt"));
qtCodeStyle->setReadOnly(true);
@@ -137,7 +133,7 @@ CppToolsSettings::CppToolsSettings(QObject *parent)
pool->addCodeStyle(qtCodeStyle);
// GNU style
- CppCodeStylePreferences *gnuCodeStyle = new CppCodeStylePreferences();
+ auto gnuCodeStyle = new CppCodeStylePreferences;
gnuCodeStyle->setId("gnu");
gnuCodeStyle->setDisplayName(tr("GNU"));
gnuCodeStyle->setReadOnly(true);
@@ -227,7 +223,7 @@ CppToolsSettings::~CppToolsSettings()
delete d;
- m_instance = 0;
+ m_instance = nullptr;
}
CppToolsSettings *CppToolsSettings::instance()
diff --git a/src/plugins/cpptools/cpptoolstestcase.cpp b/src/plugins/cpptools/cpptoolstestcase.cpp
index 9b05e4f542..f06dcf79a2 100644
--- a/src/plugins/cpptools/cpptoolstestcase.cpp
+++ b/src/plugins/cpptools/cpptoolstestcase.cpp
@@ -120,8 +120,8 @@ bool TestCase::succeededSoFar() const
bool TestCase::openBaseTextEditor(const QString &fileName, TextEditor::BaseTextEditor **editor)
{
- typedef TextEditor::BaseTextEditor BTEditor;
- if (BTEditor *e = qobject_cast<BTEditor *>(Core::EditorManager::openEditor(fileName))) {
+ using BTEditor = TextEditor::BaseTextEditor;
+ if (auto e = qobject_cast<BTEditor *>(Core::EditorManager::openEditor(fileName))) {
if (editor) {
*editor = e;
return true;
diff --git a/src/plugins/cpptools/cpptoolstestcase.h b/src/plugins/cpptools/cpptoolstestcase.h
index 2b1818e827..009a5a9c3e 100644
--- a/src/plugins/cpptools/cpptoolstestcase.h
+++ b/src/plugins/cpptools/cpptoolstestcase.h
@@ -74,7 +74,7 @@ class CPPTOOLS_EXPORT TestCase
Q_DISABLE_COPY(TestCase)
public:
- TestCase(bool runGarbageCollector = true);
+ explicit TestCase(bool runGarbageCollector = true);
~TestCase();
bool succeededSoFar() const;
@@ -145,7 +145,7 @@ protected:
class CPPTOOLS_EXPORT TemporaryCopiedDir : public TemporaryDir
{
public:
- TemporaryCopiedDir(const QString &sourceDirPath);
+ explicit TemporaryCopiedDir(const QString &sourceDirPath);
QString absolutePath(const QByteArray &relativePath) const;
private:
diff --git a/src/plugins/cpptools/cppvirtualfunctionassistprovider.cpp b/src/plugins/cpptools/cppvirtualfunctionassistprovider.cpp
index c07d88639e..6a93ffa464 100644
--- a/src/plugins/cpptools/cppvirtualfunctionassistprovider.cpp
+++ b/src/plugins/cpptools/cppvirtualfunctionassistprovider.cpp
@@ -70,7 +70,7 @@ protected:
bool eventFilter(QObject *o, QEvent *e) override
{
if (e->type() == QEvent::ShortcutOverride && m_sequence.count() == 1) {
- QKeyEvent *ke = static_cast<QKeyEvent *>(e);
+ auto ke = static_cast<const QKeyEvent*>(e);
const QKeySequence seq(ke->key());
if (seq == m_sequence) {
activateCurrentProposalItem();
@@ -124,7 +124,7 @@ public:
IAssistProposal *immediateProposal(const AssistInterface *) override
{
- QTC_ASSERT(m_params.function, return 0);
+ QTC_ASSERT(m_params.function, return nullptr);
auto *hintItem = new VirtualFunctionProposalItem(Utils::Link());
hintItem->setText(QCoreApplication::translate("VirtualFunctionsAssistProcessor",
@@ -141,19 +141,19 @@ public:
{
delete assistInterface;
- QTC_ASSERT(m_params.function, return 0);
- QTC_ASSERT(m_params.staticClass, return 0);
- QTC_ASSERT(!m_params.snapshot.isEmpty(), return 0);
+ QTC_ASSERT(m_params.function, return nullptr);
+ QTC_ASSERT(m_params.staticClass, return nullptr);
+ QTC_ASSERT(!m_params.snapshot.isEmpty(), return nullptr);
Class *functionsClass = m_finder.findMatchingClassDeclaration(m_params.function,
m_params.snapshot);
if (!functionsClass)
- return 0;
+ return nullptr;
const QList<Function *> overrides = FunctionUtils::overrides(
m_params.function, functionsClass, m_params.staticClass, m_params.snapshot);
if (overrides.isEmpty())
- return 0;
+ return nullptr;
QList<AssistProposalItemInterface *> items;
foreach (Function *func, overrides)
@@ -190,9 +190,7 @@ private:
mutable SymbolFinder m_finder;
};
-VirtualFunctionAssistProvider::VirtualFunctionAssistProvider()
-{
-}
+VirtualFunctionAssistProvider::VirtualFunctionAssistProvider() = default;
bool VirtualFunctionAssistProvider::configure(const Parameters &parameters)
{
diff --git a/src/plugins/cpptools/cppvirtualfunctionproposalitem.h b/src/plugins/cpptools/cppvirtualfunctionproposalitem.h
index 61d06b469c..d3d3d8da5c 100644
--- a/src/plugins/cpptools/cppvirtualfunctionproposalitem.h
+++ b/src/plugins/cpptools/cppvirtualfunctionproposalitem.h
@@ -37,7 +37,7 @@ class CPPTOOLS_EXPORT VirtualFunctionProposalItem final : public TextEditor::Ass
public:
VirtualFunctionProposalItem(const Utils::Link &link,
bool openInSplit = true);
- ~VirtualFunctionProposalItem() noexcept override {}
+ ~VirtualFunctionProposalItem() noexcept override = default;
void apply(TextEditor::TextDocumentManipulatorInterface &manipulator,
int basePosition) const override;
Utils::Link link() const { return m_link; } // Exposed for tests
diff --git a/src/plugins/cpptools/cppworkingcopy.cpp b/src/plugins/cpptools/cppworkingcopy.cpp
index cdd4ad257d..cee6ce2402 100644
--- a/src/plugins/cpptools/cppworkingcopy.cpp
+++ b/src/plugins/cpptools/cppworkingcopy.cpp
@@ -40,8 +40,6 @@
namespace CppTools {
-WorkingCopy::WorkingCopy()
-{
-}
+WorkingCopy::WorkingCopy() = default;
} // namespace CppTools
diff --git a/src/plugins/cpptools/cppworkingcopy.h b/src/plugins/cpptools/cppworkingcopy.h
index 6c370d5b68..6c9e74caa8 100644
--- a/src/plugins/cpptools/cppworkingcopy.h
+++ b/src/plugins/cpptools/cppworkingcopy.h
@@ -77,7 +77,7 @@ public:
{ return _elements.size(); }
private:
- typedef QHash<Utils::FileName, QPair<QByteArray, unsigned> > Table;
+ using Table = QHash<Utils::FileName, QPair<QByteArray, unsigned> >;
Table _elements;
};
diff --git a/src/plugins/cpptools/doxygengenerator.cpp b/src/plugins/cpptools/doxygengenerator.cpp
index 39e2e25275..4ae67721cf 100644
--- a/src/plugins/cpptools/doxygengenerator.cpp
+++ b/src/plugins/cpptools/doxygengenerator.cpp
@@ -136,8 +136,8 @@ QString DoxygenGenerator::generate(QTextCursor cursor,
QString DoxygenGenerator::generate(QTextCursor cursor, DeclarationAST *decl)
{
- SpecifierAST *spec = 0;
- DeclaratorAST *decltr = 0;
+ SpecifierAST *spec = nullptr;
+ DeclaratorAST *decltr = nullptr;
if (SimpleDeclarationAST *simpleDecl = decl->asSimpleDeclaration()) {
if (simpleDecl->declarator_list
&& simpleDecl->declarator_list->value) {
diff --git a/src/plugins/cpptools/editordocumenthandle.cpp b/src/plugins/cpptools/editordocumenthandle.cpp
index 9d999b4bec..51f3032893 100644
--- a/src/plugins/cpptools/editordocumenthandle.cpp
+++ b/src/plugins/cpptools/editordocumenthandle.cpp
@@ -34,9 +34,7 @@ namespace CppTools {
C++ editor document.
*/
-CppEditorDocumentHandle::~CppEditorDocumentHandle()
-{
-}
+CppEditorDocumentHandle::~CppEditorDocumentHandle() = default;
SendDocumentTracker &CppEditorDocumentHandle::sendTracker()
{
diff --git a/src/plugins/cpptools/followsymbolinterface.h b/src/plugins/cpptools/followsymbolinterface.h
index bde155c5f3..380e4e39ae 100644
--- a/src/plugins/cpptools/followsymbolinterface.h
+++ b/src/plugins/cpptools/followsymbolinterface.h
@@ -41,7 +41,7 @@ class CPPTOOLS_EXPORT FollowSymbolInterface
public:
using Link = Utils::Link;
- virtual ~FollowSymbolInterface() {}
+ virtual ~FollowSymbolInterface() = default;
virtual void findLink(const CursorInEditor &data,
Utils::ProcessLinkCallback &&processLinkCallback,
bool resolveTarget,
diff --git a/src/plugins/cpptools/functionutils.cpp b/src/plugins/cpptools/functionutils.cpp
index b8224923a0..fa82fece8a 100644
--- a/src/plugins/cpptools/functionutils.cpp
+++ b/src/plugins/cpptools/functionutils.cpp
@@ -47,7 +47,7 @@ static bool isVirtualFunction_helper(const Function *function,
enum { Unknown, False, True } res = Unknown;
if (firstVirtual)
- *firstVirtual = 0;
+ *firstVirtual = nullptr;
if (!function)
return false;
@@ -170,7 +170,7 @@ enum Virtuality
Virtual,
PureVirtual
};
-typedef QList<Virtuality> VirtualityList;
+using VirtualityList = QList<Virtuality>;
} // Internal namespace
} // CppTools namespace
@@ -191,7 +191,7 @@ void CppToolsPlugin::test_functionutils_virtualFunctions()
QCOMPARE(document->diagnosticMessages().size(), 0);
QVERIFY(document->translationUnit()->ast());
QList<const Function *> allFunctions;
- const Function *firstVirtual = 0;
+ const Function *firstVirtual = nullptr;
// Iterate through Function symbols
Snapshot snapshot;
@@ -236,7 +236,7 @@ void CppToolsPlugin::test_functionutils_virtualFunctions()
void CppToolsPlugin::test_functionutils_virtualFunctions_data()
{
- typedef QByteArray _;
+ using _ = QByteArray;
QTest::addColumn<QByteArray>("source");
QTest::addColumn<VirtualityList>("virtualityList");
QTest::addColumn<QList<int> >("firstVirtualList");
diff --git a/src/plugins/cpptools/includeutils.cpp b/src/plugins/cpptools/includeutils.cpp
index 029f6454d1..c57366332c 100644
--- a/src/plugins/cpptools/includeutils.cpp
+++ b/src/plugins/cpptools/includeutils.cpp
@@ -217,7 +217,7 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
if (m_includes.empty())
return findInsertLineForVeryFirstInclude(newLinesToPrepend, newLinesToAppend);
- typedef QList<IncludeGroup> IncludeGroups;
+ using IncludeGroups = QList<IncludeGroup>;
const IncludeGroups groupsNewline = IncludeGroup::detectIncludeGroupsByNewLines(m_includes);
const bool includeAtTop
@@ -241,8 +241,8 @@ int LineForNewIncludeDirective::operator()(const QString &newIncludeFileName,
= IncludeGroup::detectIncludeGroupsByIncludeType(bestMixedGroup.includes());
groupsMatchingIncludeType = getGroupsByIncludeType(groupsIncludeType, newIncludeType);
// Avoid extra new lines for include groups which are not separated by new lines
- newLinesToPrepend = 0;
- newLinesToAppend = 0;
+ newLinesToPrepend = nullptr;
+ newLinesToAppend = nullptr;
}
}
diff --git a/src/plugins/cpptools/includeutils.h b/src/plugins/cpptools/includeutils.h
index cadbac37b4..310bb251c8 100644
--- a/src/plugins/cpptools/includeutils.h
+++ b/src/plugins/cpptools/includeutils.h
@@ -39,8 +39,8 @@ QT_FORWARD_DECLARE_CLASS(QTextDocument)
namespace CppTools {
namespace IncludeUtils {
-typedef CPlusPlus::Document::Include Include;
-typedef CPlusPlus::Client::IncludeType IncludeType;
+using Include = CPlusPlus::Document::Include;
+using IncludeType = CPlusPlus::Client::IncludeType;
class CPPTOOLS_EXPORT IncludeGroup
{
@@ -54,7 +54,7 @@ public:
CPlusPlus::Client::IncludeType includeType);
public:
- IncludeGroup(const QList<Include> &includes) : m_includes(includes) {}
+ explicit IncludeGroup(const QList<Include> &includes) : m_includes(includes) {}
QList<Include> includes() const { return m_includes; }
Include first() const { return m_includes.first(); }
diff --git a/src/plugins/cpptools/indexitem.h b/src/plugins/cpptools/indexitem.h
index 4370bca422..bb57b0c850 100644
--- a/src/plugins/cpptools/indexitem.h
+++ b/src/plugins/cpptools/indexitem.h
@@ -39,7 +39,7 @@ class CPPTOOLS_EXPORT IndexItem
{
Q_DISABLE_COPY(IndexItem)
- IndexItem() {}
+ IndexItem() = default;
public:
enum ItemType {
@@ -52,7 +52,7 @@ public:
};
public:
- typedef QSharedPointer<IndexItem> Ptr;
+ using Ptr = QSharedPointer<IndexItem>;
static Ptr create(const QString &symbolName,
const QString &symbolType,
const QString &symbolScope,
@@ -94,7 +94,7 @@ public:
Recurse, /// continues traversal with the children
};
- typedef std::function<VisitorResult (const IndexItem::Ptr &)> Visitor;
+ using Visitor = std::function<VisitorResult (const IndexItem::Ptr &)>;
VisitorResult visitAllChildren(Visitor callback) const
{
diff --git a/src/plugins/cpptools/insertionpointlocator.cpp b/src/plugins/cpptools/insertionpointlocator.cpp
index 0fe27dbcc1..b73d672306 100644
--- a/src/plugins/cpptools/insertionpointlocator.cpp
+++ b/src/plugins/cpptools/insertionpointlocator.cpp
@@ -58,17 +58,10 @@ static int ordering(InsertionPointLocator::AccessSpec xsSpec)
struct AccessRange
{
- unsigned start;
- unsigned end;
- InsertionPointLocator::AccessSpec xsSpec;
- unsigned colonToken;
-
- AccessRange()
- : start(0)
- , end(0)
- , xsSpec(InsertionPointLocator::Invalid)
- , colonToken(0)
- {}
+ unsigned start = 0;
+ unsigned end = 0;
+ InsertionPointLocator::AccessSpec xsSpec = InsertionPointLocator::Invalid;
+ unsigned colonToken = 0;
AccessRange(unsigned start, unsigned end, InsertionPointLocator::AccessSpec xsSpec, unsigned colonToken)
: start(start)
@@ -107,7 +100,7 @@ public:
protected:
using ASTVisitor::visit;
- bool visit(ClassSpecifierAST *ast)
+ bool visit(ClassSpecifierAST *ast) override
{
if (!ast->lbrace_token || !ast->rbrace_token)
return true;
@@ -358,7 +351,7 @@ class FindMethodDefinitionInsertPoint : protected ASTVisitor
HighestValue<int, unsigned> _bestToken;
public:
- FindMethodDefinitionInsertPoint(TranslationUnit *translationUnit)
+ explicit FindMethodDefinitionInsertPoint(TranslationUnit *translationUnit)
: ASTVisitor(translationUnit)
{}
@@ -388,12 +381,12 @@ public:
}
protected:
- bool preVisit(AST *ast)
+ bool preVisit(AST *ast) override
{
return ast->asNamespace() || ast->asTranslationUnit() || ast->asLinkageBody();
}
- bool visit(NamespaceAST *ast)
+ bool visit(NamespaceAST *ast) override
{
if (_currentDepth >= _namespaceNames.size())
return false;
@@ -423,7 +416,7 @@ class FindFunctionDefinition : protected ASTVisitor
unsigned _line = 0;
unsigned _column = 0;
public:
- FindFunctionDefinition(TranslationUnit *translationUnit)
+ explicit FindFunctionDefinition(TranslationUnit *translationUnit)
: ASTVisitor(translationUnit)
{
}
@@ -438,7 +431,7 @@ public:
}
protected:
- bool preVisit(AST *ast)
+ bool preVisit(AST *ast) override
{
if (_result)
return false;
@@ -452,7 +445,7 @@ protected:
return true;
}
- bool visit(FunctionDefinitionAST *ast)
+ bool visit(FunctionDefinitionAST *ast) override
{
_result = ast;
return false;
@@ -464,13 +457,13 @@ protected:
static Declaration *isNonVirtualFunctionDeclaration(Symbol *s)
{
if (!s)
- return 0;
+ return nullptr;
Declaration *declaration = s->asDeclaration();
if (!declaration)
- return 0;
+ return nullptr;
Function *type = s->type()->asFunctionType();
if (!type || type->isPureVirtual())
- return 0;
+ return nullptr;
return declaration;
}
@@ -497,9 +490,9 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
// scan preceding declarations for a function declaration (and see if it is defined)
SymbolFinder symbolFinder;
- Function *definitionFunction = 0;
+ Function *definitionFunction = nullptr;
QString prefix, suffix;
- Declaration *surroundingFunctionDecl = 0;
+ Declaration *surroundingFunctionDecl = nullptr;
for (int i = declIndex - 1; i >= 0; --i) {
Symbol *s = klass->memberAt(i);
if (s->isGenerated() || !(surroundingFunctionDecl = isNonVirtualFunctionDeclaration(s)))
@@ -512,7 +505,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
prefix = QLatin1String("\n\n");
break;
}
- definitionFunction = 0;
+ definitionFunction = nullptr;
}
}
if (!definitionFunction) {
@@ -530,7 +523,7 @@ static InsertionLocation nextToSurroundingDefinitions(Symbol *declaration,
suffix = QLatin1String("\n\n");
break;
}
- definitionFunction = 0;
+ definitionFunction = nullptr;
}
}
}
diff --git a/src/plugins/cpptools/insertionpointlocator.h b/src/plugins/cpptools/insertionpointlocator.h
index 434af1f0e7..480d1b592b 100644
--- a/src/plugins/cpptools/insertionpointlocator.h
+++ b/src/plugins/cpptools/insertionpointlocator.h
@@ -87,7 +87,7 @@ public:
static QString accessSpecToString(InsertionPointLocator::AccessSpec xsSpec);
public:
- InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);
+ explicit InsertionPointLocator(const CppRefactoringChanges &refactoringChanges);
InsertionLocation methodDeclarationInClass(const QString &fileName,
const CPlusPlus::Class *clazz,
diff --git a/src/plugins/cpptools/modelmanagertesthelper.cpp b/src/plugins/cpptools/modelmanagertesthelper.cpp
index 0df295ba95..83e27fb237 100644
--- a/src/plugins/cpptools/modelmanagertesthelper.cpp
+++ b/src/plugins/cpptools/modelmanagertesthelper.cpp
@@ -85,7 +85,7 @@ void ModelManagerTestHelper::cleanup()
ModelManagerTestHelper::Project *ModelManagerTestHelper::createProject(const QString &name)
{
- TestProject *tp = new TestProject(name, this);
+ auto tp = new TestProject(name, this);
emit projectAdded(tp);
return tp;
}
diff --git a/src/plugins/cpptools/modelmanagertesthelper.h b/src/plugins/cpptools/modelmanagertesthelper.h
index 51c947af1d..9fe887006d 100644
--- a/src/plugins/cpptools/modelmanagertesthelper.h
+++ b/src/plugins/cpptools/modelmanagertesthelper.h
@@ -53,7 +53,7 @@ class CPPTOOLS_EXPORT ModelManagerTestHelper: public QObject
Q_OBJECT
public:
- typedef ProjectExplorer::Project Project;
+ using Project = ProjectExplorer::Project;
explicit ModelManagerTestHelper(QObject *parent = nullptr,
bool testOnlyForCleanedProjects = true);
@@ -70,8 +70,8 @@ public:
void waitForFinishedGc();
signals:
- void aboutToRemoveProject(ProjectExplorer::Project *project);
- void projectAdded(ProjectExplorer::Project*);
+ void aboutToRemoveProject(Project *project);
+ void projectAdded(Project*);
public slots:
void sourceFilesRefreshed(const QSet<QString> &files);
diff --git a/src/plugins/cpptools/projectinfo.h b/src/plugins/cpptools/projectinfo.h
index 4cf43d0ff6..c934bda2d5 100644
--- a/src/plugins/cpptools/projectinfo.h
+++ b/src/plugins/cpptools/projectinfo.h
@@ -87,7 +87,7 @@ class CPPTOOLS_EXPORT ProjectInfo
{
public:
ProjectInfo() = default;
- ProjectInfo(QPointer<ProjectExplorer::Project> project);
+ explicit ProjectInfo(QPointer<ProjectExplorer::Project> project);
bool isValid() const;
diff --git a/src/plugins/cpptools/refactoringengineinterface.h b/src/plugins/cpptools/refactoringengineinterface.h
index d47855b686..93f365a24b 100644
--- a/src/plugins/cpptools/refactoringengineinterface.h
+++ b/src/plugins/cpptools/refactoringengineinterface.h
@@ -59,7 +59,7 @@ public:
using RenameCallback = ClangBackEnd::RefactoringClientInterface::RenameCallback;
using Link = Utils::Link;
- virtual ~RefactoringEngineInterface() {}
+ virtual ~RefactoringEngineInterface() = default;
virtual void startLocalRenaming(const CursorInEditor &data,
CppTools::ProjectPart *projectPart,
diff --git a/src/plugins/cpptools/searchsymbols.cpp b/src/plugins/cpptools/searchsymbols.cpp
index 9ec44a3ba7..6adb437bf8 100644
--- a/src/plugins/cpptools/searchsymbols.cpp
+++ b/src/plugins/cpptools/searchsymbols.cpp
@@ -37,8 +37,8 @@ using namespace CPlusPlus;
namespace CppTools {
-typedef Utils::ScopedSwap<IndexItem::Ptr> ScopedIndexItemPtr;
-typedef Utils::ScopedSwap<QString> ScopedScope;
+using ScopedIndexItemPtr = Utils::ScopedSwap<IndexItem::Ptr>;
+using ScopedScope = Utils::ScopedSwap<QString>;
SearchSymbols::SymbolTypes SearchSymbols::AllTypes =
SymbolSearcher::Classes
diff --git a/src/plugins/cpptools/semantichighlighter.cpp b/src/plugins/cpptools/semantichighlighter.cpp
index 8d49cea122..5c7c8110ca 100644
--- a/src/plugins/cpptools/semantichighlighter.cpp
+++ b/src/plugins/cpptools/semantichighlighter.cpp
@@ -47,7 +47,6 @@ namespace CppTools {
SemanticHighlighter::SemanticHighlighter(TextDocument *baseTextDocument)
: QObject(baseTextDocument)
, m_baseTextDocument(baseTextDocument)
- , m_revision(0)
{
QTC_CHECK(m_baseTextDocument);
updateFormatMapFromFontSettings();
@@ -113,7 +112,7 @@ void SemanticHighlighter::onHighlighterFinished()
void SemanticHighlighter::connectWatcher()
{
- typedef QFutureWatcher<HighlightingResult> Watcher;
+ using Watcher = QFutureWatcher<HighlightingResult>;
connect(m_watcher.data(), &Watcher::resultsReadyAt,
this, &SemanticHighlighter::onHighlighterResultAvailable);
connect(m_watcher.data(), &Watcher::finished,
@@ -122,7 +121,7 @@ void SemanticHighlighter::connectWatcher()
void SemanticHighlighter::disconnectWatcher()
{
- typedef QFutureWatcher<HighlightingResult> Watcher;
+ using Watcher = QFutureWatcher<HighlightingResult>;
disconnect(m_watcher.data(), &Watcher::resultsReadyAt,
this, &SemanticHighlighter::onHighlighterResultAvailable);
disconnect(m_watcher.data(), &Watcher::finished,
diff --git a/src/plugins/cpptools/semantichighlighter.h b/src/plugins/cpptools/semantichighlighter.h
index 3824d244bd..5b42982cb6 100644
--- a/src/plugins/cpptools/semantichighlighter.h
+++ b/src/plugins/cpptools/semantichighlighter.h
@@ -61,7 +61,7 @@ public:
VirtualFunctionDeclarationUse,
};
- typedef std::function<QFuture<TextEditor::HighlightingResult> ()> HighlightingRunner;
+ using HighlightingRunner = std::function<QFuture<TextEditor::HighlightingResult> ()>;
public:
explicit SemanticHighlighter(TextEditor::TextDocument *baseTextDocument);
@@ -84,7 +84,7 @@ private:
private:
TextEditor::TextDocument *m_baseTextDocument;
- unsigned m_revision;
+ unsigned m_revision = 0;
QScopedPointer<QFutureWatcher<TextEditor::HighlightingResult>> m_watcher;
QHash<int, QTextCharFormat> m_formatMap;
diff --git a/src/plugins/cpptools/stringtable.cpp b/src/plugins/cpptools/stringtable.cpp
index 25be4d035c..1be6b6ce25 100644
--- a/src/plugins/cpptools/stringtable.cpp
+++ b/src/plugins/cpptools/stringtable.cpp
@@ -57,7 +57,7 @@ public:
StringTablePrivate &m_stringTable;
public:
- GCRunner(StringTablePrivate &stringTable): m_stringTable(stringTable) {}
+ explicit GCRunner(StringTablePrivate &stringTable): m_stringTable(stringTable) {}
void run() override { m_stringTable.GC(); }
} m_gcRunner;
diff --git a/src/plugins/cpptools/symbolfinder.cpp b/src/plugins/cpptools/symbolfinder.cpp
index 763fe42dcd..1e7cf37c58 100644
--- a/src/plugins/cpptools/symbolfinder.cpp
+++ b/src/plugins/cpptools/symbolfinder.cpp
@@ -47,14 +47,13 @@ namespace {
class FindMatchingDefinition: public SymbolVisitor
{
- Symbol *_declaration;
- const OperatorNameId *_oper;
+ Symbol *_declaration = nullptr;
+ const OperatorNameId *_oper = nullptr;
QList<Function *> _result;
public:
- FindMatchingDefinition(Symbol *declaration)
+ explicit FindMatchingDefinition(Symbol *declaration)
: _declaration(declaration)
- , _oper(0)
{
if (_declaration->name())
_oper = _declaration->name()->asOperatorNameId();
@@ -89,8 +88,7 @@ public:
static const int kMaxCacheSize = 10;
-SymbolFinder::SymbolFinder()
-{}
+SymbolFinder::SymbolFinder() = default;
// strict means the returned symbol has to match exactly,
// including argument count, argument types, constness and volatileness.
@@ -99,21 +97,21 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
bool strict)
{
if (!declaration)
- return 0;
+ return nullptr;
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
Document::Ptr thisDocument = snapshot.document(declFile);
if (!thisDocument) {
qWarning() << "undefined document:" << declaration->fileName();
- return 0;
+ return nullptr;
}
Function *declarationTy = declaration->type()->asFunctionType();
if (!declarationTy) {
qWarning() << "not a function:" << declaration->fileName()
<< declaration->line() << declaration->column();
- return 0;
+ return nullptr;
}
foreach (const QString &fileName, fileIterationOrder(declFile, snapshot)) {
@@ -169,7 +167,7 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
else if (!strict && viableFunctions.length() == 1)
return viableFunctions.first();
- Function *best = 0;
+ Function *best = nullptr;
foreach (Function *fun, viableFunctions) {
if (!(fun->unqualifiedName()
@@ -206,13 +204,13 @@ Function *SymbolFinder::findMatchingDefinition(Symbol *declaration,
}
}
- return 0;
+ return nullptr;
}
Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Snapshot &snapshot)
{
if (!declaration->identifier())
- return 0;
+ return nullptr;
QString declFile = QString::fromUtf8(declaration->fileName(), declaration->fileNameLength());
@@ -239,7 +237,7 @@ Class *SymbolFinder::findMatchingClassDeclaration(Symbol *declaration, const Sna
}
}
- return 0;
+ return nullptr;
}
static void findDeclarationOfSymbol(Symbol *s,
@@ -272,13 +270,13 @@ void SymbolFinder::findMatchingDeclaration(const LookupContext &context,
Scope *enclosingScope = functionType->enclosingScope();
while (!(enclosingScope->isNamespace() || enclosingScope->isClass()))
enclosingScope = enclosingScope->enclosingScope();
- QTC_ASSERT(enclosingScope != 0, return);
+ QTC_ASSERT(enclosingScope != nullptr, return);
const Name *functionName = functionType->name();
if (!functionName)
return;
- ClassOrNamespace *binding = 0;
+ ClassOrNamespace *binding = nullptr;
const QualifiedNameId *qName = functionName->asQualifiedNameId();
if (qName) {
if (qName->base())
diff --git a/src/plugins/cpptools/symbolsearcher_test.cpp b/src/plugins/cpptools/symbolsearcher_test.cpp
index dc71fa1562..624973cbf4 100644
--- a/src/plugins/cpptools/symbolsearcher_test.cpp
+++ b/src/plugins/cpptools/symbolsearcher_test.cpp
@@ -45,12 +45,13 @@ QTC_DECLARE_MYTESTDATADIR("../../../tests/cppsymbolsearcher/")
inline QString _(const QByteArray &ba) { return QString::fromLatin1(ba, ba.size()); }
+class ResultData;
+using ResultDataList = QList<ResultData>;
+
class ResultData
{
public:
- typedef QList<ResultData> ResultDataList;
-
- ResultData() {}
+ ResultData() = default;
ResultData(const QString &symbolName, const QString &scope)
: m_symbolName(symbolName), m_scope(scope) {}
@@ -82,8 +83,6 @@ public:
QString m_scope;
};
-typedef ResultData::ResultDataList ResultDataList;
-
class SymbolSearcherTestCase : public Tests::TestCase
{
public:
@@ -92,8 +91,7 @@ public:
CppIndexingSupport *indexingSupportToUse,
const SymbolSearcher::Parameters &searchParameters,
const ResultDataList &expectedResults)
- : m_indexingSupportToRestore(0)
- , m_indexingSupportToUse(indexingSupportToUse)
+ : m_indexingSupportToUse(indexingSupportToUse)
{
QVERIFY(succeededSoFar());
@@ -119,8 +117,8 @@ public:
}
private:
- CppIndexingSupport *m_indexingSupportToRestore;
- CppIndexingSupport *m_indexingSupportToUse;
+ CppIndexingSupport *m_indexingSupportToRestore = nullptr;
+ CppIndexingSupport *m_indexingSupportToUse = nullptr;
};
} // anonymous namespace
@@ -166,7 +164,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
// Check All Symbol Types
searchParameters = SymbolSearcher::Parameters();
searchParameters.text = _("");
- searchParameters.flags = 0;
+ searchParameters.flags = nullptr;
searchParameters.types = SearchSymbols::AllTypes;
searchParameters.scope = SymbolSearcher::SearchGlobal;
QTest::newRow("BuiltinSymbolSearcher::AllTypes")
@@ -220,7 +218,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
// Check Classes
searchParameters = SymbolSearcher::Parameters();
searchParameters.text = _("myclass");
- searchParameters.flags = 0;
+ searchParameters.flags = nullptr;
searchParameters.types = SymbolSearcher::Classes;
searchParameters.scope = SymbolSearcher::SearchGlobal;
QTest::newRow("BuiltinSymbolSearcher::Classes")
@@ -235,7 +233,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
// Check Functions
searchParameters = SymbolSearcher::Parameters();
searchParameters.text = _("fun");
- searchParameters.flags = 0;
+ searchParameters.flags = nullptr;
searchParameters.types = SymbolSearcher::Functions;
searchParameters.scope = SymbolSearcher::SearchGlobal;
QTest::newRow("BuiltinSymbolSearcher::Functions")
@@ -260,7 +258,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
// Check Enums
searchParameters = SymbolSearcher::Parameters();
searchParameters.text = _("enum");
- searchParameters.flags = 0;
+ searchParameters.flags = nullptr;
searchParameters.types = SymbolSearcher::Enums;
searchParameters.scope = SymbolSearcher::SearchGlobal;
QTest::newRow("BuiltinSymbolSearcher::Enums")
@@ -275,7 +273,7 @@ void CppToolsPlugin::test_builtinsymbolsearcher_data()
// Check Declarations
searchParameters = SymbolSearcher::Parameters();
searchParameters.text = _("myvar");
- searchParameters.flags = 0;
+ searchParameters.flags = nullptr;
searchParameters.types = SymbolSearcher::Declarations;
searchParameters.scope = SymbolSearcher::SearchGlobal;
QTest::newRow("BuiltinSymbolSearcher::Declarations")
diff --git a/src/plugins/cpptools/symbolsfindfilter.cpp b/src/plugins/cpptools/symbolsfindfilter.cpp
index 58e0ba11d3..1fd758a3fa 100644
--- a/src/plugins/cpptools/symbolsfindfilter.cpp
+++ b/src/plugins/cpptools/symbolsfindfilter.cpp
@@ -84,7 +84,7 @@ bool SymbolsFindFilter::isEnabled() const
void SymbolsFindFilter::cancel()
{
- SearchResult *search = qobject_cast<SearchResult *>(sender());
+ auto search = qobject_cast<SearchResult *>(sender());
QTC_ASSERT(search, return);
QFutureWatcher<SearchResultItem> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
@@ -93,7 +93,7 @@ void SymbolsFindFilter::cancel()
void SymbolsFindFilter::setPaused(bool paused)
{
- SearchResult *search = qobject_cast<SearchResult *>(sender());
+ auto search = qobject_cast<SearchResult *>(sender());
QTC_ASSERT(search, return);
QFutureWatcher<SearchResultItem> *watcher = m_watchers.key(search);
QTC_ASSERT(watcher, return);
@@ -132,7 +132,7 @@ void SymbolsFindFilter::startSearch(SearchResult *search)
projectFileNames += Utils::transform(project->files(ProjectExplorer::Project::AllFiles), &Utils::FileName::toString).toSet();
}
- QFutureWatcher<SearchResultItem> *watcher = new QFutureWatcher<SearchResultItem>();
+ auto watcher = new QFutureWatcher<SearchResultItem>;
m_watchers.insert(watcher, search);
connect(watcher, &QFutureWatcherBase::finished,
this, &SymbolsFindFilter::finish);
@@ -150,8 +150,7 @@ void SymbolsFindFilter::startSearch(SearchResult *search)
void SymbolsFindFilter::addResults(int begin, int end)
{
- QFutureWatcher<SearchResultItem> *watcher =
- static_cast<QFutureWatcher<SearchResultItem> *>(sender());
+ auto watcher = static_cast<QFutureWatcher<SearchResultItem> *>(sender());
SearchResult *search = m_watchers.value(watcher);
if (!search) {
// search was removed from search history while the search is running
@@ -166,8 +165,7 @@ void SymbolsFindFilter::addResults(int begin, int end)
void SymbolsFindFilter::finish()
{
- QFutureWatcher<SearchResultItem> *watcher =
- static_cast<QFutureWatcher<SearchResultItem> *>(sender());
+ auto watcher = static_cast<QFutureWatcher<SearchResultItem> *>(sender());
SearchResult *search = m_watchers.value(watcher);
if (search)
search->finishSearch(watcher->isCanceled());
@@ -227,7 +225,7 @@ void SymbolsFindFilter::onAllTasksFinished(Id type)
void SymbolsFindFilter::searchAgain()
{
- SearchResult *search = qobject_cast<SearchResult *>(sender());
+ auto search = qobject_cast<SearchResult *>(sender());
QTC_ASSERT(search, return);
search->restart();
startSearch(search);
@@ -263,11 +261,11 @@ SymbolsFindFilterConfigWidget::SymbolsFindFilterConfigWidget(SymbolsFindFilter *
connect(m_filter, &SymbolsFindFilter::symbolsToSearchChanged,
this, &SymbolsFindFilterConfigWidget::getState);
- QGridLayout *layout = new QGridLayout(this);
+ auto layout = new QGridLayout(this);
setLayout(layout);
layout->setMargin(0);
- QLabel *typeLabel = new QLabel(tr("Types:"));
+ auto typeLabel = new QLabel(tr("Types:"));
layout->addWidget(typeLabel, 0, 0);
m_typeClasses = new QCheckBox(tr("Classes"));
diff --git a/src/plugins/cpptools/symbolsfindfilter.h b/src/plugins/cpptools/symbolsfindfilter.h
index b4e72b2a32..e93ad48050 100644
--- a/src/plugins/cpptools/symbolsfindfilter.h
+++ b/src/plugins/cpptools/symbolsfindfilter.h
@@ -48,20 +48,20 @@ class SymbolsFindFilter : public Core::IFindFilter
Q_OBJECT
public:
- typedef SymbolSearcher::SearchScope SearchScope;
+ using SearchScope = SymbolSearcher::SearchScope;
public:
explicit SymbolsFindFilter(CppModelManager *manager);
- QString id() const;
- QString displayName() const;
- bool isEnabled() const;
+ QString id() const override;
+ QString displayName() const override;
+ bool isEnabled() const override;
- void findAll(const QString &txt, Core::FindFlags findFlags);
+ void findAll(const QString &txt, Core::FindFlags findFlags) override;
- QWidget *createConfigWidget();
- void writeSettings(QSettings *settings);
- void readSettings(QSettings *settings);
+ QWidget *createConfigWidget() override;
+ void writeSettings(QSettings *settings) override;
+ void readSettings(QSettings *settings) override;
void setSymbolsToSearch(const SearchSymbols::SymbolTypes &types) { m_symbolsToSearch = types; }
SearchSymbols::SymbolTypes symbolsToSearch() const { return m_symbolsToSearch; }
@@ -99,7 +99,7 @@ class SymbolsFindFilterConfigWidget : public QWidget
{
Q_OBJECT
public:
- SymbolsFindFilterConfigWidget(SymbolsFindFilter *filter);
+ explicit SymbolsFindFilterConfigWidget(SymbolsFindFilter *filter);
private:
void setState() const;
diff --git a/src/plugins/cpptools/typehierarchybuilder.cpp b/src/plugins/cpptools/typehierarchybuilder.cpp
index b44517e14c..e54b546068 100644
--- a/src/plugins/cpptools/typehierarchybuilder.cpp
+++ b/src/plugins/cpptools/typehierarchybuilder.cpp
@@ -42,7 +42,7 @@ QString unqualifyName(const QString &qualifiedName)
class DerivedHierarchyVisitor : public CPlusPlus::SymbolVisitor
{
public:
- DerivedHierarchyVisitor(const QString &qualifiedName)
+ explicit DerivedHierarchyVisitor(const QString &qualifiedName)
: _qualifiedName(qualifiedName)
, _unqualifiedName(unqualifyName(qualifiedName))
{}
@@ -119,8 +119,7 @@ bool DerivedHierarchyVisitor::visit(CPlusPlus::Class *symbol)
} // namespace
-TypeHierarchy::TypeHierarchy() : _symbol(0)
-{}
+TypeHierarchy::TypeHierarchy() = default;
TypeHierarchy::TypeHierarchy(CPlusPlus::Symbol *symbol) : _symbol(symbol)
{}
diff --git a/src/plugins/cpptools/typehierarchybuilder.h b/src/plugins/cpptools/typehierarchybuilder.h
index 055794687e..fc1a628515 100644
--- a/src/plugins/cpptools/typehierarchybuilder.h
+++ b/src/plugins/cpptools/typehierarchybuilder.h
@@ -43,7 +43,7 @@ class CPPTOOLS_EXPORT TypeHierarchy
public:
TypeHierarchy();
- TypeHierarchy(CPlusPlus::Symbol *symbol);
+ explicit TypeHierarchy(CPlusPlus::Symbol *symbol);
CPlusPlus::Symbol *symbol() const;
const QList<TypeHierarchy> &hierarchy() const;
@@ -52,7 +52,7 @@ public:
{ return _symbol == other._symbol; }
private:
- CPlusPlus::Symbol *_symbol;
+ CPlusPlus::Symbol *_symbol = nullptr;
QList<TypeHierarchy> _hierarchy;
};
diff --git a/src/plugins/cpptools/typehierarchybuilder_test.cpp b/src/plugins/cpptools/typehierarchybuilder_test.cpp
index 4bba86ec67..0a4ac54568 100644
--- a/src/plugins/cpptools/typehierarchybuilder_test.cpp
+++ b/src/plugins/cpptools/typehierarchybuilder_test.cpp
@@ -40,8 +40,9 @@
using namespace CPlusPlus;
using namespace CppTools;
using namespace CppTools::Internal;
+using Tests::TestDocument;
-Q_DECLARE_METATYPE(QList<Tests::TestDocument>)
+Q_DECLARE_METATYPE(QList<TestDocument>)
namespace {
@@ -64,7 +65,7 @@ QString toString(const TypeHierarchy &hierarchy, int indent = 0)
class FindFirstClassInDocument: private SymbolVisitor
{
public:
- FindFirstClassInDocument() : m_clazz(0) {}
+ FindFirstClassInDocument() = default;
Class *operator()(const Document::Ptr &document)
{
@@ -73,7 +74,7 @@ public:
}
private:
- bool preVisit(Symbol *symbol)
+ bool preVisit(Symbol *symbol) override
{
if (m_clazz)
return false;
@@ -87,13 +88,13 @@ private:
}
private:
- Class *m_clazz;
+ Class *m_clazz = nullptr;
};
class TypeHierarchyBuilderTestCase : public Tests::TestCase
{
public:
- TypeHierarchyBuilderTestCase(const QList<Tests::TestDocument> &documents,
+ TypeHierarchyBuilderTestCase(const QList<TestDocument> &documents,
const QString &expectedHierarchy)
{
QVERIFY(succeededSoFar());
@@ -101,14 +102,14 @@ public:
Tests::TemporaryDir temporaryDir;
QVERIFY(temporaryDir.isValid());
- QList<Tests::TestDocument> documents_ = documents;
+ QList<TestDocument> documents_ = documents;
// Write files
QSet<QString> filePaths;
- for (int i = 0, size = documents_.size(); i < size; ++i) {
- documents_[i].setBaseDirectory(temporaryDir.path());
- QVERIFY(documents_[i].writeToDisk());
- filePaths << documents_[i].filePath();
+ for (auto &document : documents_) {
+ document.setBaseDirectory(temporaryDir.path());
+ QVERIFY(document.writeToDisk());
+ filePaths << document.filePath();
}
// Parse files
@@ -137,11 +138,9 @@ public:
void CppToolsPlugin::test_typehierarchy_data()
{
- QTest::addColumn<QList<Tests::TestDocument> >("documents");
+ QTest::addColumn<QList<TestDocument> >("documents");
QTest::addColumn<QString>("expectedHierarchy");
- typedef Tests::TestDocument TestDocument;
-
QTest::newRow("basic-single-document")
<< (QList<TestDocument>()
<< TestDocument("a.h",
@@ -184,7 +183,7 @@ void CppToolsPlugin::test_typehierarchy_data()
void CppToolsPlugin::test_typehierarchy()
{
- QFETCH(QList<Tests::TestDocument>, documents);
+ QFETCH(QList<TestDocument>, documents);
QFETCH(QString, expectedHierarchy);
TypeHierarchyBuilderTestCase(documents, expectedHierarchy);
diff --git a/src/plugins/cpptools/usages.h b/src/plugins/cpptools/usages.h
index 60d29ddbcd..1e0f502c5e 100644
--- a/src/plugins/cpptools/usages.h
+++ b/src/plugins/cpptools/usages.h
@@ -37,7 +37,7 @@ namespace CppTools {
class Usage
{
public:
- Usage() {}
+ Usage() = default;
Usage(Utils::SmallStringView path, int line, int column)
: path(QString::fromUtf8(path.data(), int(path.size()))),
line(line),