[cfe-commits] r151635 - in /cfe/trunk: lib/Sema/SemaObjCProperty.cpp tools/libclang/IndexDecl.cpp tools/libclang/IndexingContext.cpp tools/libclang/IndexingContext.h
Argyrios Kyrtzidis
akyrtzi at gmail.com
Tue Feb 28 09:50:39 PST 2012
Author: akirtzidis
Date: Tue Feb 28 11:50:39 2012
New Revision: 151635
URL: http://llvm.org/viewvc/llvm-project?rev=151635&view=rev
Log:
[AST] When we @synthesize a property with a user-defined ivar name,
make sure to record the source location of the ivar name.
[libclang] When indexing @synthesized objc methods, report the @implementation
as the lexical container.
Fixes rdar://10905472
Modified:
cfe/trunk/lib/Sema/SemaObjCProperty.cpp
cfe/trunk/tools/libclang/IndexDecl.cpp
cfe/trunk/tools/libclang/IndexingContext.cpp
cfe/trunk/tools/libclang/IndexingContext.h
Modified: cfe/trunk/lib/Sema/SemaObjCProperty.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaObjCProperty.cpp?rev=151635&r1=151634&r2=151635&view=diff
==============================================================================
--- cfe/trunk/lib/Sema/SemaObjCProperty.cpp (original)
+++ cfe/trunk/lib/Sema/SemaObjCProperty.cpp Tue Feb 28 11:50:39 2012
@@ -582,6 +582,8 @@
Diag(AtLoc, diag::error_missing_property_context);
return 0;
}
+ if (PropertyIvarLoc.isInvalid())
+ PropertyIvarLoc = PropertyLoc;
ObjCPropertyDecl *property = 0;
ObjCInterfaceDecl* IDecl = 0;
// Find the class or category class where this property must have
@@ -729,7 +731,7 @@
}
Ivar = ObjCIvarDecl::Create(Context, ClassImpDecl,
- PropertyLoc, PropertyLoc, PropertyIvar,
+ PropertyIvarLoc,PropertyIvarLoc, PropertyIvar,
PropertyIvarType, /*Dinfo=*/0,
ObjCIvarDecl::Private,
(Expr *)0, true);
@@ -762,10 +764,8 @@
PropertyIvarType->getAs<ObjCObjectPointerType>(),
IvarType->getAs<ObjCObjectPointerType>());
else {
- SourceLocation Loc = PropertyIvarLoc;
- if (Loc.isInvalid())
- Loc = PropertyLoc;
- compat = (CheckAssignmentConstraints(Loc, PropertyIvarType, IvarType)
+ compat = (CheckAssignmentConstraints(PropertyIvarLoc, PropertyIvarType,
+ IvarType)
== Compatible);
}
if (!compat) {
Modified: cfe/trunk/tools/libclang/IndexDecl.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexDecl.cpp?rev=151635&r1=151634&r2=151635&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexDecl.cpp (original)
+++ cfe/trunk/tools/libclang/IndexDecl.cpp Tue Feb 28 11:50:39 2012
@@ -216,11 +216,13 @@
if (ObjCMethodDecl *MD = PD->getGetterMethodDecl()) {
if (MD->isSynthesized())
- IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+ IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+ D->getLexicalDeclContext());
}
if (ObjCMethodDecl *MD = PD->getSetterMethodDecl()) {
if (MD->isSynthesized())
- IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation());
+ IndexCtx.handleSynthesizedObjCMethod(MD, D->getLocation(),
+ D->getLexicalDeclContext());
}
return true;
}
Modified: cfe/trunk/tools/libclang/IndexingContext.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.cpp?rev=151635&r1=151634&r2=151635&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.cpp (original)
+++ cfe/trunk/tools/libclang/IndexingContext.cpp Tue Feb 28 11:50:39 2012
@@ -257,7 +257,8 @@
bool IndexingContext::handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
- DeclInfo &DInfo) {
+ DeclInfo &DInfo,
+ const DeclContext *LexicalDC) {
if (!CB.indexDeclaration || !D)
return false;
if (D->isImplicit() && shouldIgnoreIfImplicit(D))
@@ -269,6 +270,9 @@
|| Loc.isInvalid())
return false;
+ if (!LexicalDC)
+ LexicalDC = D->getLexicalDeclContext();
+
if (shouldSuppressRefs())
markEntityOccurrenceInFile(D, Loc);
@@ -284,7 +288,7 @@
getContainerInfo(D->getDeclContext(), DInfo.SemanticContainer);
DInfo.semanticContainer = &DInfo.SemanticContainer;
- if (D->getLexicalDeclContext() == D->getDeclContext()) {
+ if (LexicalDC == D->getDeclContext()) {
DInfo.lexicalContainer = &DInfo.SemanticContainer;
} else if (isTemplateImplicitInstantiation(D)) {
// Implicit instantiations have the lexical context of where they were
@@ -295,7 +299,7 @@
// information anyway.
DInfo.lexicalContainer = &DInfo.SemanticContainer;
} else {
- getContainerInfo(D->getLexicalDeclContext(), DInfo.LexicalContainer);
+ getContainerInfo(LexicalDC, DInfo.LexicalContainer);
DInfo.lexicalContainer = &DInfo.LexicalContainer;
}
@@ -510,10 +514,11 @@
}
bool IndexingContext::handleSynthesizedObjCMethod(const ObjCMethodDecl *D,
- SourceLocation Loc) {
+ SourceLocation Loc,
+ const DeclContext *LexicalDC) {
DeclInfo DInfo(/*isRedeclaration=*/true, /*isDefinition=*/true,
/*isContainer=*/false);
- return handleDecl(D, Loc, getCursor(D), DInfo);
+ return handleDecl(D, Loc, getCursor(D), DInfo, LexicalDC);
}
bool IndexingContext::handleObjCProperty(const ObjCPropertyDecl *D) {
Modified: cfe/trunk/tools/libclang/IndexingContext.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/IndexingContext.h?rev=151635&r1=151634&r2=151635&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/IndexingContext.h (original)
+++ cfe/trunk/tools/libclang/IndexingContext.h Tue Feb 28 11:50:39 2012
@@ -406,7 +406,8 @@
bool handleObjCMethod(const ObjCMethodDecl *D);
bool handleSynthesizedObjCProperty(const ObjCPropertyImplDecl *D);
- bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc);
+ bool handleSynthesizedObjCMethod(const ObjCMethodDecl *D, SourceLocation Loc,
+ const DeclContext *LexicalDC);
bool handleObjCProperty(const ObjCPropertyDecl *D);
@@ -452,7 +453,8 @@
private:
bool handleDecl(const NamedDecl *D,
SourceLocation Loc, CXCursor Cursor,
- DeclInfo &DInfo);
+ DeclInfo &DInfo,
+ const DeclContext *LexicalDC = 0);
bool handleObjCContainer(const ObjCContainerDecl *D,
SourceLocation Loc, CXCursor Cursor,
More information about the cfe-commits
mailing list