Prevent rewriter crash when variable type is missing.

Fixes radar 7692183.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@97281 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Fariborz Jahanian 2010-02-26 22:49:11 +00:00
Родитель 1276bfe0ce
Коммит d64a4f4798
2 изменённых файлов: 7 добавлений и 0 удалений

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

@ -4781,6 +4781,10 @@ void RewriteObjC::RewriteByRefVar(VarDecl *ND) {
int flag = 0;
int isa = 0;
SourceLocation DeclLoc = ND->getTypeSpecStartLoc();
if (DeclLoc.isInvalid())
// If type location is missing, it is because of missing type (a warning).
// Use variable's location which is good for this case.
DeclLoc = ND->getLocation();
const char *startBuf = SM->getCharacterData(DeclLoc);
SourceLocation X = ND->getLocEnd();
X = SM->getInstantiationLoc(X);

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

@ -13,10 +13,13 @@ void f(void (^block)(void));
@implementation X
- (void)foo {
__block int kerfluffle;
// radar 7692183
__block x;
f(^{
f(^{
y = 42;
kerfluffle = 1;
x = 2;
});
});
}