]> granicus.if.org Git - clang/commitdiff
Remove cause of misc. "variable might be used uninitialized in this function" warnings.
authorFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Jan 2008 20:01:35 +0000 (20:01 +0000)
committerFariborz Jahanian <fjahanian@apple.com>
Thu, 3 Jan 2008 20:01:35 +0000 (20:01 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45546 91177308-0d34-0410-b5e6-96231b3b80d8

AST/ASTContext.cpp
Sema/SemaExpr.cpp

index c01cdf512a8a8d19ee678d650c0fda7bc900529e..d20be96936bb8b8db720b4f04fc034432e21f030 100644 (file)
@@ -1384,7 +1384,7 @@ bool ASTContext::ObjcQualifiedIdTypesAreCompatible(QualType lhs,
     if (!rhsQI && !rhsQID && !rhsID)
       return false;
     
-    unsigned numRhsProtocols;
+    unsigned numRhsProtocols = 0;
     ObjcProtocolDecl **rhsProtoList;
     if (rhsQI) {
       numRhsProtocols = rhsQI->getNumProtocols();
@@ -1435,7 +1435,7 @@ bool ASTContext::ObjcQualifiedIdTypesAreCompatible(QualType lhs,
     if (!lhsQI && !lhsQID && !lhsID)
       return false;
     
-    unsigned numLhsProtocols;
+    unsigned numLhsProtocols = 0;
     ObjcProtocolDecl **lhsProtoList;
     if (lhsQI) {
       numLhsProtocols = lhsQI->getNumProtocols();
index 6c9d8ba5ea09bd53836471c3d69576aa7a7cc8c6..1ec60d9934809244fd5cad4c8cffec2d2ee9d14b 100644 (file)
@@ -2308,7 +2308,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
   Expr *RExpr = static_cast<Expr *>(receiver);
   QualType receiverType = RExpr->getType();
   QualType returnType;
-  ObjcMethodDecl *Method;
+  ObjcMethodDecl *Method = 0;
   
   if (receiverType == Context.getObjcIdType() ||
       receiverType == Context.getObjcClassType()) {
@@ -2336,7 +2336,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
           static_cast<PointerType*>(receiverType.getTypePtr());
         receiverType = pointerType->getPointeeType();
       }
-    ObjcInterfaceDecl* ClassDecl;
+    ObjcInterfaceDecl* ClassDecl = 0;
     if (ObjcQualifiedInterfaceType *QIT = 
         dyn_cast<ObjcQualifiedInterfaceType>(receiverType)) {
       ClassDecl = QIT->getDecl();
@@ -2379,9 +2379,10 @@ Sema::ExprResult Sema::ActOnInstanceMessage(
     }
     if (!Method) {
       // If we have an implementation in scope, check "private" methods.
-      if (ObjcImplementationDecl *ImpDecl = 
+      if (ClassDecl)
+        if (ObjcImplementationDecl *ImpDecl = 
             ObjcImplementations[ClassDecl->getIdentifier()])
-        Method = ImpDecl->getInstanceMethod(Sel);
+          Method = ImpDecl->getInstanceMethod(Sel);
          // If we still haven't found a method, look in the global pool. This
          // behavior isn't very desirable, however we need it for GCC compatibility.
          if (!Method)