Page MenuHomePhabricator

Fixes an assertion failure while instantiation a template with an incomplete typo corrected type
Needs ReviewPublic

Authored by Mordante on Jul 12 2019, 9:43 AM.

Details

Summary

This fixes bug 35682. When a template in instantiated with an incomplete typo corrected type an assertion can trigger if the -ferror-limit is used to reduce the number of errors. The issue can be reproduced with the following code:

#include <utility>
        
using SetKeyType = String;                                                      
std::pair<SetKeyType, int> v;

and compiled with: clang -stdlib=libc++ -ferror-limit=1 -c bug.cc
This requires the stdlib=libc++ option, without it the assertion does not trigger. Neither does it trigger when the -ferror-limit=1 is not used. The test case is based on this sample but no longer requires the -stdlib=libc++ option.

Diff Detail

Event Timeline

Mordante created this revision.Jul 12 2019, 9:43 AM

Test?

clang/lib/Sema/SemaTemplate.cpp
733

no else after return

Mordante marked 2 inline comments as done.Jul 12 2019, 10:02 AM

Thanks for feedback. I'll whether I can find a way to generate a nice test case.

clang/lib/Sema/SemaTemplate.cpp
733

Will do in the next update.

Mordante updated this revision to Diff 210128.Jul 16 2019, 10:10 AM
Mordante marked an inline comment as done.
Mordante retitled this revision from Fixes a clang frontend assertion failure (bug 35682) to Fixes an assertion failure while instantiation a template with an incomplete typo corrected type.
Mordante edited the summary of this revision. (Show Details)

Fixes @lebedev.ri's remark and adds the requested test.
While working on the test I discovered the initial assumption in bug 35682 was incorrect. Updated the title and summary accordingly.

lebedev.ri added inline comments.Jul 16 2019, 10:22 AM
clang/test/SemaTemplate/instantiate-incomplete-typo-suggested-error-limit.cpp
10–11

Please don't pull in any external headers - just mock what you need.

Mordante updated this revision to Diff 210146.Jul 16 2019, 12:00 PM

Remove the includes from the test.
Changed the std::is_constructible to is_same since the latter is easier to mock.

Mordante marked an inline comment as done.Jul 16 2019, 12:00 PM

Test looks good, adding a few more potential reviewers..