Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 190298 Details for
Bug 338234
[compiler] Missing warning for uninitialized variable in dead code
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
[patch]
proposed fix v2.1 + tests
patch338234.txt (text/plain), 34.93 KB, created by
Ayushman Jain
on 2011-03-03 13:28:56 EST
(
hide
)
Description:
proposed fix v2.1 + tests
Filename:
MIME Type:
Creator:
Ayushman Jain
Created:
2011-03-03 13:28:56 EST
Size:
34.93 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.jdt.core >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java,v >retrieving revision 1.45 >diff -u -r1.45 AND_AND_Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java 12 Aug 2010 16:58:28 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AND_AND_Expression.java 3 Mar 2011 18:06:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -57,7 +57,7 @@ > if (isLeftOptimizedFalse) { > if ((rightInfo.reachMode() & FlowInfo.UNREACHABLE) == 0) { > currentScope.problemReporter().fakeReachable(this.right); >- rightInfo.setReachMode(FlowInfo.UNREACHABLE); >+ rightInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } > rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java,v >retrieving revision 1.67 >diff -u -r1.67 AssertStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 7 Feb 2011 16:18:05 -0000 1.67 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/AssertStatement.java 3 Mar 2011 18:06:37 -0000 >@@ -56,7 +56,7 @@ > UnconditionalFlowInfo assertWhenTrueInfo = conditionFlowInfo.initsWhenTrue().unconditionalInits(); > FlowInfo assertInfo = conditionFlowInfo.initsWhenFalse(); > if (isOptimizedTrueAssertion) { >- assertInfo.setReachMode(FlowInfo.UNREACHABLE); >+ assertInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > > if (this.exceptionArgument != null) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java,v >retrieving revision 1.98 >diff -u -r1.98 ConditionalExpression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 14 Jan 2011 17:02:24 -0000 1.98 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ConditionalExpression.java 3 Mar 2011 18:06:37 -0000 >@@ -55,7 +55,7 @@ > FlowInfo trueFlowInfo = flowInfo.initsWhenTrue().copy(); > if (isConditionOptimizedFalse) { > if ((mode & FlowInfo.UNREACHABLE) == 0) { >- trueFlowInfo.setReachMode(FlowInfo.UNREACHABLE); >+ trueFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) { > this.valueIfTrue.complainIfUnreachable(trueFlowInfo, currentScope, initialComplaintLevel); >@@ -68,7 +68,7 @@ > FlowInfo falseFlowInfo = flowInfo.initsWhenFalse().copy(); > if (isConditionOptimizedTrue) { > if ((mode & FlowInfo.UNREACHABLE) == 0) { >- falseFlowInfo.setReachMode(FlowInfo.UNREACHABLE); >+ falseFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (!isKnowDeadCodePattern(this.condition) || currentScope.compilerOptions().reportDeadCodeInTrivialIfStatement) { > this.valueIfFalse.complainIfUnreachable(falseFlowInfo, currentScope, initialComplaintLevel); >@@ -98,16 +98,16 @@ > UnconditionalFlowInfo trueInfoWhenFalse = trueFlowInfo.initsWhenFalse().unconditionalInits(); > UnconditionalFlowInfo falseInfoWhenFalse = falseFlowInfo.initsWhenFalse().unconditionalInits(); > if (isValueIfTrueOptimizedFalse) { >- trueInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE); >+ trueInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (isValueIfFalseOptimizedFalse) { >- falseInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE); >+ falseInfoWhenTrue.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (isValueIfTrueOptimizedTrue) { >- trueInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE); >+ trueInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (isValueIfFalseOptimizedTrue) { >- falseInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE); >+ falseInfoWhenFalse.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > mergedInfo = > FlowInfo.conditional( >Index: compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java,v >retrieving revision 1.69 >diff -u -r1.69 ForStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 23 Aug 2010 08:41:25 -0000 1.69 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/ForStatement.java 3 Mar 2011 18:06:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -135,7 +135,7 @@ > } else { > actionInfo = initsWhenTrue.unconditionalCopy(); > if (isConditionOptimizedFalse){ >- actionInfo.setReachMode(FlowInfo.UNREACHABLE); >+ actionInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } > if (this.action.complainIfUnreachable(actionInfo, this.scope, initialComplaintLevel) < Statement.COMPLAINED_UNREACHABLE) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java,v >retrieving revision 1.69 >diff -u -r1.69 IfStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 12 Aug 2010 16:58:28 -0000 1.69 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/IfStatement.java 3 Mar 2011 18:06:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -67,11 +67,11 @@ > // process the THEN part > FlowInfo thenFlowInfo = conditionFlowInfo.safeInitsWhenTrue(); > if (isConditionOptimizedFalse) { >- thenFlowInfo.setReachMode(FlowInfo.UNREACHABLE); >+ thenFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > FlowInfo elseFlowInfo = conditionFlowInfo.initsWhenFalse().copy(); > if (isConditionOptimizedTrue) { >- elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE); >+ elseFlowInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > if (((flowInfo.tagBits & FlowInfo.UNREACHABLE) == 0) && > ((thenFlowInfo.tagBits & FlowInfo.UNREACHABLE) != 0)) { >Index: compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java,v >retrieving revision 1.45 >diff -u -r1.45 OR_OR_Expression.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 12 Aug 2010 16:58:28 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/OR_OR_Expression.java 3 Mar 2011 18:06:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -59,7 +59,7 @@ > if (isLeftOptimizedTrue){ > if ((rightInfo.reachMode() & FlowInfo.UNREACHABLE) == 0) { > currentScope.problemReporter().fakeReachable(this.right); >- rightInfo.setReachMode(FlowInfo.UNREACHABLE); >+ rightInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } > rightInfo = this.right.analyseCode(currentScope, flowContext, rightInfo); >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java,v >retrieving revision 1.116 >diff -u -r1.116 TryStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 18 Dec 2010 22:09:26 -0000 1.116 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TryStatement.java 3 Mar 2011 18:06:37 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -150,7 +150,7 @@ > ifTrue: [catchInits addPotentialInitializationsFrom: tryInits]." > */ > if (this.tryBlock.statements == null) { >- catchInfo.setReachMode(FlowInfo.UNREACHABLE); >+ catchInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > catchInfo = > this.catchBlocks[i].analyseCode( >Index: compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java,v >retrieving revision 1.166 >diff -u -r1.166 TypeDeclaration.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 11 Feb 2011 14:55:06 -0000 1.166 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/TypeDeclaration.java 3 Mar 2011 18:06:40 -0000 >@@ -646,7 +646,7 @@ > // branch, since the previous initializer already got the blame. > if (staticFieldInfo == FlowInfo.DEAD_END) { > this.staticInitializerScope.problemReporter().initializerMustCompleteNormally(field); >- staticFieldInfo = FlowInfo.initial(this.maxFieldCount).setReachMode(FlowInfo.UNREACHABLE); >+ staticFieldInfo = FlowInfo.initial(this.maxFieldCount).setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } else { > if ((nonStaticFieldInfo.tagBits & FlowInfo.UNREACHABLE) != 0) >@@ -662,7 +662,7 @@ > // branch, since the previous initializer already got the blame. > if (nonStaticFieldInfo == FlowInfo.DEAD_END) { > this.initializerScope.problemReporter().initializerMustCompleteNormally(field); >- nonStaticFieldInfo = FlowInfo.initial(this.maxFieldCount).setReachMode(FlowInfo.UNREACHABLE); >+ nonStaticFieldInfo = FlowInfo.initial(this.maxFieldCount).setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } > } >Index: compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java,v >retrieving revision 1.66 >diff -u -r1.66 WhileStatement.java >--- compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 23 Aug 2010 08:41:25 -0000 1.66 >+++ compiler/org/eclipse/jdt/internal/compiler/ast/WhileStatement.java 3 Mar 2011 18:06:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -82,7 +82,7 @@ > } else { > FlowInfo mergedInfo = flowInfo.copy().addInitializationsFrom(condInfo.initsWhenFalse()); > if (isConditionOptimizedTrue){ >- mergedInfo.setReachMode(FlowInfo.UNREACHABLE); >+ mergedInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > this.mergedInitStateIndex = > currentScope.methodScope().recordInitializationStates(mergedInfo); >@@ -104,7 +104,7 @@ > } else { > actionInfo = condInfo.initsWhenTrue().copy(); > if (isConditionOptimizedFalse){ >- actionInfo.setReachMode(FlowInfo.UNREACHABLE); >+ actionInfo.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD); > } > } > >Index: compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java,v >retrieving revision 1.33 >diff -u -r1.33 ConditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java 16 Dec 2010 13:02:30 -0000 1.33 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/ConditionalFlowInfo.java 3 Mar 2011 18:06:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -195,7 +195,7 @@ > this.tagBits &= ~UNREACHABLE; > } > else { >- this.tagBits |= UNREACHABLE; >+ this.tagBits |= reachMode; > } > this.initsWhenTrue.setReachMode(reachMode); > this.initsWhenFalse.setReachMode(reachMode); >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java,v >retrieving revision 1.35 >diff -u -r1.35 FinallyFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java 25 Feb 2010 15:27:00 -0000 1.35 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FinallyFlowContext.java 3 Mar 2011 18:06:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -229,14 +229,14 @@ > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } else if (checkType == (CAN_ONLY_NULL_NON_NULL | IN_COMPARISON_NULL)) { > if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } > return; >@@ -252,7 +252,7 @@ > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_COMPARISON_NON_NULL: >@@ -264,7 +264,7 @@ > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_ASSIGNMENT: >@@ -314,14 +314,14 @@ > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } else { > if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } > return; >@@ -342,7 +342,7 @@ > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_COMPARISON_NON_NULL: >@@ -354,7 +354,7 @@ > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_ASSIGNMENT: >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java,v >retrieving revision 1.68 >diff -u -r1.68 FlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 1 Sep 2010 15:49:57 -0000 1.68 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowContext.java 3 Mar 2011 18:06:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -578,14 +578,14 @@ > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } else { > if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } > return; >@@ -609,7 +609,7 @@ > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_COMPARISON_NON_NULL: >@@ -621,7 +621,7 @@ > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_ASSIGNMENT: >Index: compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java,v >retrieving revision 1.45 >diff -u -r1.45 FlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 16 Dec 2010 13:02:30 -0000 1.45 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/FlowInfo.java 3 Mar 2011 18:06:40 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2000, 2010 IBM Corporation and others. >+ * Copyright (c) 2000, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -22,9 +22,24 @@ > > public int tagBits; // REACHABLE by default > public final static int REACHABLE = 0; >- public final static int UNREACHABLE = 1; >- public final static int NULL_FLAG_MASK = 2; >- >+ /* unreachable code >+ * eg. while (true); >+ * i++; --> unreachable code >+ */ >+ public final static int UNREACHABLE_OR_DEAD = 1; >+ /* unreachable code as inferred by null analysis >+ * eg. str = null; >+ * if (str != null) { >+ * // dead code >+ * } >+ */ >+ public final static int UNREACHABLE_BY_NULLANALYSIS = 2; >+ /* >+ * code unreachable in any fashion >+ */ >+ public final static int UNREACHABLE = UNREACHABLE_OR_DEAD | UNREACHABLE_BY_NULLANALYSIS; >+ public final static int NULL_FLAG_MASK = 4; >+ > public final static int UNKNOWN = 1; > public final static int NULL = 2; > public final static int NON_NULL = 4; >@@ -355,7 +370,7 @@ > UnconditionalFlowInfo mergedInfo; > if (isOptimizedTrue){ > if (initsWhenTrue == FlowInfo.DEAD_END && allowFakeDeadBranch) { >- mergedInfo = initsWhenFalse.setReachMode(FlowInfo.UNREACHABLE). >+ mergedInfo = initsWhenFalse.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD). > unconditionalInits(); > } > else { >@@ -367,7 +382,7 @@ > } > else if (isOptimizedFalse) { > if (initsWhenFalse == FlowInfo.DEAD_END && allowFakeDeadBranch) { >- mergedInfo = initsWhenTrue.setReachMode(FlowInfo.UNREACHABLE). >+ mergedInfo = initsWhenTrue.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD). > unconditionalInits(); > } > else { >@@ -394,7 +409,7 @@ > UnconditionalFlowInfo mergedInfo; > if (isOptimizedTrue){ > if (initsWhenTrue == FlowInfo.DEAD_END && allowFakeDeadBranch) { >- mergedInfo = initsWhenFalse.setReachMode(FlowInfo.UNREACHABLE). >+ mergedInfo = initsWhenFalse.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD). > unconditionalInits(); > } > else { >@@ -406,7 +421,7 @@ > } > else if (isOptimizedFalse) { > if (initsWhenFalse == FlowInfo.DEAD_END && allowFakeDeadBranch) { >- mergedInfo = initsWhenTrue.setReachMode(FlowInfo.UNREACHABLE). >+ mergedInfo = initsWhenTrue.setReachMode(FlowInfo.UNREACHABLE_OR_DEAD). > unconditionalInits(); > } > else { >@@ -456,10 +471,9 @@ > } > > /** >- * Return REACHABLE if this flow info is reachable, UNREACHABLE >- * else. >- * @return REACHABLE if this flow info is reachable, UNREACHABLE >- * else >+ * Find out the reachability mode of this flowInfo. >+ * @return REACHABLE if this flow info is reachable, otherwise >+ * either UNREACHABLE_OR_DEAD or UNREACHABLE_BY_NULLANALYSIS. > */ > public int reachMode() { > return this.tagBits & UNREACHABLE; >@@ -476,7 +490,8 @@ > > /** > * Set this flow info reach mode and return this. >- * @param reachMode one of {@link #REACHABLE REACHABLE} or {@link #UNREACHABLE UNREACHABLE} >+ * @param reachMode one of {@link #REACHABLE REACHABLE}, {@link #UNREACHABLE_OR_DEAD UNREACHABLE_OR_DEAD}, >+ * {@link #UNREACHABLE_BY_NULLANALYSIS UNREACHABLE_BY_NULLANALYSIS} or {@link #UNREACHABLE UNREACHABLE} > * @return this, with the reach mode set to reachMode > */ > abstract public FlowInfo setReachMode(int reachMode); >Index: compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java,v >retrieving revision 1.52 >diff -u -r1.52 LoopingFlowContext.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 16 Feb 2011 18:57:48 -0000 1.52 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/LoopingFlowContext.java 3 Mar 2011 18:06:40 -0000 >@@ -493,14 +493,14 @@ > scope.problemReporter().localVariableRedundantCheckOnNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } else { > if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { > scope.problemReporter().localVariableNonNullComparedToNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } > } else if (flowInfo.isDefinitelyNull(local)) { >@@ -509,14 +509,14 @@ > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } else { > if ((this.tagBits & FlowContext.HIDE_NULL_COMPARISON_WARNING) == 0) { > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > } > } else if (this.upstreamNullFlowInfo.isDefinitelyNonNull(local) && !flowInfo.isPotentiallyNull(local) && !flowInfo.isPotentiallyUnknown(local)) { >@@ -554,7 +554,7 @@ > scope.problemReporter().localVariableRedundantCheckOnNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenFalse().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_COMPARISON_NON_NULL: >@@ -566,7 +566,7 @@ > scope.problemReporter().localVariableNullComparedToNonNull(local, reference); > } > if (!flowInfo.isMarkedAsNullOrNonNullInAssertExpression(local)) { >- flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE); >+ flowInfo.initsWhenTrue().setReachMode(FlowInfo.UNREACHABLE_BY_NULLANALYSIS); > } > return; > case FlowContext.IN_ASSIGNMENT: >Index: compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core/compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java,v >retrieving revision 1.72 >diff -u -r1.72 UnconditionalFlowInfo.java >--- compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 19 Jan 2011 05:29:54 -0000 1.72 >+++ compiler/org/eclipse/jdt/internal/compiler/flow/UnconditionalFlowInfo.java 3 Mar 2011 18:06:40 -0000 >@@ -731,7 +731,7 @@ > final public boolean isDefinitelyAssigned(FieldBinding field) { > // Mirrored in CodeStream.isDefinitelyAssigned(..) > // do not want to complain in unreachable code >- if ((this.tagBits & UNREACHABLE) != 0) { >+ if ((this.tagBits & UNREACHABLE_OR_DEAD) != 0) { > return true; > } > return isDefinitelyAssigned(field.id); >@@ -739,7 +739,7 @@ > > final public boolean isDefinitelyAssigned(LocalVariableBinding local) { > // do not want to complain in unreachable code if local declared in reachable code >- if ((this.tagBits & UNREACHABLE) != 0 && (local.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0) { >+ if ((this.tagBits & UNREACHABLE_OR_DEAD) != 0 && (local.declaration.bits & ASTNode.IsLocalDeclarationReachable) != 0) { > return true; > } > return isDefinitelyAssigned(local.id + this.maxFieldCount); >@@ -1870,7 +1870,7 @@ > } > } > } >- this.tagBits |= UNREACHABLE; >+ this.tagBits |= reachMode; > } > return this; > } >#P org.eclipse.jdt.core.tests.compiler >Index: src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java,v >retrieving revision 1.46 >diff -u -r1.46 FlowAnalysisTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 1 Sep 2010 15:49:30 -0000 1.46 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/FlowAnalysisTest.java 3 Mar 2011 18:06:48 -0000 >@@ -1,5 +1,5 @@ > /******************************************************************************* >- * Copyright (c) 2005, 2010 IBM Corporation and others. >+ * Copyright (c) 2005, 2011 IBM Corporation and others. > * All rights reserved. This program and the accompanying materials > * are made available under the terms of the Eclipse Public License v1.0 > * which accompanies this distribution, and is available at >@@ -2246,6 +2246,92 @@ > "Dead code\n" + > "----------\n"); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338234 >+// Warn uninitialized variable in deadcode if deadcode has been inferred >+// by null analysis >+public void testBug338234a() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " int i;\n" + >+ " String str = null;\n" + >+ " if (str != null)\n" + >+ " i++; \n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. WARNING in X.java (at line 6)\n" + >+ " i++; \n" + >+ " ^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "2. ERROR in X.java (at line 6)\n" + >+ " i++; \n" + >+ " ^\n" + >+ "The local variable i may not have been initialized\n" + >+ "----------\n"); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338234 >+// Don't warn uninitialized variable in deadcode if deadcode has not been inferred >+// by null analysis >+public void testBug338234b() { >+ this.runConformTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public static void main(String[] args) {\n" + >+ " int i;\n" + >+ " l: {\n" + >+ " if(false)\n" + >+ " break l;\n" + >+ " return;\n" + >+ " }\n" + >+ " i++; \n" + >+ " }\n" + >+ "}\n" >+ }, >+ ""); >+} >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338234 >+// Warn uninitialized field in deadcode if deadcode has been inferred >+// by null analysis >+public void testBug338234c() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " public final int field1;\n" + >+ " {\n" + >+ " int i;\n" + >+ " String str = null;\n" + >+ " if(str != null)\n" + >+ " i = field1;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 1)\n" + >+ " public class X {\n" + >+ " ^\n" + >+ "The blank final field field1 may not have been initialized\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 7)\n" + >+ " i = field1;\n" + >+ " ^^^^^^^^^^\n" + >+ "Dead code\n" + >+ "----------\n" + >+ "3. ERROR in X.java (at line 7)\n" + >+ " i = field1;\n" + >+ " ^^^^^^\n" + >+ "The blank final field field1 may not have been initialized\n" + >+ "----------\n"); >+} > public static Class testClass() { > return FlowAnalysisTest.class; > } >Index: src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java >=================================================================== >RCS file: /cvsroot/eclipse/org.eclipse.jdt.core.tests.compiler/src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java,v >retrieving revision 1.113 >diff -u -r1.113 NullReferenceTest.java >--- src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 27 Feb 2011 21:42:50 -0000 1.113 >+++ src/org/eclipse/jdt/core/tests/compiler/regression/NullReferenceTest.java 3 Mar 2011 18:06:48 -0000 >@@ -14060,4 +14060,38 @@ > }, > ""); > } >+ >+// https://bugs.eclipse.org/bugs/show_bug.cgi?id=338234 >+public void testBug338234() { >+ this.runNegativeTest( >+ new String[] { >+ "X.java", >+ "public class X {\n" + >+ " static int foo() {\n" + >+ " Object o = null;\n" + >+ " int i = 0;\n" + >+ " label: {\n" + >+ " if (o == null)\n" + >+ " break label;\n" + >+ " i++;" + >+ " }\n" + >+ " if (i != 0) {\n" + >+ " System.out.println(i);\n" + >+ " }\n" + >+ " return 0;\n" + >+ " }\n" + >+ "}\n" >+ }, >+ "----------\n" + >+ "1. ERROR in X.java (at line 6)\n" + >+ " if (o == null)\n" + >+ " ^\n" + >+ "Redundant null check: The variable o can only be null at this location\n" + >+ "----------\n" + >+ "2. WARNING in X.java (at line 8)\n" + >+ " i++; }\n" + >+ " ^^^\n" + >+ "Dead code\n" + >+ "----------\n"); >+} > } >\ No newline at end of file
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 338234
:
189898
|
189936
|
190035
|
190073
|
190298
|
190355