diff options
author | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-01 17:14:12 +0000 |
---|---|---|
committer | Argyrios Kyrtzidis <akyrtzi@gmail.com> | 2011-11-01 17:14:12 +0000 |
commit | b9689bb46f5b28f035f24f70e1b165f6b4514425 (patch) | |
tree | 81151cb2754ba96d64c22eebf89d9446250087a0 /clang/tools/libclang/CIndexUSRs.cpp | |
parent | fec0992acaf273f1c98c883c822e1db3cda3c9cf (diff) | |
download | bcm5719-llvm-b9689bb46f5b28f035f24f70e1b165f6b4514425.tar.gz bcm5719-llvm-b9689bb46f5b28f035f24f70e1b165f6b4514425.zip |
[libclang] For a class extension, give it a unique USR but for any property or ivar
it contains give it a USR based on its semantic context, which is the interface.
This follows what we already did for objc methods. rdar://10371669
llvm-svn: 143464
Diffstat (limited to 'clang/tools/libclang/CIndexUSRs.cpp')
-rw-r--r-- | clang/tools/libclang/CIndexUSRs.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/clang/tools/libclang/CIndexUSRs.cpp b/clang/tools/libclang/CIndexUSRs.cpp index 11b124c5627..32c4db6abec 100644 --- a/clang/tools/libclang/CIndexUSRs.cpp +++ b/clang/tools/libclang/CIndexUSRs.cpp @@ -169,7 +169,12 @@ void USRGenerator::VisitDeclContext(DeclContext *DC) { } void USRGenerator::VisitFieldDecl(FieldDecl *D) { - VisitDeclContext(D->getDeclContext()); + // The USR for an ivar declared in a class extension is based on the + // ObjCInterfaceDecl, not the ObjCCategoryDecl. + if (ObjCInterfaceDecl *ID = Context->getObjContainingInterface(D)) + Visit(ID); + else + VisitDeclContext(D->getDeclContext()); Out << (isa<ObjCIvarDecl>(D) ? "@" : "@FI@"); if (EmitDeclName(D)) { // Bit fields can be anonymous. @@ -336,9 +341,11 @@ void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) { IgnoreResults = true; return; } + // Specially handle class extensions, which are anonymous categories. + // We want to mangle in the location to uniquely distinguish them. if (CD->IsClassExtension()) { - // An extension semantically continues the interface of the class. - GenObjCClass(ID->getName()); + Out << "objc(ext)" << ID->getName() << '@'; + GenLoc(CD); } else GenObjCCategory(ID->getName(), CD->getName()); @@ -366,7 +373,12 @@ void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) { } void USRGenerator::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { - Visit(cast<Decl>(D->getDeclContext())); + // The USR for a property declared in a class extension or category is based + // on the ObjCInterfaceDecl, not the ObjCCategoryDecl. + if (ObjCInterfaceDecl *ID = Context->getObjContainingInterface(D)) + Visit(ID); + else + Visit(cast<Decl>(D->getDeclContext())); GenObjCProperty(D->getName()); } |