This is an archive of the discontinued LLVM Phabricator instance.

[analyzer] CallDescription: Improve array management.
ClosedPublic

Authored by NoQ on Aug 28 2018, 4:31 PM.

Details

Summary

CallDescription constructor now accepts an ArrayRef<const char *>, instead of two different constructors for StringRef and std::vector<StringRef>.

This allows us to write an init-list of a vector of CallDescription objects as:

vector<CallDescription> V = {
  { { "foo" }, 1 },
  { { "q1", "q2", "bar" }, 2 },
  ...
};

achieving uniformity between unqualified and qualified descriptions, while still allowing the old syntax of { "foo", 1 } (without braces around "foo"). Previously { { "foo" }, 1 } wouldn't have compiled, because the compiler was unable to figure out which constructor to call (because {} are allowed to be omitted or added indefinitely as a redundancy).

As a cost of that, i had to switch from StringRefs to raw pointers, because you can't automatically convert an initializer-list of C strings to an ArrayRef of StringRefs. But that doesn't seem bad, because StringRefs aren't that much different from raw pointers, and in practice only static strings will be used.

Also squash a mutable copy of that array.

Diff Detail

Repository
rC Clang

Event Timeline

NoQ created this revision.Aug 28 2018, 4:31 PM
NoQ added a reviewer: MTC.Aug 29 2018, 3:45 PM
george.karpenkov accepted this revision.Aug 29 2018, 3:54 PM
This revision is now accepted and ready to land.Aug 29 2018, 3:54 PM

Strictly speaking those two seem like completely unrelated changes , right?

NoQ added a comment.Aug 29 2018, 3:57 PM

Yeah, i guess i should've split those up.

Well, i had to fix the other code when i fixed the first code, because it contains a hardcoded duplicate of the vector type. So i decided to fix it in a slightly more intelligent manner.

MTC accepted this revision.Aug 29 2018, 7:17 PM

Thank you for digging in to delete that meaningless constructor, NoQ! And sorry for my technology debt : ).

This revision was automatically updated to reflect the committed changes.