This should make us print the right capability kind in many more cases,
especially when attributes name multiple capabilities of different kinds.
Previously we were trying to deduce the capability kind from the
original attribute, but most attributes can name multiple capabilities,
which could be of different kinds. So instead we derive the kind when
translating the attribute expression, and then store it in the returned
CapabilityExpr. Then we can extract the corresponding capability name
when we need it, which saves us lots of plumbing and almost guarantees
that the name is right.
I didn't bother adding any tests for this because it's just a usability
improvement and it's pretty much evident from the code that we don't
fall back to "mutex" anymore (save for a few cases that I'll address in
a separate change).
Hrmmmm, I think this may actually be safe, but it does give me pause to store a StringRef as anything other than a local (or param/return type): https://llvm.org/docs/ProgrammersManual.html#the-stringref-class
Can you double-check my thinking? This is fine because it's pulling the StringRef from the CapabilityAttr, and that stores its name internally and isn't released until the AST is destroyed.