This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Show better message when we rename macros.
ClosedPublic

Authored by hokein on Jun 28 2019, 1:54 AM.

Details

Summary

Previously, when we rename a macro, we get an error message of "there is
no symbol found".

This patch improves the message of this case (as we don't support macros).

Event Timeline

hokein created this revision.Jun 28 2019, 1:54 AM
Herald added a project: Restricted Project. · View Herald TranscriptJun 28 2019, 1:54 AM
sammccall accepted this revision.Jun 28 2019, 9:32 AM
sammccall added inline comments.
clang-tools-extra/clangd/SourceCode.cpp
661

"also" no longer makes sense here

clang-tools-extra/clangd/SourceCode.h
204

not sure about "sym" - it's an abbreviation and not very descriptive.
MacroDefinition is really the best name, but taken :-(

Maybe DefinedMacro or ResolvedMacro?

204

(thanks for moving this here, definitely makes sense!)

209

Can we add tests for this now that it's a public API?

210

you can get the SM and LangOpts from the PP

clang-tools-extra/clangd/refactor/Rename.cpp
167

is the fixme to detect the error, or to support renaming macros?
(And if we're not going to support them, why not?)

This revision is now accepted and ready to land.Jun 28 2019, 9:32 AM
hokein updated this revision to Diff 207244.Jul 1 2019, 1:59 AM
hokein marked 7 inline comments as done.

Address review comments:

  • renaming
  • add unittest
hokein added inline comments.Jul 1 2019, 2:00 AM
clang-tools-extra/clangd/SourceCode.h
204

DefinedMacro sounds good to me.

210

thanks, remove these two parameters.

clang-tools-extra/clangd/refactor/Rename.cpp
167

not sure whether we'd support renaming macros eventually, but I believe it is not prioritized at least for now. I think the macro-handling logic (detect the error, or support) should live in rename tooling library.

Rephrased the FIXME to make it less confusing.

This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptJul 1 2019, 2:26 AM