Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.

llvm-svn: 59664
This commit is contained in:
Steve Naroff 2008-11-19 21:15:47 +00:00
parent 91cea0ad1e
commit dbfc693f47
2 changed files with 25 additions and 2 deletions

View File

@ -1572,9 +1572,21 @@ bool RewriteObjC::needToScanForQualifiers(QualType T) {
void RewriteObjC::RewriteObjCQualifiedInterfaceTypes(Expr *E) {
QualType Type = E->getType();
if (needToScanForQualifiers(Type)) {
SourceLocation Loc = E->getLocStart();
SourceLocation Loc, EndLoc;
if (const CStyleCastExpr *ECE = dyn_cast<CStyleCastExpr>(E)) {
Loc = ECE->getLParenLoc();
EndLoc = ECE->getRParenLoc();
} else {
Loc = E->getLocStart();
EndLoc = E->getLocEnd();
}
// This will defend against trying to rewrite synthesized expressions.
if (Loc.isInvalid() || EndLoc.isInvalid())
return;
const char *startBuf = SM->getCharacterData(Loc);
const char *endBuf = SM->getCharacterData(E->getLocEnd());
const char *endBuf = SM->getCharacterData(EndLoc);
const char *startRef = 0, *endRef = 0;
if (scanForProtocolRefs(startBuf, endBuf, startRef, endRef)) {
// Get the locations of the startRef, endRef.

View File

@ -12,3 +12,14 @@ int main() {
return 0;
}
// rdar://6291588
@protocol A
@end
@interface Foo
@end
void func() {
id <A> obj = (id <A>)[Foo bar];
}