forked from qt-creator/qt-creator
Clang: Fix/silence some coverty issues
clangcompletionassistprocessor.cpp: 136 CID 1475671: Possible Control flow issues (DEADCODE) Execution cannot reach the expression "codeCompletion.completionKind != ClangBackEnd::CodeCompletion::SlotCompletionKind" inside this statement: "if (slotCompletion && codeC...". clangbackendcommunicator.cpp: 272 CID 1475649: Null pointer dereferences (NULL_RETURNS) Dereferencing a pointer that might be null "document" when calling "contents". (The dereference happens because this is a virtual function call.) clangutils.cpp: 335 CID 1475678: Error handling issues (CHECKED_RETURN) Calling "open" without checking return value (as is done elsewhere 144 out of 158 times). codecompletionsextractor.cpp: 48 CID 1475676: Uninitialized members (UNINIT_CTOR) Non-static class member field "currentCxCodeCompleteResult.CompletionString" is not initialized in this constructor nor in any functions that it calls. Change-Id: I4c8767ee6e824ba1c42d2f8914ad66dc95ac6717 Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io> Reviewed-by: Marco Bubke <marco.bubke@qt.io>
This commit is contained in:
@@ -261,14 +261,14 @@ void BackendCommunicator::unsavedFilesUpdatedForUiHeaders()
|
|||||||
void BackendCommunicator::documentsChangedFromCppEditorDocument(const QString &filePath)
|
void BackendCommunicator::documentsChangedFromCppEditorDocument(const QString &filePath)
|
||||||
{
|
{
|
||||||
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
|
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
|
||||||
|
QTC_ASSERT(document, return);
|
||||||
documentsChanged(filePath, document->contents(), document->revision());
|
documentsChanged(filePath, document->contents(), document->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
void BackendCommunicator::unsavedFielsUpdatedFromCppEditorDocument(const QString &filePath)
|
void BackendCommunicator::unsavedFielsUpdatedFromCppEditorDocument(const QString &filePath)
|
||||||
{
|
{
|
||||||
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
|
const CppTools::CppEditorDocumentHandle *document = ClangCodeModel::Utils::cppDocument(filePath);
|
||||||
|
QTC_ASSERT(document, return);
|
||||||
unsavedFilesUpdated(filePath, document->contents(), document->revision());
|
unsavedFilesUpdated(filePath, document->contents(), document->revision());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -122,8 +122,9 @@ static QList<AssistProposalItemInterface *> toAssistProposalItems(
|
|||||||
const CodeCompletions &completions,
|
const CodeCompletions &completions,
|
||||||
const ClangCompletionAssistInterface *interface)
|
const ClangCompletionAssistInterface *interface)
|
||||||
{
|
{
|
||||||
bool signalCompletion = false; // TODO
|
// TODO: Handle Qt4's SIGNAL/SLOT
|
||||||
bool slotCompletion = false; // TODO
|
// Possibly check for m_completionOperator == T_SIGNAL
|
||||||
|
// Possibly check for codeCompletion.completionKind == CodeCompletion::SignalCompletionKind
|
||||||
|
|
||||||
QList<AssistProposalItemInterface *> items;
|
QList<AssistProposalItemInterface *> items;
|
||||||
items.reserve(completions.size());
|
items.reserve(completions.size());
|
||||||
@@ -131,11 +132,6 @@ static QList<AssistProposalItemInterface *> toAssistProposalItems(
|
|||||||
if (codeCompletion.text.isEmpty())
|
if (codeCompletion.text.isEmpty())
|
||||||
continue; // It's an OverloadCandidate which has text but no typedText.
|
continue; // It's an OverloadCandidate which has text but no typedText.
|
||||||
|
|
||||||
if (signalCompletion && codeCompletion.completionKind != CodeCompletion::SignalCompletionKind)
|
|
||||||
continue;
|
|
||||||
if (slotCompletion && codeCompletion.completionKind != CodeCompletion::SlotCompletionKind)
|
|
||||||
continue;
|
|
||||||
|
|
||||||
const QString name = codeCompletion.completionKind == CodeCompletion::KeywordCompletionKind
|
const QString name = codeCompletion.completionKind == CodeCompletion::KeywordCompletionKind
|
||||||
? CompletionChunksToTextConverter::convertToName(codeCompletion.chunks)
|
? CompletionChunksToTextConverter::convertToName(codeCompletion.chunks)
|
||||||
: codeCompletion.text.toString();
|
: codeCompletion.text.toString();
|
||||||
|
@@ -332,7 +332,9 @@ void generateCompilationDB(::Utils::FileName projectDir, CppTools::ProjectInfo p
|
|||||||
{
|
{
|
||||||
QFile compileCommandsFile(projectDir.toString() + "/compile_commands.json");
|
QFile compileCommandsFile(projectDir.toString() + "/compile_commands.json");
|
||||||
|
|
||||||
compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
const bool fileOpened = compileCommandsFile.open(QIODevice::WriteOnly | QIODevice::Truncate);
|
||||||
|
if (!fileOpened)
|
||||||
|
return;
|
||||||
compileCommandsFile.write("[");
|
compileCommandsFile.write("[");
|
||||||
for (ProjectPart::Ptr projectPart : projectInfo.projectParts()) {
|
for (ProjectPart::Ptr projectPart : projectInfo.projectParts()) {
|
||||||
const ::Utils::FileName buildDir = buildDirectory(*projectPart);
|
const ::Utils::FileName buildDir = buildDirectory(*projectPart);
|
||||||
|
@@ -82,8 +82,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
CodeCompletion currentCodeCompletion_;
|
CodeCompletion currentCodeCompletion_;
|
||||||
const UnsavedFile &unsavedFile;
|
const UnsavedFile &unsavedFile;
|
||||||
CXCompletionResult currentCxCodeCompleteResult;
|
CXCompletionResult currentCxCodeCompleteResult{CXCursor_UnexposedDecl, nullptr};
|
||||||
CXCodeCompleteResults *cxCodeCompleteResults;
|
CXCodeCompleteResults *cxCodeCompleteResults = nullptr;
|
||||||
uint cxCodeCompleteResultIndex = 0;
|
uint cxCodeCompleteResultIndex = 0;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user