Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-dev] Parse Options for Cached ASTs

Hi

 

I've taken a look at Bug 412380.

In short: An extracted initializer list containing only the integer literal "1" is incomplete after a refactoring.

Affected statement: int array[] = {1};

 

The problem arises because the flag ITranslationUnit. AST_SKIP_TRIVIAL_EXPRESSIONS_IN_AGGREGATE_INITIALIZERS is set while parsing the source code. It causes the parser to skip the literal "1" resulting in the initializer list being empty. The InitializerWriter then writes the expected "{1}" as "{ }". We could just remove this flag from the PARSE_MODE in CRefactoringContext to solve the problem in the context of the unit test. Unfortunately, the caching mechanism for the ASTs will prefer a previously created AST (e.g. from the editor). It is not given that this AST has been parsed without this flag. Although the refactoring tests will work then, the problem still arises in the editor.

 

I tried to find a way to ensure that trivial expressions are not skipped in the context of the refactoring when getting an AST, but I've not been successful. Did I miss something? Do we have the capabilities to ensure certain options to be set (or not set) when retrieving ASTs from the ASTProvider? If not: Shall we add them?

 

Regards

Thomas


Back to the top