This is an archive of the discontinued LLVM Phabricator instance.

[clangd] Fix a crash bug in AddUsing tweak around template handling.
ClosedPublic

Authored by adamcz on Apr 7 2020, 8:51 AM.

Details

Summary

The crash happened on cases like:
template<typename TT> using one = two::three<T^T>;
because we tried to call getName() on getBaseTypeIdentifier(), which can
be nullptr.

Ideally we would support this use case as well, but for now not crashing
will do.

Diff Detail

Event Timeline

adamcz created this revision.Apr 7 2020, 8:51 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 7 2020, 8:51 AM
adamcz updated this revision to Diff 255694.Apr 7 2020, 8:52 AM

Removed unnecessary change.

sammccall accepted this revision.Apr 7 2020, 6:11 PM

Whoops, indeed.
There should be a version of falsehoods programmers believe about names for the clang AST :-)

  • Decls have names
  • well, NamedDecls have names
  • Decls that are not NamedDecls don't have names
  • if a NamedDecl has a name, that name is an identifier
  • ...
clang-tools-extra/clangd/refactor/tweaks/AddUsing.cpp
212

BaseTypeIdentifier->getName()

This revision is now accepted and ready to land.Apr 7 2020, 6:11 PM
adamcz updated this revision to Diff 255950.Apr 8 2020, 3:39 AM

review comment

adamcz marked an inline comment as done.Apr 8 2020, 3:40 AM

Can you submit this? Thanks!

This revision was automatically updated to reflect the committed changes.