Summary: | [compiler] Regression in if statement flow analysis related to null checks | ||||||||
---|---|---|---|---|---|---|---|---|---|
Product: | [Eclipse Project] JDT | Reporter: | Olivier Thomann <Olivier_Thomann> | ||||||
Component: | Core | Assignee: | Ayushman Jain <amj87.iitr> | ||||||
Status: | VERIFIED FIXED | QA Contact: | |||||||
Severity: | normal | ||||||||
Priority: | P3 | Flags: | Olivier_Thomann:
review+
|
||||||
Version: | 3.6 | ||||||||
Target Milestone: | 3.6 M6 | ||||||||
Hardware: | PC | ||||||||
OS: | Windows XP | ||||||||
Whiteboard: | |||||||||
Attachments: |
|
Description
Olivier Thomann
2010-02-10 10:39:57 EST
Created attachment 158761 [details]
proposed fix + regression test
The problem is: with our new analysis, we are sure that the comparison o==null is redundant and that the if statement will always be executed, as a result of which we concluded that i will always be initialised. But we dont want to be concluding the initializations so aggressively.
Attaching a patch which takes care of this, although it changes the null analysis code a bit. Now we do set the unreachable bit, but we dont set optimised constants. Two bits in ASTNode, Bit8 and 9, take care of code gen according to whether unreachable bit is set or not, and also report dead code warnings at appropriate places. A new method FlowInfo#mergedOptimisedBranchesIfElse() is introduced in addition to the old FlowInfo#mergedOptimisedBranches(). This new method takes care of the initializations inside if else constructs where one branch is sure to be executed.
Created attachment 158805 [details]
Proposed fix
Same patch with minor changes.
Released for 3.6M6. Regression tests added in org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest. Regression tests will be released tomorrow so that the nightly build doesn't fail. Released tests: org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0569_try_catch org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0570_try_catch org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0571_try_catch_finally org.eclipse.jdt.core.tests.compiler.regression.NullReferenceTest#test0572_if_statement Verified for 3.6M6 using I20100307-2000. |