[cfe-commits] r59664 - in /cfe/trunk: Driver/RewriteObjC.cpp test/Rewriter/crash.m
Steve Naroff
snaroff at apple.com
Wed Nov 19 13:15:47 PST 2008
Author: snaroff
Date: Wed Nov 19 15:15:47 2008
New Revision: 59664
URL: http://llvm.org/viewvc/llvm-project?rev=59664&view=rev
Log:
Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.
Modified:
cfe/trunk/Driver/RewriteObjC.cpp
cfe/trunk/test/Rewriter/crash.m
Modified: cfe/trunk/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/Driver/RewriteObjC.cpp?rev=59664&r1=59663&r2=59664&view=diff
==============================================================================
--- cfe/trunk/Driver/RewriteObjC.cpp (original)
+++ cfe/trunk/Driver/RewriteObjC.cpp Wed Nov 19 15:15:47 2008
@@ -1572,9 +1572,21 @@
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.
Modified: cfe/trunk/test/Rewriter/crash.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Rewriter/crash.m?rev=59664&r1=59663&r2=59664&view=diff
==============================================================================
--- cfe/trunk/test/Rewriter/crash.m (original)
+++ cfe/trunk/test/Rewriter/crash.m Wed Nov 19 15:15:47 2008
@@ -12,3 +12,14 @@
return 0;
}
+// rdar://6291588
+ at protocol A
+ at end
+
+ at interface Foo
+ at end
+
+void func() {
+ id <A> obj = (id <A>)[Foo bar];
+}
+
More information about the cfe-commits
mailing list