fix an inconsistency computing offsets that caused a crash on rewrite-nest.m

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@51514 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-05-23 23:06:56 +00:00
Родитель cfd4c7bef7
Коммит 9ed7cfd351
2 изменённых файлов: 30 добавлений и 1 удалений

Просмотреть файл

@ -52,7 +52,7 @@ void RewriteBuffer::InsertText(unsigned OrigOffset,
/// operation. /// operation.
void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength, void RewriteBuffer::ReplaceText(unsigned OrigOffset, unsigned OrigLength,
const char *NewStr, unsigned NewLength) { const char *NewStr, unsigned NewLength) {
unsigned RealOffset = getMappedOffset(OrigOffset, true); unsigned RealOffset = getMappedOffset(OrigOffset, false);
Buffer.erase(RealOffset, OrigLength); Buffer.erase(RealOffset, OrigLength);
Buffer.insert(RealOffset, NewStr, NewStr+NewLength); Buffer.insert(RealOffset, NewStr, NewStr+NewLength);
if (OrigLength != NewLength) if (OrigLength != NewLength)

Просмотреть файл

@ -0,0 +1,29 @@
// RUN: clang -rewrite-objc %s -o =-
#include <objc/objc.h>
@interface NSMapTable @end
@interface NSEnumerator @end
typedef unsigned int NSUInteger;
@interface NSConcreteMapTable : NSMapTable {
@public
NSUInteger capacity;
}
@end
@interface NSConcreteMapTableValueEnumerator : NSEnumerator {
NSConcreteMapTable *mapTable;
}
@end
@implementation NSConcreteMapTableValueEnumerator
- nextObject {
while (mapTable->capacity) {
}
return 0;
}
@end