DiagnosticIDs::getDiagnosticSeverity function turns out to take a lot of time in getDecomposedLoc. It is called quite often from different places. (For example from Sema::CheckTemplateArgument which attempt to emit warn_cxx98_compat_* diagnostics.)
In most cases, the diagnostics are not overridden by pragmas and the mapping from the command line is good enough. This commit adds a bit in the the first mapping which specify if we should look up the real mapping.
This saves more than 5% of the parsing time according to perf.
I think it would be better if you wrap this piece of code in a static function that returns DiagnosticMapping &, as it should allow you to get rid of all these . to -> changes below.