[cfe-commits] [PATCH] Revised patch for generating diagnostics information for crashing clang

Chad Rosier mcrosier at apple.com
Fri Aug 12 15:55:25 PDT 2011


On Aug 8, 2011, at 10:21 AM, Chad Rosier wrote:

>> 
>> Unless there's something non-obvious (which could be commented, if
>> that's the case) you could use the iterator returned by erase:
>> 
>> for (iterator it = begin(), ie = end(); it != ie; ) {
>> if ((*it)->getOption().matches(Id)) {
>>   it = Args.erase(it);
>> } else {
>>   ++it;
>> }
>> }
> 
> I committed the above in revision 137051.  The args list should be relatively short, so this solution is good.

David,
I ran into another case where such a loop was useful.  However, using code similar to the above 
resulted in an infinite loop in this case.  After the Args.erase(it) I believe it is necessary to update ie.

Something like this:

for (InputList::iterator it = Inputs.begin(), ie = Inputs.end(); it != ie;) {
  if (types::getPreprocessedType(it->first) == types::TY_INVALID) {
    it = Inputs.erase(it);
    ie = Inputs.end();
  } else
    ++it;
}

 Chad
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20110812/e07d91f7/attachment.html>


More information about the cfe-commits mailing list