This is an archive of the discontinued LLVM Phabricator instance.

[clang-include-cleaner] make SymbolLocation a real class, move FindHeaders
ClosedPublic

Authored by sammccall on Nov 11 2022, 3:41 AM.

Details

Summary
  • replace SymbolLocation std::variant with enum-exposing version similar to those in types.cpp. There's no appropriate implementation file, added LocateSymbol.cpp in anticipation of locateDecl/locateMacro.
  • FindHeaders is not part of the public Analysis interface, so should not be implemented/tested there (just code organization)
  • rename findIncludeHeaders->findHeaders to avoid confusion with Include concept

Diff Detail

Event Timeline

sammccall created this revision.Nov 11 2022, 3:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 3:41 AM
sammccall requested review of this revision.Nov 11 2022, 3:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 11 2022, 3:41 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript

You could:

static_assert(std::variant_size_v<....> == 2);

Kind kind() const { if (std::holds_alternative<SourceLocation>(Storage))  return Kind::Physical; return Kind::Standard; }

and Kind could become enum class Kind. => You would get rid of the order on the variant and the static_cast.

You could:

static_assert(std::variant_size_v<....> == 2);

Kind kind() const { if (std::holds_alternative<SourceLocation>(Storage))  return Kind::Physical; return Kind::Standard; }

and Kind could become enum class Kind. => You would get rid of the order on the variant and the static_cast.

Sure, but that's IMO less regular, harder to understand, and easier to get wrong when updating.

kadircet accepted this revision.Nov 11 2022, 4:41 AM

thanks!

This revision is now accepted and ready to land.Nov 11 2022, 4:41 AM
This revision was landed with ongoing or failed builds.Nov 11 2022, 4:42 AM
This revision was automatically updated to reflect the committed changes.