This is an archive of the discontinued LLVM Phabricator instance.

[clang] Add flag to DeclContext to distinguish between qualified and unqualified name lookups
ClosedPublic

Authored by evgeny777 on Oct 2 2015, 5:25 AM.

Details

Summary

Hi, all!
Currently lldb evaluation of qualified global variables does not work properly.
I've created a revision addressing the issue, which is here:
http://reviews.llvm.org/D13350

To fix the issue in lldb one has to distinguish between qualified and unqualified identifier lookups. In case of qualified lookup the identifier search scope is restricted to DeclContext::DeclKind (Namespace, TranslationUnit). For unqualified lookups scopes are being searched from bottom to top, until you get the first name match

Diff Detail

Event Timeline

evgeny777 updated this revision to Diff 36346.Oct 2 2015, 5:25 AM
evgeny777 retitled this revision from to [clang] Add flag to DeclContext to distinguish between qualified and unqualified name lookups.
evgeny777 updated this object.
evgeny777 added reviewers: aaron.ballman, klimek.
evgeny777 added subscribers: cfe-commits, dawn, KLapshin.

Hello Jim and Sean,

Greg suggested adding you for this review. Can you please take a look?

aaron.ballman edited edge metadata.Oct 6 2015, 7:05 AM

I'm uncertain whether this change is good or not (Richard is more likely to have thoughts on that), but the patch is missing tests.

clang/lib/Sema/SemaLookup.cpp
208

This should be a local class defined more closely to its usage.

What kind of tests do you propose for this? It doesn't introduce any new features to clang, only to lldb where the separate review exists

What kind of tests do you propose for this? It doesn't introduce any new features to clang, only to lldb where the separate review exists

It modifies the behavior of all qualified lookups in Clang, so I would assume there would be some behavior change associated with this?

In case of qualified lookup it raises flag in DeclContext, which is not used anywhere else in clang, only in lldb (clang expression parser is linked to lldb).

In case of qualified lookup it raises flag in DeclContext, which is not used anywhere else in clang, only in lldb (clang expression parser is linked to lldb).

Hah, good point, the test case is in lldb, not in clang, for that very reason. :-P Carry on (I must need more sleep).

Can someone look at it, please?

aaron.ballman accepted this revision.Nov 6 2015, 6:25 AM
aaron.ballman edited edge metadata.

With moving the definition of the Deinitializer class closer to its use (it should be defined within the function itself given the limited use), LGTM.

clang/lib/Sema/SemaLookup.cpp
211

Formatting (the & goes with d).

This revision is now accepted and ready to land.Nov 6 2015, 6:25 AM
evgeny777 closed this revision.Nov 18 2015, 4:52 AM

Deinitializer class was renamed and moved under LookupQualifiedName() function scope