bool IndexingContext::handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
DeclInfo &DInfo,
- const DeclContext *LexicalDC) {
+ const DeclContext *LexicalDC,
+ const DeclContext *SemaDC) {
if (!CB.indexDeclaration || !D)
return false;
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
DInfo.attributes = DInfo.EntInfo.attributes;
DInfo.numAttributes = DInfo.EntInfo.numAttributes;
- getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
+ if (!SemaDC)
+ SemaDC = D->getDeclContext();
+ getContainerInfo(SemaDC, DInfo.SemanticContainer);
DInfo.semanticContainer = &DInfo.SemanticContainer;
- if (LexicalDC == D->getDeclContext()) {
+ if (LexicalDC == SemaDC) {
DInfo.lexicalContainer = &DInfo.SemanticContainer;
} else if (isTemplateImplicitInstantiation(D)) {
// Implicit instantiations have the lexical context of where they were
const DeclContext *LexicalDC) {
DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true,
/*isContainer=*/false);
- return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC);
+ return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC, LexicalDC);
}
bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
bool handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
DeclInfo &DInfo,
- const DeclContext *LexicalDC = nullptr);
+ const DeclContext *LexicalDC = nullptr,
+ const DeclContext *SemaDC = nullptr);
bool handleObjCContainer(const ObjCContainerDecl *D,
SourceLocation Loc, CXCursor Cursor,