<div dir="ltr">Yes, this makes sense. I think exposing just the names is a bit "clever".<div><br></div><div>If we changed the internal structure to be an array of struct {<div>  StringRef Name;</div><div>  StringRef Payload;</div><div>  size_t Start;</div><div>  size_t End; // -1 for a point</div><div>}</div><div>Then how do you feel if we expose that array and drop the current maps?</div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Nov 17, 2022 at 2:16 PM Eric Li via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">li.zhe.hua added a comment.<br>
<br>
So the two functions I added were because previously using `Annotations` required knowledge of the annotation names a priori. If you are constructing one and using it directly yourself in a test, great. If you handed the `Annotations` object to a helper function, you'd also need to hand the two sets of names with it (one for points and one for ranges), otherwise the helper function doesn't know what annotations exist. In our case, the helper function is a googletest matcher verifying matches on AST nodes are bound to IDs matching the annotations listed. However, if no nodes are matched, we can't verify that all annotated nodes were matched without a lot of extra (possibly error-prone) boilerplate.<br>
<br>
Ultimately, we only really need the names. Returning the full map was mostly for simplicity (if you want all the names, you probably will query all the values eventually), but really the key (... heh) piece of data we need is the names from the maps.<br>
<br>
<br>
Repository:<br>
  rG LLVM Github Monorepo<br>
<br>
CHANGES SINCE LAST ACTION<br>
  <a href="https://reviews.llvm.org/D134072/new/" rel="noreferrer" target="_blank">https://reviews.llvm.org/D134072/new/</a><br>
<br>
<a href="https://reviews.llvm.org/D134072" rel="noreferrer" target="_blank">https://reviews.llvm.org/D134072</a><br>
<br>
</blockquote></div>