diff options
| author | Steve Naroff <snaroff@apple.com> | 2008-11-19 21:15:47 +0000 |
|---|---|---|
| committer | Steve Naroff <snaroff@apple.com> | 2008-11-19 21:15:47 +0000 |
| commit | dbfc693f475a44045f0eba79eabdf8205ca223a1 (patch) | |
| tree | 5af61f15a5aefcb42844269109bc3e9a5afc34d6 | |
| parent | 91cea0ad1e4cdec5886dfb3cf805bb116fc24e0a (diff) | |
| download | bcm5719-llvm-dbfc693f475a44045f0eba79eabdf8205ca223a1.tar.gz bcm5719-llvm-dbfc693f475a44045f0eba79eabdf8205ca223a1.zip | |
Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.
llvm-svn: 59664
| -rw-r--r-- | clang/Driver/RewriteObjC.cpp | 16 | ||||
| -rw-r--r-- | clang/test/Rewriter/crash.m | 11 |
2 files changed, 25 insertions, 2 deletions
diff --git a/clang/Driver/RewriteObjC.cpp b/clang/Driver/RewriteObjC.cpp index 804a891f6b6..a3ce8a8c569 100644 --- a/clang/Driver/RewriteObjC.cpp +++ b/clang/Driver/RewriteObjC.cpp @@ -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. diff --git a/clang/test/Rewriter/crash.m b/clang/test/Rewriter/crash.m index 59f18f37c2c..2e34850e968 100644 --- a/clang/test/Rewriter/crash.m +++ b/clang/test/Rewriter/crash.m @@ -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]; +} + |

