This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Fix false error report of array subscription for templated indexes.
AbandonedPublic

Authored by h-joo on Apr 22 2020, 8:07 AM.

Details

Reviewers
ABataev
jdoerfert
Summary

This is a fix for Bug 45383.

This revision fixes the error reported for array subscription for the cases where the array index is a template parameter.
Note that the ArraySubscriptExpr::getBase() might return something which might not be a base in the cases where either LHS or RHS of the ArraySubscriptExpr is a template declaration - I think the fundemental fix would include more changes with ArraySubscriptExpr::getBase() in the presence of template dependent types, but I thought it would involve a bigger scope of refactoring since many of the code is touching it.

Please also keep in mind this is my first patch, so I would be very glad for any kind of comment if I did something wrong.

Diff Detail

Event Timeline

h-joo created this revision.Apr 22 2020, 8:07 AM

Can we create a test case that shows even if it is a dependent type we will eventuall issue an error if it is not an addressable lvalue or array item?
If this is the part that needs refactoring to work, we should add the test with a TODO.

h-joo updated this revision to Diff 259326.EditedApr 22 2020, 10:09 AM

Can we create a test case that shows even if it is a dependent type we will eventuall issue an error if it is not an addressable lvalue or array item?
If this is the part that needs refactoring to work, we should add the test with a TODO.

Added a test to check the test triggers in presence of lvalue expression. Although the test does not trigger line 15912, but rather line 15905. I tried some examples and it seems like after during the template instantiation, while an ArraySubscriptExpr is being constructed, it already checks whether it's a pointer type or an array type, thus, I am thinking this check in line 15912 might actually be redundant?

This looks reasonable to me. @ABataev WDYT?

This looks reasonable to me. @ABataev WDYT?

I would add a positive test with -ast-print

clang/lib/Sema/SemaOpenMP.cpp
15913

Just QualType BaseType = ASE->getBase()->getType().getNonReferenceType(); and drop the call for getNonReferenceType() in later checks.

h-joo updated this revision to Diff 259343.EditedApr 22 2020, 11:30 AM

This looks reasonable to me. @ABataev WDYT?

I would add a positive test with -ast-print

  1. Changed into a positive test with -ast-print
  2. Just QualType BaseType = ASE->getBase()->getType().getNonReferenceType(); and dropped all the call for getNonReferenceType() in later checks.

Thank you for your time for the review! I do have one more question to ask. I don't understand the log of the build failure, may I ask for some help to understand the failures?

h-joo marked an inline comment as done.EditedApr 30 2020, 2:50 AM

Sorry, I feel like I'm holding back the fix for this bug since I'm stuck on how to proceed with the build failure, @ABataev would you like to proceed with the other revision that you were working on? If you would, I will drop this one then.

Sorry, I feel like I'm holding back the fix for this bug since I'm stuck on how to proceed with the build failure, @ABataev would you like to proceed with the other revision that you were working on? If you would, I will drop this one then.

Don't worry. What build failure exactly? The lldb libc++ failures shown here in phab or something else?

h-joo added a comment.Apr 30 2020, 6:10 AM

Sorry, I feel like I'm holding back the fix for this bug since I'm stuck on how to proceed with the build failure, @ABataev would you like to proceed with the other revision that you were working on? If you would, I will drop this one then.

Don't worry. What build failure exactly? The lldb libc++ failures shown here in phab or something else?

Exactly, I was a bit lost by the lldb and libc++ failures

h-joo abandoned this revision.Jul 5 2020, 9:08 AM