File tree Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Expand file tree Collapse file tree 3 files changed +10
-7
lines changed Original file line number Diff line number Diff line change 1818namespace clang {
1919namespace clangd {
2020
21- Range MacroOccurrence::toRange (const SourceManager &SM) const {
21+ CharSourceRange MacroOccurrence::toSourceRange (const SourceManager &SM) const {
2222 auto MainFile = SM.getMainFileID ();
23- return halfOpenToRange (
24- SM, syntax::FileRange (MainFile, StartOffset, EndOffset).toCharRange (SM));
23+ return syntax::FileRange (MainFile, StartOffset, EndOffset).toCharRange (SM);
24+ }
25+
26+ Range MacroOccurrence::toRange (const SourceManager &SM) const {
27+ return halfOpenToRange (SM, toSourceRange (SM));
2528}
2629
2730void CollectMainFileMacros::add (const Token &MacroNameTok, const MacroInfo *MI,
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ struct MacroOccurrence {
3131 // True if the occurence is used in a conditional directive, e.g. #ifdef MACRO
3232 bool InConditionalDirective;
3333
34+ CharSourceRange toSourceRange (const SourceManager &SM) const ;
3435 Range toRange (const SourceManager &SM) const ;
3536};
3637
Original file line number Diff line number Diff line change @@ -713,7 +713,8 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
713713 // Add macro references.
714714 for (const auto &IDToRefs : MacroRefsToIndex.MacroRefs ) {
715715 for (const auto &MacroRef : IDToRefs.second ) {
716- const auto &Range = MacroRef.toRange (SM);
716+ const auto &SR = MacroRef.toSourceRange (SM);
717+ auto Range = halfOpenToRange (SM, SR);
717718 bool IsDefinition = MacroRef.IsDefinition ;
718719 Ref R;
719720 R.Location .Start .setLine (Range.start .line );
@@ -726,9 +727,7 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
726727 if (IsDefinition) {
727728 Symbol S;
728729 S.ID = IDToRefs.first ;
729- auto StartLoc = cantFail (sourceLocationInMainFile (SM, Range.start ));
730- auto EndLoc = cantFail (sourceLocationInMainFile (SM, Range.end ));
731- S.Name = toSourceCode (SM, SourceRange (StartLoc, EndLoc));
730+ S.Name = toSourceCode (SM, SR.getAsRange ());
732731 S.SymInfo .Kind = index::SymbolKind::Macro;
733732 S.SymInfo .SubKind = index::SymbolSubKind::None;
734733 S.SymInfo .Properties = index::SymbolPropertySet ();
You can’t perform that action at this time.
0 commit comments