[index] Fix dynamicMemberLookup subscript reference implicit role

When building the implicit subscript expression, set the "implicit" bit
correctly and pass it through in the indexer so that we get implicit
refernces to the subscript. This would be useful for e.g. searching for
all uses of the dynamic subscript.
This commit is contained in:
Ben Langmuir
2019-04-02 16:43:27 -07:00
parent 0224d40551
commit 6af24d083c
10 changed files with 56 additions and 35 deletions

View File

@@ -41,8 +41,10 @@ enum class SemaReferenceKind : uint8_t {
struct ReferenceMetaData {
SemaReferenceKind Kind;
llvm::Optional<AccessKind> AccKind;
ReferenceMetaData(SemaReferenceKind Kind, llvm::Optional<AccessKind> AccKind) :
Kind(Kind), AccKind(AccKind) {}
bool isImplicit = false;
ReferenceMetaData(SemaReferenceKind Kind, llvm::Optional<AccessKind> AccKind,
bool isImplicit = false)
: Kind(Kind), AccKind(AccKind), isImplicit(isImplicit) {}
};
/// An abstract class used to traverse an AST.

View File

@@ -113,11 +113,11 @@ public:
///
/// \param D the referenced decl.
/// \param Range the source range of the source reference.
/// \param AccKind whether this is a read, write or read/write access.
/// \param Data whether this is a read, write or read/write access, etc.
/// \param IsOpenBracket this is \c true when the method is called on an
/// open bracket.
virtual bool visitSubscriptReference(ValueDecl *D, CharSourceRange Range,
Optional<AccessKind> AccKind,
ReferenceMetaData Data,
bool IsOpenBracket);
/// This method is called for each keyword argument in a call expression.

View File

@@ -231,7 +231,7 @@ private:
bool tryResolve(ModuleEntity Mod, SourceLoc Loc);
bool tryResolve(Stmt *St);
bool visitSubscriptReference(ValueDecl *D, CharSourceRange Range,
Optional<AccessKind> AccKind,
ReferenceMetaData Data,
bool IsOpenBracket) override;
};