Skip to content

Commit 70d259c

Browse files
committed
---
yaml --- r: 343166 b: refs/heads/master-rebranch c: 89f89ab h: refs/heads/master
1 parent d73b642 commit 70d259c

File tree

3 files changed

+9
-20
lines changed

3 files changed

+9
-20
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1455,7 +1455,7 @@ refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-02-a: ddd2b2976aa9bfde5f20fe37f6bd2
14551455
refs/tags/swift-DEVELOPMENT-SNAPSHOT-2019-08-03-a: 171cc166f2abeb5ca2a4003700a8a78a108bd300
14561456
refs/heads/benlangmuir-patch-1: baaebaf39d52f3bf36710d4fe40cf212e996b212
14571457
refs/heads/i-do-redeclare: 8c4e6d5de5c1e3f0a2cedccf319df713ea22c48e
1458-
refs/heads/master-rebranch: 39e43d70d79c63e34bd8cd1cf328fef0c1c76547
1458+
refs/heads/master-rebranch: 89f89ab3e06038653ea6d38da855ce975c93cf08
14591459
refs/heads/rdar-53901732: 9bd06af3284e18a109cdbf9aa59d833b24eeca7b
14601460
refs/heads/revert-26776-subst-always-returns-a-type: 1b8e18fdd391903a348970a4c848995d4cdd789c
14611461
refs/heads/tensorflow-merge: 8b854f62f80d4476cb383d43c4aac2001dde3cec

branches/master-rebranch/include/swift/Index/IndexSymbol.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,7 @@ struct IndexSymbol : IndexRelation {
6666
SmallVector<IndexRelation, 3> Relations;
6767
unsigned line = 0;
6868
unsigned column = 0;
69-
unsigned startOffset = 0;
70-
unsigned endOffset = 0;
69+
unsigned offset = 0;
7170

7271
IndexSymbol() = default;
7372

branches/master-rebranch/lib/Index/Index.cpp

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,7 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
474474

475475
IndexSymbol Info;
476476
std::tie(Info.line, Info.column) = getLineCol(Loc);
477-
std::tie(Info.startOffset, Info.endOffset) =
478-
getRangeStartAndEndOffset(Range);
477+
Info.offset = getOffsetInBuffer(Loc);
479478
Info.roles |= (unsigned)SymbolRole::Reference;
480479
Info.symInfo = getSymbolInfoForModule(Mod);
481480
getModuleNameAndUSR(Mod, Info.name, Info.USR);
@@ -593,19 +592,10 @@ class IndexSwiftASTWalker : public SourceEntityWalker {
593592
return SrcMgr.getLineAndColumn(Loc, BufferID);
594593
}
595594

596-
std::pair<unsigned, unsigned> getRangeStartAndEndOffset(CharSourceRange Range) {
597-
if (Range.isInvalid())
598-
return std::make_pair(0, 0);
599-
unsigned offset = SrcMgr.getLocOffsetInBuffer(Range.getStart(), BufferID);
600-
unsigned length = SrcMgr.getByteDistance(Range.getStart(), Range.getEnd());
601-
return std::make_pair(offset, offset + length);
602-
}
603-
604-
std::pair<unsigned, unsigned> getLocStartAndEndOffset(SourceLoc Loc) {
595+
unsigned getOffsetInBuffer(SourceLoc Loc) {
605596
if (Loc.isInvalid())
606-
return std::make_pair(0, 0);
607-
return getRangeStartAndEndOffset(
608-
Lexer::getCharSourceRangeFromSourceRange(SrcMgr, SourceRange(Loc)));
597+
return 0;
598+
return SrcMgr.getLocOffsetInBuffer(Loc, BufferID);
609599
}
610600

611601
bool shouldIndex(ValueDecl *D, bool IsRef) const {
@@ -1243,7 +1233,7 @@ bool IndexSwiftASTWalker::initIndexSymbol(ValueDecl *D, SourceLoc Loc,
12431233
return true;
12441234

12451235
std::tie(Info.line, Info.column) = getLineCol(Loc);
1246-
std::tie(Info.startOffset, Info.endOffset) = getLocStartAndEndOffset(Loc);
1236+
Info.offset = getOffsetInBuffer(Loc);
12471237
if (!IsRef) {
12481238
if (auto Group = D->getGroupName())
12491239
Info.group = Group.getValue();
@@ -1265,7 +1255,7 @@ bool IndexSwiftASTWalker::initIndexSymbol(ExtensionDecl *ExtD, ValueDecl *Extend
12651255
return true;
12661256

12671257
std::tie(Info.line, Info.column) = getLineCol(Loc);
1268-
std::tie(Info.startOffset, Info.endOffset) = getLocStartAndEndOffset(Loc);
1258+
Info.offset = getOffsetInBuffer(Loc);
12691259
if (auto Group = ExtD->getGroupName())
12701260
Info.group = Group.getValue();
12711261
return false;
@@ -1473,7 +1463,7 @@ bool IndexSwiftASTWalker::indexComment(const Decl *D) {
14731463
Info.USR = stringStorage.copyString(OS.str());
14741464
}
14751465
std::tie(Info.line, Info.column) = getLineCol(loc);
1476-
std::tie(Info.startOffset, Info.endOffset) = getLocStartAndEndOffset(loc);
1466+
Info.offset = getOffsetInBuffer(loc);
14771467
if (!IdxConsumer.startSourceEntity(Info) || !IdxConsumer.finishSourceEntity(Info.symInfo, Info.roles)) {
14781468
Cancelled = true;
14791469
break;

0 commit comments

Comments
 (0)