[cfe-commits] r74556 - /cfe/trunk/lib/Parse/ParseDecl.cpp

Ted Kremenek kremenek at apple.com
Tue Jun 30 15:19:00 PDT 2009


Author: kremenek
Date: Tue Jun 30 17:19:00 2009
New Revision: 74556

URL: http://llvm.org/viewvc/llvm-project?rev=74556&view=rev
Log:
Fix: <rdar://problem/7021553> clang -fsyntax-only crashes (in ParseDeclarationSpecifiers ... from ParseObjCTypeName)

Another case where we should use SmallVector::data() instead of taking the
address of element 0 of a SmallVector when the SmallVector has no elements.

Modified:
    cfe/trunk/lib/Parse/ParseDecl.cpp

Modified: cfe/trunk/lib/Parse/ParseDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Parse/ParseDecl.cpp?rev=74556&r1=74555&r2=74556&view=diff

==============================================================================
--- cfe/trunk/lib/Parse/ParseDecl.cpp (original)
+++ cfe/trunk/lib/Parse/ParseDecl.cpp Tue Jun 30 17:19:00 2009
@@ -802,7 +802,7 @@
       SourceLocation EndProtoLoc;
       llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
       ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
-      DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
+      DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
       
       DS.SetRangeEnd(EndProtoLoc);
       continue;
@@ -859,7 +859,7 @@
       SourceLocation EndProtoLoc;
       llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
       ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
-      DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
+      DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
       
       DS.SetRangeEnd(EndProtoLoc);
 
@@ -1066,7 +1066,7 @@
         SourceLocation EndProtoLoc;
         llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
         ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
-        DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
+        DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
         DS.SetRangeEnd(EndProtoLoc);
 
         Diag(Loc, diag::warn_objc_protocol_qualifier_missing_id)
@@ -1179,7 +1179,7 @@
     SourceLocation EndProtoLoc;
     llvm::SmallVector<DeclPtrTy, 8> ProtocolDecl;
     ParseObjCProtocolReferences(ProtocolDecl, false, EndProtoLoc);
-    DS.setProtocolQualifiers(&ProtocolDecl[0], ProtocolDecl.size());
+    DS.setProtocolQualifiers(ProtocolDecl.data(), ProtocolDecl.size());
     
     DS.SetRangeEnd(EndProtoLoc);
     return true;





More information about the cfe-commits mailing list