This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Use name of Macro to compute its SymbolID.
ClosedPublic

Authored by usaxena95 on Nov 7 2019, 3:08 AM.

Details

Summary

We use the name from the IdentifierInfo of the Macro to compute its
SymbolID. It is better to just take the Name as a parameter to avoid
storing the IdentifierInfo whenever we need the SymbolID for the Macro.

Diff Detail

Event Timeline

usaxena95 created this revision.Nov 7 2019, 3:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 7 2019, 3:08 AM
hokein accepted this revision.Nov 7 2019, 3:59 AM

there are some unrelated changes in this patch (probably trigger by your editor setting?), though they are trivial, I would avoid these changes in a same patch.

clang-tools-extra/clangd/AST.cpp
238

hmm, this is a unrelated change.

clang-tools-extra/clangd/CodeComplete.cpp
1769

same here.

This revision is now accepted and ready to land.Nov 7 2019, 3:59 AM
usaxena95 updated this revision to Diff 228220.Nov 7 2019, 5:01 AM

Addressed comments.

usaxena95 marked 2 inline comments as done.Nov 7 2019, 5:02 AM

Does that mean we identify each macro merely by its name?
It's not uncommon to have multiple #define for the same name, meaning completely different things.

If find references shows all of those, it's not very useful...

hokein added a comment.Nov 7 2019, 6:41 AM

Does that mean we identify each macro merely by its name?
It's not uncommon to have multiple #define for the same name, meaning completely different things.

If find references shows all of those, it's not very useful...

no, I would say this patch is NFC, we still construct macro symbol id with macro name and definition location.

We actually use both the name and the source location of the macro to calculate its ID.
I see that the subject of the patch might suggest otherwise.
This is a trivial change which just changes the params of the function so that users don't have to carry the IdentifierInfo when we just want the name out of it.

We use clang::index::generateUSRForMacro(StringRef MacroName, SourceLocation Loc, const SourceManager &SM, SmallVectorImpl<char> &Buf) to generate the SymbolID.

Sorry for not reading through and assuming the wrong thing from the title. Thanks for the explanation! LG

usaxena95 updated this revision to Diff 228430.Nov 8 2019, 6:01 AM
  • [clangd] Store xref for Macros in ParsedAST.
usaxena95 updated this revision to Diff 228431.Nov 8 2019, 6:06 AM

Hopefully reverting unintended changes.

This revision was automatically updated to reflect the committed changes.