CppEditor: Fix uninitialized value warnings

...from coverity scan.

Change-Id: I1b1fb919e77f1407fe2e4319392c28413a296493
Reviewed-by: Robert Loehning <robert.loehning@qt.io>
This commit is contained in:
Nikolai Kosjar
2017-06-01 13:32:23 +02:00
parent a3a62e78f7
commit 39dea09794
9 changed files with 40 additions and 60 deletions

View File

@@ -260,17 +260,6 @@ void FunctionDeclDefLinkFinder::startFindLinkAt(
m_watcher->setFuture(Utils::runAsync(findLinkHelper, result, refactoringChanges));
}
FunctionDeclDefLink::FunctionDeclDefLink()
{
hasMarker = false;
targetLine = 0;
targetColumn = 0;
sourceFunction = 0;
targetFunction = 0;
targetDeclaration = 0;
targetFunctionDeclarator = 0;
}
bool FunctionDeclDefLink::isValid() const
{
return !linkSelection.isNull();

View File

@@ -68,6 +68,7 @@ class FunctionDeclDefLink
{
Q_DECLARE_TR_FUNCTIONS(CppEditor::Internal::FunctionDeclDefLink)
Q_DISABLE_COPY(FunctionDeclDefLink)
FunctionDeclDefLink() = default;
public:
class Marker {};
@@ -88,26 +89,24 @@ public:
// The 'source' prefix denotes information about the original state
// of the function before the user did any edits.
CPlusPlus::Document::Ptr sourceDocument;
CPlusPlus::Function *sourceFunction;
CPlusPlus::DeclarationAST *sourceDeclaration;
CPlusPlus::FunctionDeclaratorAST *sourceFunctionDeclarator;
CPlusPlus::Function *sourceFunction = nullptr;
CPlusPlus::DeclarationAST *sourceDeclaration = nullptr;
CPlusPlus::FunctionDeclaratorAST *sourceFunctionDeclarator = nullptr;
// The 'target' prefix denotes information about the remote declaration matching
// the 'source' declaration, where we will try to apply the user changes.
// 1-based line and column
unsigned targetLine;
unsigned targetColumn;
unsigned targetLine = 0;
unsigned targetColumn = 0;
QString targetInitial;
CppTools::CppRefactoringFileConstPtr targetFile;
CPlusPlus::Function *targetFunction;
CPlusPlus::DeclarationAST *targetDeclaration;
CPlusPlus::FunctionDeclaratorAST *targetFunctionDeclarator;
CPlusPlus::Function *targetFunction = nullptr;
CPlusPlus::DeclarationAST *targetDeclaration = nullptr;
CPlusPlus::FunctionDeclaratorAST *targetFunctionDeclarator = nullptr;
private:
FunctionDeclDefLink();
bool hasMarker;
bool hasMarker = false;
friend class FunctionDeclDefLinkFinder;
};

View File

@@ -197,12 +197,12 @@ public:
Qt::ItemFlags flags() const;
Qt::CheckState checkState() const { return checked ? Qt::Checked : Qt::Unchecked; }
const Function *function;
InsertionPointLocator::AccessSpec accessSpec;
bool reimplemented;
bool alreadyFound;
bool checked;
FunctionItem *nextOverride;
const Function *function = nullptr;
InsertionPointLocator::AccessSpec accessSpec = InsertionPointLocator::Invalid;
bool reimplemented = false;
bool alreadyFound = false;
bool checked = false;
FunctionItem *nextOverride = nullptr;
private:
QString name;
@@ -256,9 +256,6 @@ void ClassItem::removeFunction(int row)
FunctionItem::FunctionItem(const Function *func, const QString &functionName, ClassItem *parent) :
InsertVirtualMethodsItem(parent),
function(func),
reimplemented(false),
alreadyFound(false),
checked(false),
nextOverride(this)
{
name = functionName;

View File

@@ -824,9 +824,9 @@ public:
ASTMatcher matcher;
ASTPatternBuilder mk;
ConditionAST *condition;
IfStatementAST *pattern;
CoreDeclaratorAST *core;
ConditionAST *condition = nullptr;
IfStatementAST *pattern = nullptr;
CoreDeclaratorAST *core = nullptr;
};
} // anonymous namespace
@@ -901,9 +901,9 @@ public:
ASTMatcher matcher;
ASTPatternBuilder mk;
ConditionAST *condition;
WhileStatementAST *pattern;
CoreDeclaratorAST *core;
ConditionAST *condition = nullptr;
WhileStatementAST *pattern = nullptr;
CoreDeclaratorAST *core = nullptr;
};
} // anonymous namespace
@@ -2235,7 +2235,7 @@ public:
}
Overview prettyPrint;
bool foundCaseStatementLevel;
bool foundCaseStatementLevel = false;
QStringList values;
TypeOfExpression typeOfExpression;
Document::Ptr document;

