This is an archive of the discontinued LLVM Phabricator instance.

[AST] Use IntrusiveRefCntPtr for Introspection LocationCall.
ClosedPublic

Authored by njames93 on Apr 13 2021, 5:09 AM.

Diff Detail

Event Timeline

njames93 requested review of this revision.Apr 13 2021, 5:09 AM
njames93 created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 13 2021, 5:09 AM
Herald added a subscriber: cfe-commits. · View Herald Transcript
njames93 added inline comments.Apr 13 2021, 6:05 AM
clang/lib/Tooling/NodeIntrospection.cpp
60

This is a slight change in behaviour, The old implementation used the operator< on a std::shared_ptr.
That in turns boils down to a comparison on the raw pointer, which is less than ideal.

dblaikie added inline comments.
clang/lib/Tooling/NodeIntrospection.cpp
60

Why is that less than ideal? Does the ordering need to be stable?

njames93 marked an inline comment as done.Apr 14 2021, 12:37 AM
njames93 added inline comments.
clang/lib/Tooling/NodeIntrospection.cpp
60

It's not strictly necessary that the ordering is stable. but when printing the contents of the map it would be nice if there was some obvious ordering. This also (partially) mimics the behaviour of the comparison for std::pair<SourceRange, SharedLocationCall>.

njames93 marked an inline comment as done.Apr 14 2021, 12:41 AM
dblaikie added inline comments.Apr 14 2021, 12:46 AM
clang/lib/Tooling/NodeIntrospection.cpp
60

seems like a strange tradeoff to me for the LLVM codebase - we have lots of unstable maps & don't try to make them nicer for printing - especially if that would come at any performance cost, like doing string comparisons.

Does the SourceRange+SharedLocationCall need stability?

njames93 marked an inline comment as done.Apr 14 2021, 1:04 AM
njames93 added inline comments.
clang/lib/Tooling/NodeIntrospection.cpp
60

The purpose behind this functionality is partly based on getting clang-query to show how to get display what source location accessors can be used for specific nodes(http://ce.steveire.com/z/V3k6Rl). As this is for a user facing and not a particularly hot path, I think its worth a couple extra cycles to give stability.

dblaikie added inline comments.Apr 14 2021, 1:13 AM
clang/lib/Tooling/NodeIntrospection.cpp
60

Oh. If this is user-facing then in must be stable/deterministic (for reproducibility, testing, etc).

Indeed, I just this evening discovered the need for this to be stable across runs for testing.

steveire accepted this revision.Apr 14 2021, 3:49 PM
This revision is now accepted and ready to land.Apr 14 2021, 3:49 PM
This revision was automatically updated to reflect the committed changes.
njames93 marked an inline comment as done.