This is an archive of the discontinued LLVM Phabricator instance.

[MSVC] Improved lookup into dependent/non-dependent bases of dependent class
ClosedPublic

Authored by ABataev on Jan 26 2015, 2:01 AM.

Details

Summary

Patch improves lookup into dependendt bases of dependent class and adds lookup into non-dependent bases.

Diff Detail

Event Timeline

ABataev updated this revision to Diff 18746.Jan 26 2015, 2:01 AM
ABataev retitled this revision from to [MSVC] Improved lookup into dependent/non-dependent bases of dependent class.
ABataev updated this object.
ABataev edited the test plan for this revision. (Show Details)
ABataev added a reviewer: rsmith.
ABataev added a subscriber: Unknown Object (MLST).
rnk added a subscriber: rnk.Feb 4 2015, 4:42 PM

Looks pretty good.

lib/Sema/SemaDecl.cpp
132

"FoundNonType" would be closer to the standardese terminology of "non-type template parameter"

159–160

You can reduce the indentation here with continue.

test/SemaTemplate/ms-lookup-template-base-classes.cpp
449

Can you add a test for the case where we look through non-dependent bases? So far as I can tell, these are all dependent.

rsmith added inline comments.Feb 4 2015, 5:00 PM
lib/AST/Type.cpp
1894–1900 ↗(On Diff #18746)

What's the purpose of this change? We'll call the const version for a non-const object without this, which will do the same thing.

lib/Sema/SemaDecl.cpp
132

This should either be an enum class or should use a prefix for its names; these identifiers seem too general to drop into global scope here.

139

The name of this function should mention something about dependent bases, since that's what's interesting about it and how it differs from normal name lookup.

153

You're going to lengths to ensure we look up into dependent bases of dependent bases, but you don't support finding names in dependent bases of non-dependent bases of dependent bases: we'll use normal name lookup here in that case. Maybe remove this whole case and do the same thing you do below: look up into the RecordDecl you get here and then recurse to its base classes.

173–187

Switch these two over: first look up in the base class itself, and then look up in its base classes if you find nothing. Otherwise you'll get the wrong result if the name is a type in one place and a non-type in the other.

195–207

If there are multiple such base classes, we should ideally search outer ones if we find nothing in the innermost one, to match normal unqualified lookup.

Richard, Reid,
Thanks for the review!

lib/AST/Type.cpp
1894–1900 ↗(On Diff #18746)

Removed.

lib/Sema/SemaDecl.cpp
132

Turned enum into enum class and renamed FoundNotType to FoundNonTypeTemplateParam

139

Renamed to lookupUnqualifiedTypeNameInDependentBase

153

Hmm, maybe I'm missing something, but is it possible at all? How non-dependent class may have dependent base?

159–160

Ok

173–187

Ok, got it.

195–207

Agree, will be fixed

test/SemaTemplate/ms-lookup-template-base-classes.cpp
449

Test in 'namespace type_in_base_of_dependent_base' checks this already. But I'll add another one.

Nope, unfortunately not. I'll try to fix this one later.

ABataev updated this revision to Diff 19396.Feb 5 2015, 4:47 AM

Update after review

rnk added inline comments.Feb 5 2015, 9:49 AM
lib/Sema/SemaDecl.cpp
132

Well, we aren't searching for template parameters specifically, so I'd still prefer FoundNonType. :)

ABataev updated this revision to Diff 19474.Feb 6 2015, 4:01 AM

Fixed lookup in non-dependent bases

Any comments on updated version of the patch?

rsmith accepted this revision.Feb 18 2015, 7:37 PM
rsmith edited edge metadata.

Thanks, LGTM

This revision is now accepted and ready to land.Feb 18 2015, 7:37 PM
This revision was automatically updated to reflect the committed changes.