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 | 87ec9c257c99b4136af6c7f5be5a2d486906ba84 (patch) | |
tree | 16e40e422cbb65ab40940d730d365118217c08f5 /tools/libclang/CIndexUSRs.cpp | |
parent | 177dce777596e68d111d6d3e6046f3ddfc96bd07 (diff) | |
download | clang-87ec9c257c99b4136af6c7f5be5a2d486906ba84.tar.gz |
[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
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@143464 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools/libclang/CIndexUSRs.cpp')
-rw-r--r-- | tools/libclang/CIndexUSRs.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/tools/libclang/CIndexUSRs.cpp b/tools/libclang/CIndexUSRs.cpp index 11b124c562..32c4db6abe 100644 --- a/tools/libclang/CIndexUSRs.cpp +++ b/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()); } |