This is a very preliminary proposal to introduce a message table that would let us replace hard-coded strings with an identifier. The basic idea is that instead of something like this:
ORE->emit([&]() {
return OptimizationRemark(DEBUG_TYPE, "LoadElim", LI)
<< "load of type " << NV("Type", LI->getType()) << " eliminated"
<< setExtraArgs() << " in favor of "
<< NV("InfavorOfValue", AvailableValue);
});We'd be able to have something like this:
ORE->emit([&]() {
return OptimizationRemark(DEBUG_TYPE, diag::remark_gvn_load_elim, LI)
<< NV("Type", LI->getType())
<< setExtraArgs() << NV("InfavorOfValue", AvailableValue);
});I think this opens up a lot of possibilities for more compact storage of remarks and more reliable identification of remarks in the DiagHandler. It also brings up a lot of questions about how much of the information that is currently part of the OptimizationRemark class (and its siblings) should be part of the message table. I hope to discuss that in this review.
What would be the use case of these enums? Can't the same be achieved by not quoting RemarkName and Test1 in the OPT_REMARK( macros like in clang/include/clang/Driver/Options.h:
enum ID { OPT_INVALID = 0, // This is not an option ID. #define OPTION(PREFIX, NAME, ID, KIND, GROUP, ALIAS, ALIASARGS, FLAGS, PARAM, \ HELPTEXT, METAVAR, VALUES) \ OPT_##ID, #include "clang/Driver/Options.inc" LastOption #undef OPTION };