aboutsummaryrefslogtreecommitdiff
path: root/Driver/RewriteObjC.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2008-11-19 21:15:47 +0000
committerSteve Naroff <snaroff@apple.com>2008-11-19 21:15:47 +0000
commitcda658e90d7ffe0ece23d741ff82cf764108f66c (patch)
treea59f18be9c1b194381b74c1a20940c0432b5fe2c /Driver/RewriteObjC.cpp
parentf9eb905197e44ed5634205512074993f6f40470d (diff)
Fix <rdar://problem/6291588> assertion failure: SourceManager.h line 489.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@59664 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'Driver/RewriteObjC.cpp')
-rw-r--r--Driver/RewriteObjC.cpp16
1 files changed, 14 insertions, 2 deletions
diff --git a/Driver/RewriteObjC.cpp b/Driver/RewriteObjC.cpp
index 804a891f6b..a3ce8a8c56 100644
--- a/Driver/RewriteObjC.cpp
+++ b/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.