View File

@@ -87,11 +87,7 @@ namespace Internal {
// CppTypeHierarchyWidget
CppTypeHierarchyWidget::CppTypeHierarchyWidget() :
QWidget(0),
m_treeView(0),
m_model(0),
m_delegate(0),
m_noTypeHierarchyAvailableLabel(0)
QWidget(0)
{
m_inspectedClass = new TextEditor::TextEditorLinkLabel(this);
m_inspectedClass->setMargin(5);

View File

@@ -87,14 +87,14 @@ private:
void clearTypeHierarchy();
void onItemActivated(const QModelIndex &index);
CppEditorWidget *m_cppEditor;
Utils::NavigationTreeView *m_treeView;
QWidget *m_hierarchyWidget;
QStackedLayout *m_stackLayout;
QStandardItemModel *m_model;
Utils::AnnotatedItemDelegate *m_delegate;
TextEditor::TextEditorLinkLabel *m_inspectedClass;
QLabel *m_noTypeHierarchyAvailableLabel;
CppEditorWidget *m_cppEditor = nullptr;
Utils::NavigationTreeView *m_treeView = nullptr;
QWidget *m_hierarchyWidget = nullptr;
QStackedLayout *m_stackLayout = nullptr;
QStandardItemModel *m_model = nullptr;
Utils::AnnotatedItemDelegate *m_delegate = nullptr;
TextEditor::TextEditorLinkLabel *m_inspectedClass = nullptr;
QLabel *m_noTypeHierarchyAvailableLabel = nullptr;
};
class CppTypeHierarchyFactory : public Core::INavigationWidgetFactory

View File

@@ -74,7 +74,7 @@ private:
SelectionList waitForUseSelections(bool *hasTimedOut) const;
private:
CppEditorWidget *m_editorWidget;
CppEditorWidget *m_editorWidget = nullptr;
};
UseSelectionsTestCase::UseSelectionsTestCase(TestDocument &testFile,

View File

@@ -54,19 +54,18 @@ namespace {
class FunctionDefinitionUnderCursor: protected ASTVisitor
{
unsigned _line;
unsigned _column;
DeclarationAST *_functionDefinition;
unsigned _line = 0;
unsigned _column = 0;
DeclarationAST *_functionDefinition = nullptr;
public:
FunctionDefinitionUnderCursor(TranslationUnit *translationUnit)
: ASTVisitor(translationUnit),
_line(0), _column(0)
: ASTVisitor(translationUnit)
{ }
DeclarationAST *operator()(AST *ast, unsigned line, unsigned column)
{
_functionDefinition = 0;
_functionDefinition = nullptr;
_line = line;
_column = column;
accept(ast);

View File

@@ -104,8 +104,8 @@ private:
CPlusPlus::Document::Ptr m_document;
QScopedPointer<QFutureWatcher<UseSelectionsResult>> m_findUsesWatcher;
int m_findUsesRevision;
int m_findUsesCursorPosition;
int m_findUsesRevision = -1;
int m_findUsesCursorPosition = -1;
};
} // namespace Internal