Check whether the string (db.names.back().first) is longer than 7 characters before inserting another string at index 8.
Could you please add more context lines in any future patches? Makes it easier to review!
I think we fixed the same problem at the same time, I have https://reviews.llvm.org/D33368 that also fixes this! The reason that inserting into db.names.back() sometimes results in a insertion out of bounds is that parse_type() can sometimes append multiple names into db.names (ie for a reference to a pack expansion). This results in db.names.back() no longer being the text 'lambda, which makes inserting at +7 dangerous. I think we should handle this case by appending them one by one into the lambda's parameters, which is what my patch does. Do you agree that this is the right approach here?
We shouldn't make progress here if something invalid happened, if the names.back().size() is less than 7 then we should just bail out and return first.
You could append my test case as a quick-check.
Sure, I added the test case here to my patch and it works.
So, I'll go ahead and abandon this revision?
Guess so, sorry for the confusion here.
but having a constant like this ("7") sounds wrong. Why not 6, or 8, or 42?
7 is correct here because we inserting into a specific point into a string that was inserted into db.names just above this (but out of context from the diff). The only problem is that more stuff was inserted in the meantime.
This is horrible, but the demangler is littered with random offsets. My personal favorite is that const, volatile, and restrict aren't represented with an enum, but just with the literals 1, 2, and 4.