From: Fariborz Jahanian Date: Thu, 3 Jan 2008 20:01:35 +0000 (+0000) Subject: Remove cause of misc. "variable might be used uninitialized in this function" warnings. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bca14a2c664dfb2e221a4b9d481f8d4116bfcf37;p=clang Remove cause of misc. "variable might be used uninitialized in this function" warnings. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@45546 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/AST/ASTContext.cpp b/AST/ASTContext.cpp index c01cdf512a..d20be96936 100644 --- a/AST/ASTContext.cpp +++ b/AST/ASTContext.cpp @@ -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(); diff --git a/Sema/SemaExpr.cpp b/Sema/SemaExpr.cpp index 6c9d8ba5ea..1ec60d9934 100644 --- a/Sema/SemaExpr.cpp +++ b/Sema/SemaExpr.cpp @@ -2308,7 +2308,7 @@ Sema::ExprResult Sema::ActOnInstanceMessage( Expr *RExpr = static_cast(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(receiverType.getTypePtr()); receiverType = pointerType->getPointeeType(); } - ObjcInterfaceDecl* ClassDecl; + ObjcInterfaceDecl* ClassDecl = 0; if (ObjcQualifiedInterfaceType *QIT = dyn_cast(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)