File tree Expand file tree Collapse file tree 2 files changed +12
-21
lines changed Expand file tree Collapse file tree 2 files changed +12
-21
lines changed Original file line number Diff line number Diff line change @@ -890,24 +890,15 @@ std::vector<DocumentLink> getDocumentLinks(ParsedAST &AST) {
890890 FileRange = FileTok->range (SM).toCharRange (SM);
891891 } else {
892892 // FileTok is the first Token of a macro spelling
893- // We can use the AST to get the macro expansion from the spelling
894- // starting at FileTok and use the expansion to get all the spelled Tokens
895- // that expanded to it
896-
897- auto OptExpansion = AST.getTokens ().expansionStartingAt (FileTok);
898- if (OptExpansion && !OptExpansion->Spelled .empty ()) {
899- // If an expansion was found and has an non-empty spelling, return the
900- // range from the start of the first Token to the end of the last Token
901- const auto &LastTok = OptExpansion->Spelled .back ();
902-
903- FileRange = FileTok->range (SM).toCharRange (SM);
904- const auto EndRange = LastTok.range (SM).toCharRange (SM);
905- FileRange.setEnd (EndRange.getEnd ());
906- } else {
907- // We failed to find a macro expansion from the spelling
908- // fallback to FileTok->range
909- FileRange = FileTok->range (SM).toCharRange (SM);
910- }
893+
894+ // Report the range of the first token (as it should be the macro
895+ // identifier)
896+ // We could use the AST to find the last spelled token of the macro and
897+ // report a range spanning the full macro expression, but it would require
898+ // using token-buffers that are deemed too unstable and crash-prone
899+ // due to optimizations in cland
900+
901+ FileRange = FileTok->range (SM).toCharRange (SM);
911902 }
912903
913904 Result.push_back (
Original file line number Diff line number Diff line change @@ -2783,11 +2783,11 @@ TEST(DocumentLinks, All) {
27832783 #/*comments*/include /*comments*/ $foo[["foo.h"]] //more comments
27842784 int end_of_preamble = 0;
27852785 #include $bar[[<bar.h>]]
2786- #include $AA[[GET_HEADER(AA)]] // Some comment !
2786+ #include $AA[[GET_HEADER]] (AA) // Some comment !
27872787 # /* What about */ \
27882788 include /* multiple line */ \
2789- $BB[[GET_HEADER( /* statements ? */ \
2790- BB /* >>>> Hey ! Dont go further ! this ')' is the last token of the file ! >>>> */ )]]
2789+ $BB[[GET_HEADER]] ( /* statements ? */ \
2790+ BB /* :) */ )
27912791 )cpp" );
27922792
27932793 TestTU TU;
You can’t perform that action at this time.
0 commit comments