Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llvm support for meta rule 3 #1118

Merged
merged 8 commits into from
Dec 9, 2021
Merged

Add llvm support for meta rule 3 #1118

merged 8 commits into from
Dec 9, 2021

Conversation

fineg74
Copy link
Contributor

@fineg74 fineg74 commented Dec 4, 2021

The PR changes a way how type of an unqualified field is determined and attributes every declarative reference with potential anchor table reference that may be used by Translation Engine to generate the navigation code properly

Copy link
Contributor

@simone-gaia simone-gaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the most important thing to do is a file that extensively tests meta-rule3. With comments that describe why a certain semantic is applied etc...

@@ -9529,6 +9529,8 @@ def err_duplicate_field : Error<
"table name (table.field) to disambiguate field names that occur in more "
"than one table. You can also restrict the list of tables to search by "
"specifying them in the ruleset 'tables' attribute.">;
def err_wrong_table_field : Error<
"Field '%0' belongs to a table '%1' that does not exist in the catalog.">;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it sounds strange to say that a field belongs to a table that does not exist, because by saying "belong" it seems the table somewhat exists.

Probably @vDonGlover knows a better way to say this or, what I said above, doesn't make sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe instead of "belongs" we can say "is marked as belonging".

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"is defined in a table that does not exist"?

return return_value;
}

// Find shortest navigation path between 2 tables. If multiple shortest paths exist, return an error.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does it mean "return an error" since this function returns true/false?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments

}

// Find shortest navigation path between 2 tables. If multiple shortest paths exist, return an error.
bool GaiaCatalog::findNavigationPath(StringRef src, StringRef dst, SmallVector<string, 8>& current_path, bool reportErrors)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is current_path? And what is reportErrors? Can you add documentation for the parameters?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added more comments

}
const auto& table_data = getCatalogTableData();

IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you are inside "gaia code" use snake_case (or use CamelCase for Gaia stuff).

Comment on lines 194 to 197
TextDiagnosticPrinter *DiagClient = new TextDiagnosticPrinter(llvm::errs(), &*DiagOpts);

IntrusiveRefCntPtr<DiagnosticIDs> DiagID(new DiagnosticIDs());
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagClient);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this allocated memory need to be released?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IntrusiveRefCntPtr is a smart pointer.
Diagnostic Engine uses smart pointers for Diagnostic Client inside. So memory is taken care of

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd add a comment for DiagClient, to indicate this.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a comment

if (foundTables.size() == 1)
{
fieldTableName = foundTables.begin()->first();
retVal = foundTables.begin()->second;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of retVal, you could just use result. Same number of characters, no abbreviation.

Copy link
Contributor Author

@fineg74 fineg74 Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

// Find topographically shortest path between anchor table and destination table.
if (gaia::catalog::GaiaCatalog::findNavigationPath(anchor_table_iterator->first(), firstComponent, path, false))
{
if(path.size() < pathLength)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space after if.

Copy link
Contributor Author

@fineg74 fineg74 Dec 7, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed

Copy link
Contributor

@simone-gaia simone-gaia left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since @waynelwarren is busy with other matters somebody else's need to write extensive tests for this feature. Are you planning to do it as part of this PR ?

@fineg74
Copy link
Contributor Author

fineg74 commented Dec 7, 2021

Since @waynelwarren is busy with other matters somebody else's need to write extensive tests for this feature. Are you planning to do it as part of this PR ?

There are tests covering what was introduced in this PR (Resolving an unqualified field reference in some cases that earlier was considered ambiguous ). The more interesting part would be code generation where more tests would come in separate PR.

@fineg74
Copy link
Contributor Author

fineg74 commented Dec 8, 2021

How about

"Field '%0' is defined in table '%1', which does not exist in the catalog."

Changed

Copy link
Contributor

@daxhaw daxhaw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm assuming in another PR you'll add some tests to ensure meta-rule 3 meets our spec requirements.

@fineg74 fineg74 merged commit 02e55c8 into master Dec 9, 2021
@fineg74 fineg74 deleted the MetaRule3 branch December 9, 2021 03:39
@fineg74 fineg74 restored the MetaRule3 branch December 9, 2021 03:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants