[llvm-branch-commits] [cfe-branch] r71677 - /cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Steve Naroff snaroff at apple.com
Wed May 13 10:49:20 PDT 2009


Author: snaroff
Date: Wed May 13 12:48:30 2009
New Revision: 71677

URL: http://llvm.org/viewvc/llvm-project?rev=71677&view=rev
Log:
Avoid using "back" method on empty vector (the behavior is undefined).

This appears to work on Mac OS X (which is why I didn't discover it).
It also appears to work *sometimes* on Windows...:-)

Modified:
    cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp

Modified: cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp?rev=71677&r1=71676&r2=71677&view=diff

==============================================================================
--- cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp (original)
+++ cfe/branches/Apple/objective-rewrite/tools/clang/Driver/RewriteObjC.cpp Wed May 13 12:48:30 2009
@@ -4398,9 +4398,12 @@
     //   for (id <FooProtocol> index in someArray) ;
     // This is because RewriteObjCForCollectionStmt() does textual rewriting 
     // and it depends on the original text locations/positions.
-    Stmt *ParentStmt = Stmts.back();
-    if (!ParentStmt || !isa<ObjCForCollectionStmt>(ParentStmt))
+	if (Stmts.empty()) {
       RewriteObjCQualifiedInterfaceTypes(*DS->decl_begin());
+	} else {
+	  if (!isa<ObjCForCollectionStmt>(Stmts.back()))
+        RewriteObjCQualifiedInterfaceTypes(*DS->decl_begin());
+	}
     
     // Blocks rewrite rules.
     for (DeclStmt::decl_iterator DI = DS->decl_begin(), DE = DS->decl_end();





More information about the llvm-branch-commits mailing list