build: Treat warnings as errors (#923)

* squash and rebase andronov-alexey:treat_warnings_as_errors from pull request #850
* fix remaining warnings in java lib
This commit is contained in:
Malte Langkabel
2020-02-14 16:34:04 +01:00
committed by GitHub
parent e5c1a118d7
commit a30f47e27f
112 changed files with 634 additions and 430 deletions
+1 -1
View File
@@ -450,7 +450,7 @@ void Application::updateRecentProjects(const FilePath& projectSettingsFilePath)
}
recentProjects.insert(recentProjects.begin(), projectSettingsFilePath);
while (recentProjects.size() > appSettings->getMaxRecentProjectsCount())
while (static_cast<int>(recentProjects.size()) > appSettings->getMaxRecentProjectsCount())
{
recentProjects.pop_back();
}
+22 -17
View File
@@ -381,7 +381,9 @@ void CodeController::handleMessage(MessageCodeShowDefinition* message)
if (message->inIDE)
{
MessageMoveIDECursor(filePath, lineNumber, columnNumber).dispatch();
MessageMoveIDECursor(
filePath, static_cast<unsigned int>(lineNumber), static_cast<unsigned int>(columnNumber))
.dispatch();
return;
}
@@ -471,10 +473,10 @@ void CodeController::handleMessage(MessageShowError* message)
void CodeController::handleMessage(MessageShowReference* message)
{
m_referenceIndex = message->refIndex;
m_referenceIndex = static_cast<int>(message->refIndex);
bool replayed = message->isReplayed();
if (m_referenceIndex >= 0 && m_referenceIndex < m_references.size())
if (m_referenceIndex >= 0 && m_referenceIndex < static_cast<int>(m_references.size()))
{
const Reference& ref = m_references[m_referenceIndex];
m_codeParams.activeLocationIds = {ref.locationId};
@@ -641,7 +643,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
activeSourceLocations->getFilePath(), showsErrors);
size_t lineCount = textAccess->getLineCount();
SnippetMerger fileScopedMerger(1, lineCount);
SnippetMerger fileScopedMerger(1, static_cast<int>(lineCount));
std::map<int, std::shared_ptr<SnippetMerger>> mergers;
std::shared_ptr<SourceLocationFile> scopeLocations =
@@ -657,8 +659,9 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
activeSourceLocations->getFilePath(), LOCATION_COMMENT);
commentLocations->forEachStartSourceLocation([&](SourceLocation* location) {
atomicRanges.push_back(SnippetMerger::Range(
SnippetMerger::Border(location->getLineNumber(), false),
SnippetMerger::Border(location->getOtherLocation()->getLineNumber(), false)));
SnippetMerger::Border(static_cast<int>(location->getLineNumber()), false),
SnippetMerger::Border(
static_cast<int>(location->getOtherLocation()->getLineNumber()), false)));
});
atomicRanges = SnippetMerger::Range::mergeAdjacent(atomicRanges);
@@ -673,7 +676,7 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
params.startLineNumber = std::max<int>(
1, range.start.row - (range.start.strong ? 0 : snippetExpandRange));
params.endLineNumber = std::min<int>(
lineCount, range.end.row + (range.end.strong ? 0 : snippetExpandRange));
static_cast<int>(lineCount), range.end.row + (range.end.strong ? 0 : snippetExpandRange));
params.locationFile = activeSourceLocations->getFilteredByLines(
params.startLineNumber, params.endLineNumber);
@@ -712,8 +715,9 @@ std::vector<CodeSnippetParams> CodeController::getSnippetsForFile(
params.footer = activeSourceLocations->getFilePath().wstr();
}
for (const std::string& line:
textAccess->getLines(params.startLineNumber, params.endLineNumber))
for (const std::string& line: textAccess->getLines(
static_cast<unsigned int>(params.startLineNumber),
static_cast<unsigned int>(params.endLineNumber)))
{
params.code += line;
}
@@ -731,7 +735,8 @@ std::shared_ptr<SnippetMerger> CodeController::buildMergerHierarchy(
std::map<int, std::shared_ptr<SnippetMerger>>& mergers) const
{
std::shared_ptr<SnippetMerger> currentMerger = std::make_shared<SnippetMerger>(
location->getStartLocation()->getLineNumber(), location->getEndLocation()->getLineNumber());
static_cast<int>(location->getStartLocation()->getLineNumber()),
static_cast<int>(location->getEndLocation()->getLineNumber()));
const SourceLocation* scopeLocation = getSourceLocationOfParentScope(
location->getLineNumber(), scopeLocations);
@@ -743,11 +748,11 @@ std::shared_ptr<SnippetMerger> CodeController::buildMergerHierarchy(
std::shared_ptr<SnippetMerger> nextMerger;
std::map<int, std::shared_ptr<SnippetMerger>>::iterator it = mergers.find(
scopeLocation->getLocationId());
static_cast<int>(scopeLocation->getLocationId()));
if (it == mergers.end())
{
nextMerger = buildMergerHierarchy(scopeLocation, scopeLocations, fileScopedMerger, mergers);
mergers[scopeLocation->getLocationId()] = nextMerger;
mergers[static_cast<int>(scopeLocation->getLocationId())] = nextMerger;
}
else
{
@@ -986,7 +991,7 @@ void CodeController::iterateReference(bool next)
{
if (m_referenceIndex < 1)
{
m_referenceIndex = m_references.size() - 1;
m_referenceIndex = static_cast<int>(m_references.size()) - 1;
}
else
{
@@ -1009,7 +1014,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
m_localReferenceIndex++;
if (m_localReferenceIndex == m_localReferences.size())
if (m_localReferenceIndex == static_cast<int>(m_localReferences.size()))
{
m_localReferenceIndex = 0;
}
@@ -1018,7 +1023,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
if (m_localReferenceIndex < 1)
{
m_localReferenceIndex = m_localReferences.size() - 1;
m_localReferenceIndex = static_cast<int>(m_localReferences.size()) - 1;
}
else
{
@@ -1036,7 +1041,7 @@ void CodeController::iterateLocalReference(bool next, bool updateView)
{
if (m_references[i].locationId == ref.locationId)
{
m_referenceIndex = i;
m_referenceIndex = static_cast<int>(i);
}
}
}
@@ -1382,7 +1387,7 @@ void CodeController::showFirstActiveReference(Id tokenId, bool updateView)
if (!firstReference.tokenId)
{
firstReference = ref;
referenceIndex = i;
referenceIndex = static_cast<int>(i);
}
}
@@ -73,7 +73,7 @@ void ErrorController::handleMessage(MessageErrorCountUpdate* message)
ErrorFilter filter = getView()->getErrorFilter();
int room = filter.limit - m_errorCount;
int room = static_cast<int>(filter.limit) - static_cast<int>(m_errorCount);
if (room > 0)
{
filter.limit = 0;
@@ -1269,7 +1269,7 @@ void GraphController::bundleNodesAndEdgesMatching(
bundleNode->name = name;
bundleNode->visible = true;
for (int i = matchedNodeIndices.size() - 1; i >= 0; i--)
for (int i = static_cast<int>(matchedNodeIndices.size()) - 1; i >= 0; i--)
{
std::shared_ptr<DummyNode> node = m_dummyNodes[matchedNodeIndices[i]];
node->visible = false;
@@ -1366,7 +1366,7 @@ std::shared_ptr<DummyNode> GraphController::bundleNodesMatching(
bundleNode->name = name;
bundleNode->visible = true;
for (int i = matchedNodes.size() - 1; i >= 0; i--)
for (int i = static_cast<int>(matchedNodes.size()) - 1; i >= 0; i--)
{
std::shared_ptr<DummyNode> node = *matchedNodes[i];
node->visible = false;
@@ -1484,7 +1484,7 @@ void GraphController::addCharacterIndex()
m_dummyNodes.insert(m_dummyNodes.end(), newNodes.begin(), newNodes.end());
// Add index characters
char character = 0;
wchar_t character = 0;
for (size_t i = 0; i < m_dummyNodes.size(); i++)
{
if (!m_dummyNodes[i]->visible || !m_dummyNodes[i]->name.size())
@@ -1950,7 +1950,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
if (node->isGraphNode())
{
node->name = utility::elide(node->name, utility::ELIDE_RIGHT, node->active ? 100 : 50);
width = margins.charWidth * node->name.size();
width = static_cast<int>(margins.charWidth * node->name.size());
if (node->data->getType().isCollapsible() && node->data->getChildCount() > 0)
{
@@ -1959,11 +1959,11 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
else if (node->isBundleNode() || node->isTextNode())
{
width = margins.charWidth * node->name.size();
width = static_cast<int>(margins.charWidth * node->name.size());
}
else if (node->isGroupNode())
{
width = margins.charWidth * node->name.size() + 5;
width = static_cast<int>(margins.charWidth * node->name.size() + 5);
}
width += margins.iconWidth;
@@ -1982,7 +1982,7 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
else if (subNode->isQualifierNode())
{
subNode->position.y = margins.top + margins.charHeight / 2;
subNode->position.y = static_cast<int>(margins.top + margins.charHeight / 2);
width += 5;
continue;
}
@@ -2027,7 +2027,10 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
case GroupLayout::SKEWED:
ListLayouter::layoutSkewed(
&node->subNodes, margins.spacingX, margins.spacingY, viewSize.x() * 1.5);
&node->subNodes,
margins.spacingX,
margins.spacingY,
static_cast<int>(viewSize.x() * 1.5));
break;
case GroupLayout::BUCKET:
@@ -2060,13 +2063,16 @@ Vec4i GraphController::layoutNestingRecursive(DummyNode* node, int relayoutAcces
}
Vec2i size = ListLayouter::offsetNodes(
node->subNodes, margins.top + margins.charHeight + margins.spacingA, margins.left);
node->subNodes,
static_cast<int>(margins.top + margins.charHeight + margins.spacingA),
margins.left);
width = std::max(size.x(), width);
height = size.y();
node->size.x = margins.left + width + margins.right;
node->size.y = margins.top + margins.charHeight + margins.spacingA + height + margins.bottom;
node->size.y = static_cast<int>(
margins.top + margins.charHeight + margins.spacingA + height + margins.bottom);
for (const std::shared_ptr<DummyNode>& subNode: node->subNodes)
{
@@ -2158,7 +2164,7 @@ void GraphController::layoutToGrid(DummyNode* node) const
if (subNode->isAccessNode())
{
subNode->size.x = subNode->size.x + incX;
subNode->size.x = static_cast<int>(subNode->size.x + incX);
lastAccessNode = subNode.get();
}
else if (subNode->isExpandToggleNode())
@@ -2169,15 +2175,15 @@ void GraphController::layoutToGrid(DummyNode* node) const
if (lastAccessNode)
{
lastAccessNode->size.y = lastAccessNode->size.y + incY;
lastAccessNode->size.y = static_cast<int>(lastAccessNode->size.y + incY);
if (expandToggleNode)
{
expandToggleNode->position.x = expandToggleNode->position.x + incX;
expandToggleNode->position.x = static_cast<int>(expandToggleNode->position.x + incX);
}
node->size.x = width;
node->size.y = height;
node->size.x = static_cast<int>(width);
node->size.y = static_cast<int>(height);
}
}
@@ -2409,8 +2415,8 @@ void GraphController::createLegendGraph()
addText(L"Legend", 6, Vec2i(0, 0));
size_t y = 50;
size_t x = 0;
int y = 50;
int x = 0;
// Layout
{
@@ -2474,12 +2480,12 @@ void GraphController::createLegendGraph()
x = 0;
y = 610;
size_t dx = 200;
size_t dy = 50;
int dx = 200;
int dy = 50;
// Nodes
{
size_t i = 0;
int i = 0;
addText(L"Nodes", 3, Vec2i(x, y));
addNode(NodeType::NODE_FILE, L"File", Vec2i(x, y + dy * ++i));
@@ -2581,7 +2587,7 @@ void GraphController::createLegendGraph()
// Edges
{
addText(L"Edges", 3, Vec2i(x, y));
size_t i = 0;
int i = 0;
{
addText(L"file include", 0, Vec2i(x, y + dy * ++i));
@@ -628,7 +628,7 @@ void UndoRedoController::updateHistory()
const size_t historyListSize = 50;
std::vector<SearchMatch> historyListMatches;
size_t index = 0;
int index = 0;
int currentIndex = -1;
m_historyOffset = 0;
@@ -36,8 +36,9 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector<std::shared_ptr
{
std::vector<int> maxWidths = std::vector<int>(cols, 0);
size_t nodesPerCol =
(cols == 1 ? visibleNodes.size()
: std::ceil((visibleNodes.size() + cols - 1) / double(cols)));
(cols == 1
? visibleNodes.size()
: static_cast<size_t>(std::ceil((visibleNodes.size() + cols - 1) / double(cols))));
int maxHeight = 0;
int height = -gapY;
@@ -86,7 +87,8 @@ void ListLayouter::layoutMultiColumn(Vec2i viewSize, std::vector<std::shared_ptr
size_t nodesPerCol =
(colsFinal == 1 ? visibleNodes.size()
: std::ceil((visibleNodes.size() + colsFinal - 1) / double(colsFinal)));
: static_cast<size_t>(
std::ceil((visibleNodes.size() + colsFinal - 1) / double(colsFinal))));
std::shared_ptr<DummyNode> lastTextNode;
for (size_t i = 0; i < visibleNodes.size(); i++)
@@ -151,9 +153,9 @@ void ListLayouter::layoutSquare(std::vector<std::shared_ptr<DummyNode>>* nodes,
}
int diff = -1;
size_t cols = 1;
int cols = 1;
for (size_t i = cols; i < 100; i++)
for (int i = cols; i < 100; i++)
{
if (layoutSquareInternal(
visibleNodes, Vec2i(maxWidth, totalHeight * i / 100), Vec2i(gapX, gapY)))
@@ -134,7 +134,7 @@ NetworkProtocolHelper::CreateCDBProjectMessage NetworkProtocolHelper::parseCreat
}
else
{
const int subMessageCount = subMessages.size();
const size_t subMessageCount = subMessages.size();
const std::wstring cdbPath = subMessages[1];
if (!cdbPath.empty())
@@ -309,8 +309,8 @@ void TrailLayouter::buildColumns()
{
for (const std::shared_ptr<TrailNode>& node: m_allNodes)
{
int level = node->level + 1;
for (int i = m_nodesPerCol.size(); i <= level; i++)
const int level = node->level + 1;
for (int i = static_cast<int>(m_nodesPerCol.size()); i <= level; i++)
{
m_nodesPerCol.push_back(std::vector<TrailNode*>());
}
@@ -365,7 +365,7 @@ void TrailLayouter::reduceEdgeCrossings()
}
}
float value = j;
float value = float(j);
if (count)
{
value = float(sum) / count;
@@ -508,7 +508,7 @@ void TrailLayouter::moveNodesToAveragePosition(std::vector<TrailNode*> nodes, bo
{
averagePosition += p.first;
}
averagePosition /= averagePositions.size();
averagePosition /= static_cast<int>(averagePositions.size());
std::multimap<int, int> distanceFromAveragePosition;
+15 -10
View File
@@ -145,7 +145,7 @@ void GraphViewStyle::loadStyleSettings()
s_edgeColors.clear();
s_screenMatchColors.clear();
s_gridCellPadding = getCharHeight(NodeType::STYLE_BIG_NODE) - 8;
s_gridCellPadding = static_cast<int>(getCharHeight(NodeType::STYLE_BIG_NODE) - 8);
s_gridCellSize = s_gridCellPadding / 2;
}
@@ -316,7 +316,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfExpandToggleNode()
NodeMargins margins;
margins.left = margins.right = margins.top = margins.bottom = 6;
margins.minWidth = margins.charHeight = getFontSizeOfExpandToggleNode();
margins.charHeight = static_cast<float>(getFontSizeOfExpandToggleNode());
margins.minWidth = static_cast<int>(margins.charHeight);
return margins;
}
@@ -332,7 +333,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfTextNode(int fontSizeDif
margins.left = margins.right = 0;
margins.top = margins.bottom = 6;
margins.minWidth = margins.charHeight = getFontSizeOfTextNode(fontSizeDiff);
margins.charHeight = static_cast<float>(getFontSizeOfTextNode(fontSizeDiff));
margins.minWidth = static_cast<int>(margins.charHeight);
margins.charWidth = getCharWidth(getFontNameOfTextNode(), getFontSizeOfTextNode(fontSizeDiff));
@@ -357,7 +359,8 @@ GraphViewStyle::NodeMargins GraphViewStyle::getMarginsOfGroupNode(GroupType type
if (hasName)
{
margins.minWidth = margins.charHeight = getFontSizeOfGroupNode();
margins.charHeight = static_cast<float>(getFontSizeOfGroupNode());
margins.minWidth = static_cast<int>(margins.charHeight);
}
margins.charWidth = getCharWidth(NodeType::STYLE_GROUP);
@@ -618,7 +621,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
{
EdgeStyle style;
style.width = isActive ? 4 : 2;
style.width = isActive ? 4.0f : 2.0f;
style.zValue = isActive ? 5 : 2;
if (isTrailEdge)
@@ -688,7 +691,7 @@ GraphViewStyle::EdgeStyle GraphViewStyle::getStyleForEdgeType(
style.verticalOffset = 0;
style.cornerRadius = 7;
style.zValue = isActive ? 2 : -3;
style.width = isActive ? 3 : 2;
style.width = isActive ? 3.0f : 2.0f;
if (isTrailEdge)
{
@@ -725,13 +728,15 @@ int GraphViewStyle::toGridOffset(int x)
{
if (x > 0)
{
return std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize);
return static_cast<int>(
std::ceil(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize));
}
else
{
return std::floor(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize);
return static_cast<int>(
std::floor(x / double(s_gridCellPadding + s_gridCellSize)) *
(s_gridCellPadding + s_gridCellSize));
}
}
@@ -26,7 +26,7 @@ CodeSnippetParams CodeSnippetParams::merge(const CodeSnippetParams& a, const Cod
std::string code = first->code;
std::string secondCode = second->code;
int secondCodeStartIndex = 0;
size_t secondCodeStartIndex = 0;
for (size_t i = second->startLineNumber; i <= first->endLineNumber; i++)
{
secondCodeStartIndex = secondCode.find("\n", secondCodeStartIndex) + 1;
+1 -1
View File
@@ -162,7 +162,7 @@ NodeTypeSet::NodeTypeSet(NodeTypeSet::MaskType typeMask): m_nodeTypeMask(typeMas
NodeTypeSet::MaskType NodeTypeSet::nodeTypeToMask(const NodeType& nodeType)
{
// todo: convert to mask if ids are not power of two anymore
return nodeType.getId();
return static_cast<MaskType>(nodeType.getId());
}
const std::vector<NodeType> NodeTypeSet::s_allNodeTypes = {
+2 -2
View File
@@ -36,7 +36,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
m_storage->optimizeMemory();
m_dialogView->hideUnknownProgressDialog();
float time = TimeStamp::durationSeconds(start);
double time = TimeStamp::durationSeconds(start);
if (blackboard->exists("clear_time"))
{
@@ -85,7 +85,7 @@ Task::TaskState TaskFinishParsing::doUpdate(std::shared_ptr<Blackboard> blackboa
sourceFileCount,
stats.completedFileCount,
stats.fileCount,
time,
static_cast<float>(time),
errorInfo,
interruptedIndexing,
shallowIndexing);
@@ -11,7 +11,7 @@ void FullTextSearchIndex::addFile(Id fileId, const std::wstring& fileContent)
LOG_ERROR("empty file not added to fulltextsearch index");
}
if (fileContent.size() >= std::numeric_limits<int>::max())
if (static_cast<int>(fileContent.size()) >= std::numeric_limits<int>::max())
{
LOG_ERROR("file too big not added to fulltextsearch index");
}
+4 -4
View File
@@ -46,7 +46,7 @@ void SuffixArray::printLCP() const
std::vector<int> SuffixArray::buildLCP()
{
const int n = m_array.size();
const int n = static_cast<int>(m_array.size());
std::vector<int> lcp(n, 0);
std::vector<int> invSuff(n, 0);
@@ -89,8 +89,8 @@ std::vector<int> SuffixArray::searchForTerm(const std::wstring& searchTerm) cons
std::wstring term = searchTerm;
std::transform(term.begin(), term.end(), term.begin(), ::towlower);
const int termLength = term.length();
const int textLength = m_text.length();
const int termLength = static_cast<int>(term.length());
const int textLength = static_cast<int>(m_text.length());
int l = -1;
int r = textLength;
int m;
@@ -131,7 +131,7 @@ std::vector<int> SuffixArray::searchForTerm(const std::wstring& searchTerm) cons
std::vector<int> SuffixArray::buildSuffixArray()
{
const int n = m_text.length();
const int n = static_cast<int>(m_text.length());
std::vector<suffix> suffixes;
suffixes.reserve(n);
@@ -25,7 +25,7 @@ std::shared_ptr<TokenComponent> TokenComponentAggregation::copy() const
int TokenComponentAggregation::getAggregationCount() const
{
return m_ids.size();
return static_cast<int>(m_ids.size());
}
std::set<Id> TokenComponentAggregation::getAggregationIds() const
+1 -1
View File
@@ -268,7 +268,7 @@ bool TaskBuildIndex::fetchIntermediateStorages(std::shared_ptr<Blackboard> black
std::shared_ptr<InterprocessIntermediateStorageManager> storageManager =
m_interprocessIntermediateStorageManagers[finishedProcessId - 1];
int storageCount = storageManager->getIntermediateStorageCount();
const size_t storageCount = storageManager->getIntermediateStorageCount();
if (!storageCount)
{
break;
@@ -89,7 +89,10 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
for (size_t i = 1 /*this method is counting as the first thread*/; i < m_indexerThreadCount; i++)
{
indexerThreads.push_back(std::make_shared<std::thread>(
&TaskExecuteCustomCommands::executeParallelIndexerCommands, this, i, blackboard));
&TaskExecuteCustomCommands::executeParallelIndexerCommands,
this,
static_cast<int>(i),
blackboard));
}
while (!m_interrupted && !m_serialCommands.empty())
@@ -138,7 +141,7 @@ Task::TaskState TaskExecuteCustomCommands::doUpdate(std::shared_ptr<Blackboard>
void TaskExecuteCustomCommands::doExit(std::shared_ptr<Blackboard> blackboard)
{
m_storage.reset();
const float duration = TimeStamp::durationSeconds(m_start);
const float duration = static_cast<float>(TimeStamp::durationSeconds(m_start));
blackboard->update<float>(
"index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
@@ -336,7 +339,7 @@ void TaskExecuteCustomCommands::runPythonPostProcessing(PersistentStorage& stora
}
const std::wstring token = utility::decodeFromUtf8(
textAccess->getLine(startLoc->getLineNumber())
textAccess->getLine(static_cast<unsigned int>(startLoc->getLineNumber()))
.substr(
startLoc->getColumnNumber() - 1,
endLoc->getColumnNumber() - startLoc->getColumnNumber() + 1));
@@ -64,6 +64,13 @@ std::shared_ptr<IndexerCommand> SharedIndexerCommand::fromShared(const SharedInd
indexerCommand.getLanguageStandard(),
indexerCommand.getClassPaths());
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
case PYTHON:
LOG_ERROR(
L"Cannot convert shared IndexerCommand for file: " +
indexerCommand.getSourceFilePath().wstr() + L". The type is unknown.");
break;
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
default:
LOG_ERROR(
L"Cannot convert shared IndexerCommand for file: " +
@@ -59,8 +59,11 @@ private:
CXX,
#endif // BUILD_CXX_LANGUAGE_PACKAGE
#if BUILD_JAVA_LANGUAGE_PACKAGE
JAVA
JAVA,
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
PYTHON,
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
};
Type getType() const;
@@ -230,5 +230,5 @@ Id SharedIntermediateStorage::getNextId() const
void SharedIntermediateStorage::setNextId(const Id nextId)
{
m_nextId = nextId;
m_nextId = static_cast<int>(nextId);
}
+2 -2
View File
@@ -229,7 +229,7 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByTypes(
size_t typeMask = 0;
for (LocationType type: types)
{
typeMask |= 1 << type;
typeMask |= static_cast<size_t>(1) << type;
}
std::shared_ptr<SourceLocationFile> ret = std::make_shared<SourceLocationFile>(
@@ -237,7 +237,7 @@ std::shared_ptr<SourceLocationFile> SourceLocationFile::getFilteredByTypes(
for (const std::shared_ptr<SourceLocation>& location: m_locations)
{
if ((1 << location->getType()) & typeMask)
if ((static_cast<size_t>(1) << location->getType()) & typeMask)
{
ret->addSourceLocationCopy(location.get());
}
+1 -1
View File
@@ -36,7 +36,7 @@ Task::TaskState TaskParseWrapper::doUpdate(std::shared_ptr<Blackboard> blackboar
void TaskParseWrapper::doExit(std::shared_ptr<Blackboard> blackboard)
{
float duration = TimeStamp::durationSeconds(m_start);
float duration = static_cast<float>(TimeStamp::durationSeconds(m_start));
blackboard->update<float>(
"index_time", [duration](float currentDuration) { return currentDuration + duration; });
}
+4 -3
View File
@@ -439,12 +439,13 @@ int SearchIndex::scoreText(const std::wstring& text, const std::vector<size_t>&
int noLetterScore = 0;
int firstLetterScore = 0;
for (size_t i = 0; i < indices.size(); i++)
for (int i = 0; i < static_cast<int>(indices.size()); i++)
{
// unmatched and consecutive
if (i > 0)
{
unmatchedLetterScore += (indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus;
unmatchedLetterScore += static_cast<int>(
(indices[i] - indices[i - 1] - 1) * unmatchedLetterBonus);
consecutiveLetterScore += (indices[i] - indices[i - 1] == 1) ? consecutiveLetterBonus : 0;
}
@@ -497,7 +498,7 @@ SearchResult SearchIndex::rescoreText(
std::vector<size_t> textIndices;
// match is already within text
int newIdx = indices[0] - (fulltext.size() - text.size());
const int newIdx = static_cast<int>(indices[0] - (fulltext.size() - text.size()));
if (newIdx >= 0)
{
for (size_t idx: indices)
+1 -1
View File
@@ -33,7 +33,7 @@ void IntermediateStorage::clear()
size_t IntermediateStorage::getByteSize(size_t stringSize) const
{
unsigned int byteSize = 0;
size_t byteSize = 0;
for (const StorageFile& storageFile: getStorageFiles())
{
+7 -5
View File
@@ -625,7 +625,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
/*no ref here!*/ fileResults,
&collection,
&collectionMutex]() {
const int termLength = searchTerm.length();
const int termLength = static_cast<int>(searchTerm.length());
for (const FullTextSearchResult& fileResult: fileResults)
{
const FilePath filePath = getFileNodePath(fileResult.fileId);
@@ -639,7 +639,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
{
while (charsTotal + (int)line.length() <= pos)
{
charsTotal += line.length();
charsTotal += static_cast<int>(line.length());
lineNumber++;
line = codec.decode(fileContent->getLine(lineNumber));
}
@@ -655,7 +655,7 @@ std::shared_ptr<SourceLocationCollection> PersistentStorage::getFullTextSearchLo
}
while ((charsTotal + (int)line.length()) < pos + termLength)
{
charsTotal += line.length();
charsTotal += static_cast<int>(line.length());
lineNumber++;
line = codec.decode(fileContent->getLine(lineNumber));
}
@@ -709,7 +709,7 @@ std::vector<SearchMatch> PersistentStorage::getAutocompletionMatches(
TRACE();
// search in indices
const size_t maxResultsCount = std::pow(3, query.size() + 3);
const size_t maxResultsCount = static_cast<size_t>(std::pow(3, query.size() + 3));
const size_t maxBestScoredResultsLength = 100;
const size_t maxMatchesReturned = 1000;
@@ -2280,7 +2280,9 @@ TooltipSnippet PersistentStorage::getTooltipSnippetForNode(const StorageNode& no
std::vector<Annotation> annotations;
std::vector<std::string> lines =
getFileContent(sigLoc->getFilePath(), false)
->getLines(sigLoc->getLineNumber(), sigLoc->getEndLocation()->getLineNumber());
->getLines(
static_cast<unsigned int>(sigLoc->getLineNumber()),
static_cast<unsigned int>(sigLoc->getEndLocation()->getLineNumber()));
// check if signature location refers to correct locations in the code
// wrongly recorded signature locations of implicit template methods in C++ caused crashes
+1 -1
View File
@@ -5,7 +5,7 @@
int StorageProvider::getStorageCount() const
{
std::lock_guard<std::mutex> lock(m_storagesMutex);
return m_storages.size();
return static_cast<int>(m_storages.size());
}
void StorageProvider::clear()
@@ -75,7 +75,7 @@ StorageBookmarkCategory SqliteBookmarkStorage::addBookmarkCategory(const Storage
stmt.bind(1, utility::encodeToUtf8(data.name).c_str());
executeStatement(stmt);
return StorageBookmarkCategory(m_database.lastRowId(), data);
return StorageBookmarkCategory(static_cast<Id>(m_database.lastRowId()), data);
}
StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& data)
@@ -93,7 +93,7 @@ StorageBookmark SqliteBookmarkStorage::addBookmark(const StorageBookmarkData& da
stmt.bind(3, data.timestamp.c_str());
executeStatement(stmt);
return StorageBookmark(m_database.lastRowId(), data);
return StorageBookmark(static_cast<Id>(m_database.lastRowId()), data);
}
catch (CppSQLite3Exception e)
{
@@ -107,7 +107,7 @@ StorageBookmarkedNode SqliteBookmarkStorage::addBookmarkedNode(const StorageBook
executeStatement(
"INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " +
std::to_string(data.bookmarkId) + ");");
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
std::string statement =
"INSERT INTO bookmarked_node(id, serialized_node_name) "
@@ -125,7 +125,7 @@ StorageBookmarkedEdge SqliteBookmarkStorage::addBookmarkedEdge(const StorageBook
executeStatement(
"INSERT INTO bookmarked_element(id, bookmark_id) VALUES(NULL, " +
std::to_string(data.bookmarkId) + ");");
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
std::string statement =
"INSERT INTO bookmarked_edge(id, serialized_source_node_name, serialized_target_node_name, "
@@ -89,14 +89,14 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
std::string name = utility::encodeToUtf8(node.serializedName);
if (name.size() != node.serializedName.size())
{
m_tempWNodeNameIndex.add(node.serializedName, node.id);
m_tempWNodeNameIndex.add(node.serializedName, static_cast<uint32_t>(node.id));
}
else
{
m_tempNodeNameIndex.add(name, node.id);
m_tempNodeNameIndex.add(name, static_cast<uint32_t>(node.id));
}
m_tempNodeTypes.emplace(node.id, node.type);
m_tempNodeTypes.emplace(static_cast<uint32_t>(node.id), node.type);
});
}
@@ -119,11 +119,11 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
if (nodeId)
{
auto it = m_tempNodeTypes.find(nodeId);
auto it = m_tempNodeTypes.find(static_cast<uint32_t>(nodeId));
if (it != m_tempNodeTypes.end() && it->second < data.type)
{
setNodeType(data.type, nodeId);
m_tempNodeTypes[nodeId] = data.type;
m_tempNodeTypes[static_cast<uint32_t>(nodeId)] = data.type;
}
nodeIds[i] = nodeId;
@@ -131,20 +131,20 @@ std::vector<Id> SqliteIndexStorage::addNodes(const std::vector<StorageNode>& nod
else
{
executeStatement(m_insertElementStmt);
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
nodesToInsert.emplace_back(id, data);
nodeIds[i] = id;
if (name.size() != data.serializedName.size())
{
m_tempWNodeNameIndex.add(data.serializedName, id);
m_tempWNodeNameIndex.add(data.serializedName, static_cast<uint32_t>(id));
}
else
{
m_tempNodeNameIndex.add(name, id);
m_tempNodeNameIndex.add(name, static_cast<uint32_t>(id));
}
m_tempNodeTypes.emplace(id, data.type);
m_tempNodeTypes.emplace(static_cast<uint32_t>(id), data.type);
}
}
}
@@ -224,7 +224,8 @@ std::vector<Id> SqliteIndexStorage::addEdges(const std::vector<StorageEdge>& edg
{
forEach<StorageEdge>([this](StorageEdge&& edge) {
m_tempEdgeIndex.emplace(
StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId), edge.id);
StorageEdgeData(edge.type, edge.sourceNodeId, edge.targetNodeId),
static_cast<uint32_t>(edge.id));
});
}
@@ -241,12 +242,12 @@ std::vector<Id> SqliteIndexStorage::addEdges(const std::vector<StorageEdge>& edg
else
{
executeStatement(m_insertElementStmt);
Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
edgeIds[i] = id;
edgesToInsert.emplace_back(id, data);
m_tempEdgeIndex.emplace(data, id);
m_tempEdgeIndex.emplace(data, static_cast<uint32_t>(id));
}
}
@@ -272,7 +273,8 @@ std::vector<Id> SqliteIndexStorage::addLocalSymbols(const std::set<StorageLocalS
std::pair<std::wstring, std::wstring> name = splitLocalSymbolName(localSymbol.name);
if (name.second.size())
{
m_tempLocalSymbolIndex[name.first].emplace(name.second, localSymbol.id);
m_tempLocalSymbolIndex[name.first].emplace(
name.second, static_cast<uint32_t>(localSymbol.id));
}
});
}
@@ -300,13 +302,13 @@ std::vector<Id> SqliteIndexStorage::addLocalSymbols(const std::set<StorageLocalS
if (!symbolIds[i])
{
executeStatement(m_insertElementStmt);
const Id id = m_database.lastRowId();
const Id id = static_cast<Id>(m_database.lastRowId());
symbolIds[i] = id;
symbolsToInsert.emplace_back(id, data);
if (name.second.size())
{
m_tempLocalSymbolIndex[name.first].emplace(name.second, id);
m_tempLocalSymbolIndex[name.first].emplace(name.second, static_cast<uint32_t>(id));
}
}
@@ -333,11 +335,15 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
{
forEach<StorageSourceLocation>([this](StorageSourceLocation&& loc) {
std::map<TempSourceLocation, uint32_t>& index =
m_tempSourceLocationIndices[loc.fileNodeId];
m_tempSourceLocationIndices[static_cast<uint32_t>(loc.fileNodeId)];
index.emplace(
TempSourceLocation(
loc.startLine, loc.endLine - loc.startLine, loc.startCol, loc.endCol, loc.type),
loc.id);
static_cast<uint32_t>(loc.startLine),
static_cast<uint16_t>(loc.endLine - loc.startLine),
static_cast<uint16_t>(loc.startCol),
static_cast<uint16_t>(loc.endCol),
loc.type),
static_cast<uint32_t>(loc.id));
});
}
@@ -349,9 +355,13 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
{
const StorageSourceLocation& data = locations[i];
const TempSourceLocation tempLoc(
data.startLine, data.endLine - data.startLine, data.startCol, data.endCol, data.type);
static_cast<uint32_t>(data.startLine),
static_cast<uint16_t>(data.endLine - data.startLine),
static_cast<uint16_t>(data.startCol),
static_cast<uint16_t>(data.endCol),
data.type);
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[data.fileNodeId];
std::map<TempSourceLocation, uint32_t>& index = m_tempSourceLocationIndices[static_cast<uint32_t>(data.fileNodeId)];
std::map<TempSourceLocation, uint32_t>::const_iterator it = index.find(tempLoc);
if (it != index.end())
{
@@ -363,7 +373,7 @@ std::vector<Id> SqliteIndexStorage::addSourceLocations(const std::vector<Storage
Id id = lastRowId + 1 + locationsToInsert.size();
locationIds[i] = id;
index.emplace(tempLoc, id);
index.emplace(tempLoc, static_cast<uint32_t>(id));
locationsToInsert.emplace_back(data);
}
@@ -434,7 +444,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data)
if (id == 0)
{
executeStatement(m_insertElementStmt);
id = m_database.lastRowId();
id = static_cast<Id>(m_database.lastRowId());
m_insertErrorStmt.bind(1, int(id));
m_insertErrorStmt.bind(2, utility::encodeToUtf8(sanitizedMessage).c_str());
@@ -445,7 +455,7 @@ StorageError SqliteIndexStorage::addError(const StorageErrorData& data)
const bool success = executeStatement(m_insertErrorStmt);
if (success)
{
id = m_database.lastRowId();
id = static_cast<Id>(m_database.lastRowId());
}
}
@@ -1349,35 +1359,35 @@ void SqliteIndexStorage::setupPrecompiledStatements()
"INSERT INTO node(id, type, serialized_name) VALUES",
3,
[](CppSQLite3Statement& stmt, const StorageNode& node, size_t index) {
stmt.bind(index * 3 + 1, int(node.id));
stmt.bind(index * 3 + 2, int(node.type));
stmt.bind(index * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str());
stmt.bind(int(index) * 3 + 1, int(node.id));
stmt.bind(int(index) * 3 + 2, int(node.type));
stmt.bind(int(index) * 3 + 3, utility::encodeToUtf8(node.serializedName).c_str());
},
m_database);
m_insertEdgeBatchStatement.compile(
"INSERT INTO edge(id, type, source_node_id, target_node_id) VALUES",
4,
[](CppSQLite3Statement& stmt, const StorageEdge& edge, size_t index) {
stmt.bind(index * 4 + 1, int(edge.id));
stmt.bind(index * 4 + 2, int(edge.type));
stmt.bind(index * 4 + 3, int(edge.sourceNodeId));
stmt.bind(index * 4 + 4, int(edge.targetNodeId));
stmt.bind(int(index) * 4 + 1, int(edge.id));
stmt.bind(int(index) * 4 + 2, int(edge.type));
stmt.bind(int(index) * 4 + 3, int(edge.sourceNodeId));
stmt.bind(int(index) * 4 + 4, int(edge.targetNodeId));
},
m_database);
m_insertSymbolBatchStatement.compile(
"INSERT OR IGNORE INTO symbol(id, definition_kind) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageSymbol& symbol, size_t index) {
stmt.bind(index * 2 + 1, int(symbol.id));
stmt.bind(index * 2 + 2, int(symbol.definitionKind));
stmt.bind(int(index) * 2 + 1, int(symbol.id));
stmt.bind(int(index) * 2 + 2, int(symbol.definitionKind));
},
m_database);
m_insertLocalSymbolBatchStatement.compile(
"INSERT INTO local_symbol(id, name) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageLocalSymbol& symbol, size_t index) {
stmt.bind(index * 2 + 1, int(symbol.id));
stmt.bind(index * 2 + 2, utility::encodeToUtf8(symbol.name).c_str());
stmt.bind(int(index) * 2 + 1, int(symbol.id));
stmt.bind(int(index) * 2 + 2, utility::encodeToUtf8(symbol.name).c_str());
},
m_database);
m_insertSourceLocationBatchStatement.compile(
@@ -1385,28 +1395,28 @@ void SqliteIndexStorage::setupPrecompiledStatements()
"end_column, type) VALUES",
6,
[](CppSQLite3Statement& stmt, const StorageSourceLocationData& location, size_t index) {
stmt.bind(index * 6 + 1, int(location.fileNodeId));
stmt.bind(index * 6 + 2, int(location.startLine));
stmt.bind(index * 6 + 3, int(location.startCol));
stmt.bind(index * 6 + 4, int(location.endLine));
stmt.bind(index * 6 + 5, int(location.endCol));
stmt.bind(index * 6 + 6, int(location.type));
stmt.bind(int(index) * 6 + 1, int(location.fileNodeId));
stmt.bind(int(index) * 6 + 2, int(location.startLine));
stmt.bind(int(index) * 6 + 3, int(location.startCol));
stmt.bind(int(index) * 6 + 4, int(location.endLine));
stmt.bind(int(index) * 6 + 5, int(location.endCol));
stmt.bind(int(index) * 6 + 6, int(location.type));
},
m_database);
m_insertOccurenceBatchStatement.compile(
"INSERT OR IGNORE INTO occurrence(element_id, source_location_id) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageOccurrence& occurrence, size_t index) {
stmt.bind(index * 2 + 1, int(occurrence.elementId));
stmt.bind(index * 2 + 2, int(occurrence.sourceLocationId));
stmt.bind(int(index) * 2 + 1, int(occurrence.elementId));
stmt.bind(int(index) * 2 + 2, int(occurrence.sourceLocationId));
},
m_database);
m_insertComponentAccessBatchStatement.compile(
"INSERT OR IGNORE INTO component_access(node_id, type) VALUES",
2,
[](CppSQLite3Statement& stmt, const StorageComponentAccess& componentAccess, size_t index) {
stmt.bind(index * 2 + 1, int(componentAccess.nodeId));
stmt.bind(index * 2 + 2, int(componentAccess.type));
stmt.bind(int(index) * 2 + 1, int(componentAccess.nodeId));
stmt.bind(int(index) * 2 + 2, int(componentAccess.type));
},
m_database);
+5 -4
View File
@@ -599,7 +599,8 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
size_t sourceFileCount = indexerCommandProvider->size() + customIndexerCommandProvider->size();
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("shallow_indexing", info.shallow));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("source_file_count", sourceFileCount));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>(
"source_file_count", static_cast<int>(sourceFileCount)));
taskSequential->addTask(std::make_shared<TaskSetValue<int>>("indexed_source_file_count", 0));
taskSequential->addTask(std::make_shared<TaskSetValue<bool>>("interrupted_indexing", false));
taskSequential->addTask(std::make_shared<TaskSetValue<float>>("index_time", 0.0f));
@@ -617,7 +618,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
if (!indexerCommandProvider->empty())
{
const int adjustedIndexerThreadCount = std::min<int>(
indexerThreadCount, indexerCommandProvider->size());
indexerThreadCount, static_cast<int>(indexerCommandProvider->size()));
std::shared_ptr<StorageProvider> storageProvider = std::make_shared<StorageProvider>();
// add tasks for setting some variables on the blackboard that are used during indexing
@@ -719,7 +720,7 @@ void Project::buildIndex(RefreshInfo info, std::shared_ptr<DialogView> dialogVie
if (!customIndexerCommandProvider->empty())
{
const int adjustedIndexerThreadCount = std::min<int>(
indexerThreadCount, customIndexerCommandProvider->size());
indexerThreadCount, static_cast<int>(customIndexerCommandProvider->size()));
taskSequential->addTask(std::make_shared<TaskExecuteCustomCommands>(
std::move(customIndexerCommandProvider),
@@ -813,7 +814,7 @@ bool Project::swapToTempStorageFile(
FileSystem::remove(indexDbFilePath);
FileSystem::rename(tempIndexDbFilePath, indexDbFilePath);
}
catch (std::exception& e)
catch (std::exception& /*e*/)
{
if (m_hasGUI)
{
+5
View File
@@ -472,6 +472,11 @@ SettingsMigrator ProjectSettings::getMigrations() const
languageName = "java";
break;
#endif // BUILD_JAVA_LANGUAGE_PACKAGE
#if BUILD_PYTHON_LANGUAGE_PACKAGE
case LANGUAGE_PYTHON:
continue;
#endif // BUILD_PYTHON_LANGUAGE_PACKAGE
default:
continue;
}
+1 -1
View File
@@ -96,7 +96,7 @@ size_t Settings::getVersion() const
void Settings::setVersion(size_t version)
{
setValue<int>("version", version);
setValue<int>("version", static_cast<int>(version));
}
Settings::Settings()
@@ -23,8 +23,8 @@ public:
SourceGroupSettings::load(config, key);
using expand_type = int[];
expand_type a {0, loadHelper<ComponentTypes>(config, key)...};
using expand_type = bool[];
expand_type a {false, loadHelper<ComponentTypes>(config, key)...};
}
void saveSettings(ConfigManager* config) override
@@ -33,8 +33,8 @@ public:
SourceGroupSettings::save(config, key);
using expand_type = int[];
expand_type a {0, saveHelper<ComponentTypes>(config, key)...};
using expand_type = bool[];
expand_type a {false, saveHelper<ComponentTypes>(config, key)...};
}
bool equalsSettings(const SourceGroupSettingsBase* other) override
@@ -51,7 +51,7 @@ public:
return false;
}
using expand_type = int[];
using expand_type = bool[];
expand_type a {false, equalsHelper<ComponentTypes>(other)...};
bool r = true;
+6
View File
@@ -32,7 +32,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return strncpy(destination, source, num);
#pragma warning(pop)
}
};
@@ -50,7 +53,10 @@ public:
static CharT* CopyFn(CharT* destination, const CharT* source, size_t num)
{
#pragma warning(push)
#pragma warning(disable : 4996)
return wcsncpy(destination, source, num);
#pragma warning(pop)
}
};
+4 -4
View File
@@ -23,7 +23,7 @@ std::string TimeStamp::secondsToString(double secs)
int seconds = int(secs);
secs -= seconds;
int milliSeconds = secs * 1000;
const int milliSeconds = static_cast<int>(secs * 1000);
if (hours > 9)
{
@@ -110,12 +110,12 @@ std::string TimeStamp::dayOfWeekShort() const
size_t TimeStamp::deltaMS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_milliseconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_milliseconds()));
}
size_t TimeStamp::deltaS(const TimeStamp& other) const
{
return abs((m_time - other.m_time).total_seconds());
return static_cast<size_t>(abs((m_time - other.m_time).total_seconds()));
}
bool TimeStamp::isSameDay(const TimeStamp& other) const
@@ -139,5 +139,5 @@ size_t TimeStamp::deltaDays(const TimeStamp& other) const
size_t TimeStamp::deltaHours(const TimeStamp& other) const
{
boost::posix_time::time_duration delta = m_time - other.m_time;
return abs(delta.total_seconds() / 3600);
return static_cast<size_t>(abs(delta.total_seconds() / 3600));
}
+3
View File
@@ -261,8 +261,11 @@ std::vector<FilePath> FilePath::expandEnvironmentVariables() const
std::smatch match;
while (std::regex_search(text, match, env))
{
#pragma warning(push)
#pragma warning(disable : 4996)
const char* s = match[1].matched ? getenv(match[1].str().c_str())
: getenv(match[2].str().c_str());
#pragma warning(pop)
if (s == nullptr)
{
LOG_ERROR_STREAM(<< match[1].str() << " is not an environment variable in: " << text);
+1 -1
View File
@@ -28,7 +28,7 @@ std::vector<FilePath> utility::partitionFilePathsBySize(std::vector<FilePath> fi
sourceFileSizesToCommands.end(),
[](const PairType& p, const PairType& q) { return p.first > q.first; });
if (0 < partitionCount && partitionCount < sourceFileSizesToCommands.size())
if (0 < partitionCount && partitionCount < static_cast<int>(sourceFileSizesToCommands.size()))
{
for (int i = 0; i < partitionCount; i++)
{
@@ -195,7 +195,6 @@ SharedMemory::~SharedMemory()
LOG_ERROR_STREAM(
<< "boost exception thrown at shared memory destruction - " << getMemoryName() << ": "
<< e.what());
throw e;
}
}
+4
View File
@@ -13,6 +13,9 @@ std::wstring FileLogger::generateDatedFileName(
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm t = *std::localtime(&time);
if (offsetDays != 0)
@@ -20,6 +23,7 @@ std::wstring FileLogger::generateDatedFileName(
time = mktime(&t) + offsetDays * 24 * 60 * 60;
t = *std::localtime(&time);
}
#pragma warning(pop)
std::wstringstream filename;
if (!prefix.empty())
@@ -79,7 +79,7 @@ void LogManagerImplementation::clearLoggers()
int LogManagerImplementation::getLoggerCount() const
{
std::lock_guard<std::mutex> lockGuard(m_loggerMutex);
return m_loggers.size();
return static_cast<int>(m_loggers.size());
}
void LogManagerImplementation::logInfo(
@@ -128,7 +128,12 @@ tm LogManagerImplementation::getTime()
{
time_t time;
std::time(&time);
#pragma warning(push)
#pragma warning(disable : 4996)
tm result = *std::localtime(&time); // this is done because localtime returns a pointer to a
// statically allocated object
#pragma warning(pop)
return result;
}
+2 -2
View File
@@ -70,7 +70,7 @@ void MatrixDynamicBase<T>::setValue(
template <class T>
unsigned int MatrixDynamicBase<T>::getColumnsCount() const
{
return m_values.size();
return static_cast<unsigned int>(m_values.size());
}
template <class T>
@@ -78,7 +78,7 @@ unsigned int MatrixDynamicBase<T>::getRowsCount() const
{
if (m_values.size() > 0)
{
return m_values[0].size();
return static_cast<unsigned int>(m_values[0].size());
}
return 0;
@@ -22,7 +22,7 @@ void TaskGroupParallel::doEnter(std::shared_ptr<Blackboard> blackboard)
if (m_needsToStartThreads)
{
m_needsToStartThreads = false;
m_activeTaskCount = m_tasks.size();
m_activeTaskCount = static_cast<int>(m_tasks.size());
for (size_t i = 0; i < m_tasks.size(); i++)
{
m_tasks[i]->active = true;
+1 -1
View File
@@ -81,7 +81,7 @@ TextAccess::~TextAccess() {}
unsigned int TextAccess::getLineCount() const
{
return m_lines.size();
return static_cast<unsigned int>(m_lines.size());
}
bool TextAccess::isEmpty() const
+2 -2
View File
@@ -119,12 +119,12 @@ void Tracer::printTraces()
if (p.second)
{
acc->event = event.get();
acc->time = event->time;
acc->time = static_cast<float>(event->time);
acc->count = 1;
}
else
{
acc->time += event->time;
acc->time += static_cast<float>(event->time);
acc->count++;
}
}
+4 -4
View File
@@ -7,9 +7,9 @@
unsigned long utility::getLargestByteSizeOfAllocatableMemory()
{
MEMORY_BASIC_INFORMATION mbi;
unsigned long start = 0;
__int64 start = 0;
bool recording = false;
unsigned long freestart = 0, largestFreestart = 0;
__int64 freestart = 0, largestFreestart = 0;
__int64 free = 0, largestFree = 0;
while (true)
@@ -39,10 +39,10 @@ unsigned long utility::getLargestByteSizeOfAllocatableMemory()
free = 0;
recording = false;
}
start += mbi.RegionSize;
start += static_cast<unsigned long>(mbi.RegionSize);
}
return largestFree;
return static_cast<unsigned int>(largestFree);
}
#endif // WIN32