r275630 - [index] Create different USR if a property is a class property.
Argyrios Kyrtzidis via cfe-commits
cfe-commits at lists.llvm.org
Fri Jul 15 15:18:20 PDT 2016
Author: akirtzidis
Date: Fri Jul 15 17:18:19 2016
New Revision: 275630
URL: http://llvm.org/viewvc/llvm-project?rev=275630&view=rev
Log:
[index] Create different USR if a property is a class property.
Avoids USR conflicts between class & instance properties of the same name.
Modified:
cfe/trunk/include/clang/Index/USRGeneration.h
cfe/trunk/lib/Index/USRGeneration.cpp
cfe/trunk/test/Index/index-decls.m
cfe/trunk/tools/libclang/CIndexUSRs.cpp
Modified: cfe/trunk/include/clang/Index/USRGeneration.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Index/USRGeneration.h?rev=275630&r1=275629&r2=275630&view=diff
==============================================================================
--- cfe/trunk/include/clang/Index/USRGeneration.h (original)
+++ cfe/trunk/include/clang/Index/USRGeneration.h Fri Jul 15 17:18:19 2016
@@ -44,7 +44,7 @@ void generateUSRForObjCMethod(StringRef
raw_ostream &OS);
/// \brief Generate a USR fragment for an Objective-C property.
-void generateUSRForObjCProperty(StringRef Prop, raw_ostream &OS);
+void generateUSRForObjCProperty(StringRef Prop, bool isClassProp, raw_ostream &OS);
/// \brief Generate a USR fragment for an Objective-C protocol.
void generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS);
Modified: cfe/trunk/lib/Index/USRGeneration.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Index/USRGeneration.cpp?rev=275630&r1=275629&r2=275630&view=diff
==============================================================================
--- cfe/trunk/lib/Index/USRGeneration.cpp (original)
+++ cfe/trunk/lib/Index/USRGeneration.cpp Fri Jul 15 17:18:19 2016
@@ -138,8 +138,8 @@ public:
}
/// Generate a USR fragment for an Objective-C property.
- void GenObjCProperty(StringRef prop) {
- generateUSRForObjCProperty(prop, Out);
+ void GenObjCProperty(StringRef prop, bool isClassProp) {
+ generateUSRForObjCProperty(prop, isClassProp, Out);
}
/// Generate a USR for an Objective-C protocol.
@@ -411,7 +411,7 @@ void USRGenerator::VisitObjCPropertyDecl
Visit(ID);
else
Visit(cast<Decl>(D->getDeclContext()));
- GenObjCProperty(D->getName());
+ GenObjCProperty(D->getName(), D->isClassProperty());
}
void USRGenerator::VisitObjCPropertyImplDecl(const ObjCPropertyImplDecl *D) {
@@ -864,8 +864,9 @@ void clang::index::generateUSRForObjCMet
OS << (IsInstanceMethod ? "(im)" : "(cm)") << Sel;
}
-void clang::index::generateUSRForObjCProperty(StringRef Prop, raw_ostream &OS) {
- OS << "(py)" << Prop;
+void clang::index::generateUSRForObjCProperty(StringRef Prop, bool isClassProp,
+ raw_ostream &OS) {
+ OS << (isClassProp ? "(cpy)" : "(py)") << Prop;
}
void clang::index::generateUSRForObjCProtocol(StringRef Prot, raw_ostream &OS) {
Modified: cfe/trunk/test/Index/index-decls.m
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/index-decls.m?rev=275630&r1=275629&r2=275630&view=diff
==============================================================================
--- cfe/trunk/test/Index/index-decls.m (original)
+++ cfe/trunk/test/Index/index-decls.m Fri Jul 15 17:18:19 2016
@@ -52,6 +52,7 @@ int test1() {
@class I5;
@interface I5
-(void)meth;
+ at property (class) int c;
@end
// RUN: c-index-test -index-file %s -target x86_64-apple-macosx10.7 > %t
@@ -82,3 +83,4 @@ int test1() {
// CHECK-NOT: [indexDeclaration]: kind: objc-instance-method {{.*}} loc: 43:
// CHECK: [indexDeclaration]: kind: objc-instance-method | name: meth | {{.*}} loc: 54:1 | {{.*}} | isRedecl: 0 | isDef: 0 |
+// CHECK: [indexDeclaration]: kind: objc-property | name: c | USR: c:objc(cs)I5(cpy)c | lang: ObjC | cursor: ObjCPropertyDecl=c:55:23 [class,] | loc: 55:23
Modified: cfe/trunk/tools/libclang/CIndexUSRs.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndexUSRs.cpp?rev=275630&r1=275629&r2=275630&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndexUSRs.cpp (original)
+++ cfe/trunk/tools/libclang/CIndexUSRs.cpp Fri Jul 15 17:18:19 2016
@@ -137,7 +137,7 @@ CXString clang_constructUSR_ObjCProperty
SmallString<128> Buf(getUSRSpacePrefix());
llvm::raw_svector_ostream OS(Buf);
OS << extractUSRSuffix(clang_getCString(classUSR));
- generateUSRForObjCProperty(property, OS);
+ generateUSRForObjCProperty(property, /*isClassProp=*/false, OS);
return cxstring::createDup(OS.str());
}
More information about the cfe-commits
mailing list