forked from qt-creator/qt-creator
ClangTools: Get rid of some dynamic_casts
Change-Id: I5b6ebbf993fdf9954f7c5df66a09266b6b155aaf Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -623,9 +623,10 @@ bool DiagnosticFilterModel::filterAcceptsRow(int sourceRow,
|
|||||||
|
|
||||||
// DiagnosticItem
|
// DiagnosticItem
|
||||||
Utils::TreeItem *parentItem = model->itemForIndex(sourceParent);
|
Utils::TreeItem *parentItem = model->itemForIndex(sourceParent);
|
||||||
if (auto filePathItem = dynamic_cast<FilePathItem *>(parentItem)) {
|
QTC_ASSERT(parentItem, return true);
|
||||||
auto diagnosticItem = dynamic_cast<DiagnosticItem *>(filePathItem->childAt(sourceRow));
|
if (parentItem->level() == 1) {
|
||||||
QTC_ASSERT(diagnosticItem, return false);
|
auto filePathItem = static_cast<FilePathItem *>(parentItem);
|
||||||
|
auto diagnosticItem = static_cast<DiagnosticItem *>(filePathItem->childAt(sourceRow));
|
||||||
|
|
||||||
// Is the diagnostic explicitly suppressed?
|
// Is the diagnostic explicitly suppressed?
|
||||||
const Diagnostic &diag = diagnosticItem->diagnostic();
|
const Diagnostic &diag = diagnosticItem->diagnostic();
|
||||||
@@ -651,11 +652,12 @@ bool DiagnosticFilterModel::lessThan(const QModelIndex &l, const QModelIndex &r)
|
|||||||
{
|
{
|
||||||
auto model = static_cast<ClangToolsDiagnosticModel *>(sourceModel());
|
auto model = static_cast<ClangToolsDiagnosticModel *>(sourceModel());
|
||||||
Utils::TreeItem *itemLeft = model->itemForIndex(l);
|
Utils::TreeItem *itemLeft = model->itemForIndex(l);
|
||||||
const bool isComparingDiagnostics = !dynamic_cast<FilePathItem *>(itemLeft);
|
QTC_ASSERT(itemLeft, return QSortFilterProxyModel::lessThan(l, r));
|
||||||
|
const bool isComparingDiagnostics = itemLeft->level() > 1;
|
||||||
|
|
||||||
if (sortColumn() == Debugger::DetailedErrorView::DiagnosticColumn && isComparingDiagnostics) {
|
if (sortColumn() == Debugger::DetailedErrorView::DiagnosticColumn && isComparingDiagnostics) {
|
||||||
bool result = false;
|
bool result = false;
|
||||||
if (dynamic_cast<DiagnosticItem *>(itemLeft)) {
|
if (itemLeft->level() == 2) {
|
||||||
using Debugger::DiagnosticLocation;
|
using Debugger::DiagnosticLocation;
|
||||||
const int role = Debugger::DetailedErrorView::LocationRole;
|
const int role = Debugger::DetailedErrorView::LocationRole;
|
||||||
|
|
||||||
@@ -669,8 +671,11 @@ bool DiagnosticFilterModel::lessThan(const QModelIndex &l, const QModelIndex &r)
|
|||||||
|
|
||||||
result = std::tie(leftLoc.line, leftLoc.column, leftText)
|
result = std::tie(leftLoc.line, leftLoc.column, leftText)
|
||||||
< std::tie(rightLoc.line, rightLoc.column, rightText);
|
< std::tie(rightLoc.line, rightLoc.column, rightText);
|
||||||
} else if (auto left = dynamic_cast<ExplainingStepItem *>(itemLeft)) {
|
} else if (itemLeft->level() == 3) {
|
||||||
const auto right = dynamic_cast<ExplainingStepItem *>(model->itemForIndex(r));
|
Utils::TreeItem *itemRight = model->itemForIndex(r);
|
||||||
|
QTC_ASSERT(itemRight, QSortFilterProxyModel::lessThan(l, r));
|
||||||
|
const auto left = static_cast<ExplainingStepItem *>(itemLeft);
|
||||||
|
const auto right = static_cast<ExplainingStepItem *>(itemRight);
|
||||||
result = left->index() < right->index();
|
result = left->index() < right->index();
|
||||||
} else {
|
} else {
|
||||||
QTC_CHECK(false && "Unexpected item");
|
QTC_CHECK(false && "Unexpected item");
|
||||||
|
Reference in New Issue
Block a user