Unfortunately, I don't have any good suggestions. Clang has basically no
reusable pragma parsing infrastructure. Nothing is consistent, because
we're parsing all pragmas that have ever seen any significant use. Aaron
has done a really good job cleaning up attributes, and I'd love to see the
same happen to pragmas. I tried once and it didn't go well.
I can give more precise details if necessary, but it's more a
general question to start.
Any recommendations on how to best handle two similar, but
incompatible sets of pragma?
Unfortunately, I don't have any good suggestions. Clang has basically no reusable pragma parsing infrastructure. Nothing is consistent, because we're parsing all pragmas that have ever seen any significant use. Aaron has done a really good job cleaning up attributes, and I'd love to see the same happen to pragmas. I tried once and it didn't go well.
Cool I tried rewriting the pragma parsers too once, using a templatized PEG.
It reduced implementing pragmas to a couple of lines. There are some really nice C++ templatized PEGs out there and in principle it should be possible to integrate them fully to achieve the same quality or better diagnostics as the hand-written code we have now.
We don't use parser generators for C++ but in theory there's nothing stopping us using them for the various other kinds of sub-grammars we encounter like pragmas which are trivial/regular in comparison.
Fun project for a rainy day perhaps, though contrary to the time-honoured LLVM tradition of hand-parsing.