Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 318784

Summary: DeclarationGenerator fails for some cases
Product: [Tools] CDT Reporter: Tomasz Wesolowski <kosashi>
Component: cdt-refactoringAssignee: Emanuel Graf <emanuel>
Status: RESOLVED FIXED QA Contact: Emanuel Graf <emanuel>
Severity: normal    
Priority: P3    
Version: 7.0   
Target Milestone: 7.0.1   
Hardware: PC   
OS: Windows 7   
Whiteboard:
Bug Depends on: 318785    
Bug Blocks: 318874    
Attachments:
Description Flags
new declarator generation
none
fixed declaration generation
emanuel: iplog+
test case emanuel: iplog-

Description Tomasz Wesolowski CLA 2010-07-03 09:37:25 EDT
Build Identifier: 

While fixing Extract Constant refactoring, I've found out some problems with my current implementation of DeclarationGenerator - it fails to generate the proper IASTDeclarator for complex cases like nested pointer-to-array-of-pointer-to-sth types.

I'm redesigning the implementation of DeclarationGenerator atm, I hope to have it finished and working today. I hope that my new approach to this problem will allow to extend it with handling function pointers, too.

Update soon.

Reproducible: Always
Comment 1 Tomasz Wesolowski CLA 2010-07-03 17:40:59 EDT
Created attachment 173362 [details]
new declarator generation

Success!

Well, that's literally my 4th attempt on the generation logic - fortunately, this one seems to be both correct and shortest in terms of code so far :) Wasn't so pleasant to throw away my original code, but at least we have the sophisticated declarations generated correctly.

The good thing is that after rewriting the code it was easy to add support for function pointers, including those returning function pointers. Works like a charm, finally.

See bug 318785 for NPEs after applying the change.
Comment 2 Emanuel Graf CLA 2010-07-06 05:32:59 EDT
> 
> See bug 318785 for NPEs after applying the change.

The cause for the NPE is the ArrayDeclarator, getName() returns null but according to the javaDoc for this method the method should return an empty name.
Comment 3 Tomasz Wesolowski CLA 2010-07-06 14:17:29 EDT
Created attachment 173580 [details]
fixed declaration generation

Here we go!

+ added an empty ASTName for every created declarator where there was a null ASTName before
and:
+ fixed PointerOperator order
+ added some support for pointer-to-members
Comment 4 Emanuel Graf CLA 2010-07-07 04:37:43 EDT
Created attachment 173625 [details]
test case
Comment 5 Emanuel Graf CLA 2010-07-07 05:00:33 EDT
Fixed in HEAD and 7.0 > 20100707

Thanks Tomasz