Skip to content

Commit 6b36996

Browse files
committed
[NFC] Refactor setLocationInfo to return LocationInfo instead
1 parent 44aba13 commit 6b36996

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

tools/SourceKit/lib/SwiftLang/SwiftSourceDocInfo.cpp

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -900,8 +900,8 @@ static void setLocationInfoForRange(SourceManager &SM, SourceRange R,
900900
SM.getLineAndColumnInBuffer(CR.getStart(), BufID);
901901
}
902902

903-
static void setLocationInfo(const ValueDecl *VD,
904-
LocationInfo &Location) {
903+
static LocationInfo getDeclLocationInfo(const ValueDecl *VD) {
904+
LocationInfo Location;
905905
ASTContext &Ctx = VD->getASTContext();
906906
SourceManager &SM = Ctx.SourceMgr;
907907
auto *Importer = static_cast<ClangImporter *>(Ctx.getClangModuleLoader());
@@ -963,19 +963,19 @@ static void setLocationInfo(const ValueDecl *VD,
963963
// original file might be tricky.
964964
setLocationInfoForRange(SM, VDRange, VDBufID, Location);
965965
}
966-
return;
966+
return Location;
967967
case GeneratedSourceInfo::AttributeFromClang:
968968
// This buffer was generated for an imported ClangNode, so set location
969969
// info according to that.
970970
if (auto node = info->clangNode)
971971
setLocationInfoForClangNode(node, Importer, Location);
972972
else
973973
setLocationInfoForRange(SM, VDRange, VDBufID, Location);
974-
return;
974+
return Location;
975975
case GeneratedSourceInfo::DefaultArgument:
976976
case GeneratedSourceInfo::PrettyPrinted:
977977
setLocationInfoForRange(SM, VDRange, VDBufID, Location);
978-
return;
978+
return Location;
979979
}
980980
llvm_unreachable("All switch cases either explicitly continue or return");
981981
}
@@ -984,6 +984,7 @@ static void setLocationInfo(const ValueDecl *VD,
984984
} else if (auto CNode = VD->getClangNode()) {
985985
setLocationInfoForClangNode(CNode, Importer, Location);
986986
}
987+
return Location;
987988
}
988989

989990
static llvm::Error
@@ -1142,7 +1143,7 @@ fillSymbolInfo(CursorSymbolInfo &Symbol, const DeclInfo &DInfo,
11421143
Lang.getIFaceGenContexts().find(Symbol.ModuleName, Invoc))
11431144
Symbol.ModuleInterfaceName = IFaceGenRef->getDocumentName();
11441145

1145-
setLocationInfo(DInfo.OriginalProperty, Symbol.Location);
1146+
Symbol.Location = getDeclLocationInfo(DInfo.OriginalProperty);
11461147
if (!Symbol.Location.Filename.empty()) {
11471148
mapLocToLatestSnapshot(Lang, Symbol.Location, PreviousSnaps);
11481149
if (Symbol.Location.Filename.empty()) {

0 commit comments

Comments
 (0)