diff --git a/mlir/include/mlir/Parser/AsmParserState.h b/mlir/include/mlir/Parser/AsmParserState.h --- a/mlir/include/mlir/Parser/AsmParserState.h +++ b/mlir/include/mlir/Parser/AsmParserState.h @@ -47,6 +47,9 @@ /// an input file. struct OperationDefinition { struct ResultGroupDefinition { + ResultGroupDefinition(unsigned index, llvm::SMRange loc) + : startIndex(index), definition(loc) {} + /// The result number that starts this group. unsigned startIndex; /// The source definition of the result group. @@ -67,7 +70,7 @@ llvm::SMRange scopeLoc; /// Source definitions for any result groups of this operation. - SmallVector> resultGroups; + SmallVector resultGroups; /// If this operation is a symbol operation, this vector contains symbol /// uses of this operation. diff --git a/mlir/lib/Parser/AsmParserState.cpp b/mlir/lib/Parser/AsmParserState.cpp --- a/mlir/lib/Parser/AsmParserState.cpp +++ b/mlir/lib/Parser/AsmParserState.cpp @@ -258,9 +258,9 @@ unsigned resultNo = result.getResultNumber(); OperationDefinition &def = *impl->operations[existingIt->second]; for (auto &resultGroup : llvm::reverse(def.resultGroups)) { - if (resultNo >= resultGroup.first) { + if (resultNo >= resultGroup.startIndex) { for (llvm::SMLoc loc : locations) - resultGroup.second.uses.push_back(convertIdLocToRange(loc)); + resultGroup.definition.uses.push_back(convertIdLocToRange(loc)); return; } } diff --git a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp --- a/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp +++ b/mlir/lib/Tools/mlir-lsp-server/MLIRServer.cpp @@ -367,7 +367,7 @@ if (contains(op.loc, posLoc)) return collectLocationsFromLoc(op.op->getLoc(), locations, uri); for (const auto &result : op.resultGroups) - if (containsPosition(result.second)) + if (containsPosition(result.definition)) return collectLocationsFromLoc(op.op->getLoc(), locations, uri); for (const auto &symUse : op.symbolUses) { if (contains(symUse, posLoc)) { @@ -404,15 +404,15 @@ for (const AsmParserState::OperationDefinition &op : asmState.getOpDefs()) { if (contains(op.loc, posLoc)) { for (const auto &result : op.resultGroups) - appendSMDef(result.second); + appendSMDef(result.definition); for (const auto &symUse : op.symbolUses) if (contains(symUse, posLoc)) references.push_back(getLocationFromLoc(sourceMgr, symUse, uri)); return; } for (const auto &result : op.resultGroups) - if (isDefOrUse(result.second, posLoc)) - return appendSMDef(result.second); + if (isDefOrUse(result.definition, posLoc)) + return appendSMDef(result.definition); for (const auto &symUse : op.symbolUses) { if (!contains(symUse, posLoc)) continue; @@ -456,13 +456,13 @@ // Check if the position points at a result group. for (unsigned i = 0, e = op.resultGroups.size(); i < e; ++i) { const auto &result = op.resultGroups[i]; - if (!isDefOrUse(result.second, posLoc, &hoverRange)) + if (!isDefOrUse(result.definition, posLoc, &hoverRange)) continue; // Get the range of results covered by the over position. - unsigned resultStart = result.first; - unsigned resultEnd = - (i == e - 1) ? op.op->getNumResults() : op.resultGroups[i + 1].first; + unsigned resultStart = result.startIndex; + unsigned resultEnd = (i == e - 1) ? op.op->getNumResults() + : op.resultGroups[i + 1].startIndex; return buildHoverForOperationResult(hoverRange, op.op, resultStart, resultEnd, posLoc); }