Skip to content

Fix for handling CapturedDecl, which was causing the failure of certain #979

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

Merged
merged 6 commits into from
Feb 19, 2021

Conversation

sulekhark
Copy link
Contributor

OpenMP test cases after upgrade.

Result
Lexicographic::CompareLoc(const SourceLocation *SL1,
const SourceLocation *SL2) const {
if (SL1 && SL2) {
Copy link

Choose a reason for hiding this comment

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

If SL1 or SL2 is null, you can early exit by moving the llvm_unreachable from line 146 to here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, I can do that.

@@ -137,6 +179,20 @@ Lexicographic::CompareScope(const DeclContext *DC1, const DeclContext *DC2) cons
}
}

Result
Lexicographic::CompareDecl(const CapturedDecl *CD1,
Copy link

Choose a reason for hiding this comment

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

Should this function be called CompareCapturedDecl? Because it won't accept any other Decl.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

There is a CompareDecl function on line 197 that takes two NamedDecls as arguments. So, I named this new function in the same way to indicate its "overloaded" nature.

Stmt *SList1 = CD1->getBody();
Stmt *SList2 = CD2->getBody();
if (SList1 && SList2) {
const SourceLocation SL1 = SList1->getSourceRange().getBegin();
Copy link

Choose a reason for hiding this comment

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

Could getSourceRange() return null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As far as I have investigated, it doesn't return null.

const CapturedDecl *CD2Arg) const {
const CapturedDecl *CD1 = dyn_cast<CapturedDecl>(CD1Arg->getCanonicalDecl());
const CapturedDecl *CD2 = dyn_cast<CapturedDecl>(CD2Arg->getCanonicalDecl());
if (CD1 == CD2)
Copy link

Choose a reason for hiding this comment

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

Do we want to return Result::Equal even if both CD1 and CD2 are null? If not, then the null checks from line 190 should move here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a fair question. For the sake of uniformity, I have written the code to execute in the same way that the other overloaded function CompareDecl on line 206 (the function that compares two NamedDecls) executes.

Copy link

@mgrang mgrang left a comment

Choose a reason for hiding this comment

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

LGTM.

Copy link
Contributor

@kkjeer kkjeer left a comment

Choose a reason for hiding this comment

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

LGTM


if (!SL1.isInvalid() && !SL2.isInvalid())
return CompareLoc(&SL1, &SL2);
else {
Copy link

Choose a reason for hiding this comment

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

else after a return is redundant.

assert(false && "unexpected invalid source location(s)");
if (!SL2.isInvalid())
return Result::LessThan;
else if (!SL1.isInvalid())
Copy link

Choose a reason for hiding this comment

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

else after a return is redundant.

return Result::LessThan;
else if (!SL1.isInvalid())
return Result::GreaterThan;
else {
Copy link

Choose a reason for hiding this comment

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

Same here.

// to the statement lists.
if (SList1 == SList2)
return Result::Equal;
else if (SList1 < SList2)
Copy link

Choose a reason for hiding this comment

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

Ditto.

Copy link

@mgrang mgrang left a comment

Choose a reason for hiding this comment

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

Thanks! LGTM.

…wo CapturedDecls. An interim solution using pointer comparison is present, with a TODO for an improved ordering.
Copy link
Member

@dtarditi dtarditi left a comment

Choose a reason for hiding this comment

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

Looks good, thanks!

@sulekhark sulekhark merged commit 7e57978 into updated-master-11-last Feb 19, 2021
@sulekhark sulekhark deleted the updated-master-11-last-captureDecl branch February 19, 2021 22:33
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.

4 participants