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 18
18
namespace clang {
19
19
namespace clangd {
20
20
21
- Range MacroOccurrence::toRange (const SourceManager &SM) const {
21
+ CharSourceRange MacroOccurrence::toSourceRange (const SourceManager &SM) const {
22
22
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));
25
28
}
26
29
27
30
void CollectMainFileMacros::add (const Token &MacroNameTok, const MacroInfo *MI,
Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ struct MacroOccurrence {
31
31
// True if the occurence is used in a conditional directive, e.g. #ifdef MACRO
32
32
bool InConditionalDirective;
33
33
34
+ CharSourceRange toSourceRange (const SourceManager &SM) const ;
34
35
Range toRange (const SourceManager &SM) const ;
35
36
};
36
37
Original file line number Diff line number Diff line change @@ -713,7 +713,8 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
713
713
// Add macro references.
714
714
for (const auto &IDToRefs : MacroRefsToIndex.MacroRefs ) {
715
715
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);
717
718
bool IsDefinition = MacroRef.IsDefinition ;
718
719
Ref R;
719
720
R.Location .Start .setLine (Range.start .line );
@@ -726,9 +727,7 @@ void SymbolCollector::handleMacros(const MainFileMacros &MacroRefsToIndex) {
726
727
if (IsDefinition) {
727
728
Symbol S;
728
729
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 ());
732
731
S.SymInfo .Kind = index::SymbolKind::Macro;
733
732
S.SymInfo .SubKind = index::SymbolSubKind::None;
734
733
S.SymInfo .Properties = index::SymbolPropertySet ();
You can’t perform that action at this time.
0 commit comments