Currently, protected members from base classes are marked as
inaccessible when completing in derived class. This patch fixes the problem by
setting the naming class correctly when looking up results in base class
according to [11.2.p5].
Details
Diff Detail
- Repository
- rC Clang
- Build Status
Buildable 20443 Build 20443: arc lint + arc unit
Event Timeline
Adding Richard to see if he agrees with the direction taken.
lib/Sema/SemaAccess.cpp | ||
---|---|---|
1871–1873 | This seems to contradict the function-level comment that says the check seems to only take the access specifiers into account and not how the member is accessed. | |
lib/Sema/SemaCodeComplete.cpp | ||
1307 | Please do not use auto as the type is not spelled out in the initialization. | |
1316–1317 | This makes it sound like the caller has messed something up, but I'm also pretty unfamiliar with the code completion logic. Why would InBaseClass be true for that completion point and why would the context be set to B? | |
1319 | You can drop the llvm:: | |
1322 | Please don't use auto here either. | |
1324 | You can drop the llvm:: |
Thanks for the review!
lib/Sema/SemaAccess.cpp | ||
---|---|---|
1871–1873 |
It's not very clear to me what exactly this means. But I think we are still not taking how member was accessed into account. The access in DeclAccessPair describes how a member was accessed, and this should be None instead of the access specifier of the member as we don't have this information here. I updated the wording in the comment to make this a bit clearer. | |
lib/Sema/SemaCodeComplete.cpp | ||
1316–1317 | It's a bit messy, but this is roughly how lookup inside a class, say D,works:
So, InBaseClass would be true when a lookup starts from a derived class. |
lib/Sema/SemaAccess.cpp | ||
---|---|---|
1871–1873 | I'm still wondering about the removal of the public access check -- if the declaration has a public access specifier, that early return saves work. So Entity may still require passing AS_none but we might want to continue to check Decl->getAccess() == AS_public for the early return? (Drive-by nit that's not yours: Decl is the name of a type, so if you wanted to rename the parameter to something that isn't a type name, I would not be sad, but you're not required to do it.) | |
lib/Sema/SemaCodeComplete.cpp | ||
1316–1317 | Ah, thank you for the explanation; that helps. |
lib/Sema/SemaAccess.cpp | ||
---|---|---|
1871–1873 | Added Decl->getAccess() == AS_public back to preserve the behavior. s/Decl/Target/ |
This seems to contradict the function-level comment that says the check seems to only take the access specifiers into account and not how the member is accessed.