blob: b35ca0bcaf62d04740620970c3b910bec4170a22 [file] [log] [blame]
Ted Kremenek1b6869a2010-01-05 22:06:45 +00001//===- CIndexUSR.cpp - Clang-C Source Indexing Library --------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// This file implements the generation and use of USRs from CXEntities.
11//
12//===----------------------------------------------------------------------===//
13
14#include "CIndexer.h"
Ted Kremenekcf84aa42010-01-18 20:23:29 +000015#include "CXCursor.h"
Benjamin Kramer9895c6a2010-01-12 11:32:40 +000016#include "clang/AST/DeclVisitor.h"
Ted Kremenek6f153952010-04-15 21:51:13 +000017#include "clang/Frontend/ASTUnit.h"
Benjamin Kramerb846deb2010-04-12 19:45:50 +000018#include "clang/Lex/PreprocessingRecord.h"
Ted Kremenek87763822010-01-12 02:07:58 +000019#include "llvm/ADT/SmallString.h"
Benjamin Kramer9895c6a2010-01-12 11:32:40 +000020#include "llvm/Support/raw_ostream.h"
Ted Kremenek6f153952010-04-15 21:51:13 +000021
Benjamin Kramerb846deb2010-04-12 19:45:50 +000022using namespace clang;
Ted Kremenekee4db4f2010-02-17 00:41:08 +000023using namespace clang::cxstring;
24
Ted Kremenekc50277f2010-01-12 23:33:42 +000025//===----------------------------------------------------------------------===//
26// USR generation.
27//===----------------------------------------------------------------------===//
28
29namespace {
Ted Kremenek2fee4e62010-01-14 01:50:21 +000030class USRGenerator : public DeclVisitor<USRGenerator> {
31 llvm::raw_ostream &Out;
Ted Kremenek3adca6d2010-01-18 22:02:49 +000032 bool IgnoreResults;
Ted Kremenek1865cfe2010-04-15 21:04:25 +000033 ASTUnit *AU;
Ted Kremenek2fee4e62010-01-14 01:50:21 +000034public:
Ted Kremenek1865cfe2010-04-15 21:04:25 +000035 USRGenerator(ASTUnit *au, llvm::raw_ostream &out)
36 : Out(out), IgnoreResults(false), AU(au) {}
Ted Kremenek896b70f2010-03-13 02:50:34 +000037
Ted Kremenek3adca6d2010-01-18 22:02:49 +000038 bool ignoreResults() const { return IgnoreResults; }
Ted Kremenek896b70f2010-03-13 02:50:34 +000039
40 // Visitation methods from generating USRs from AST elements.
Ted Kremenek2fee4e62010-01-14 01:50:21 +000041 void VisitBlockDecl(BlockDecl *D);
42 void VisitDeclContext(DeclContext *D);
Ted Kremenek3adca6d2010-01-18 22:02:49 +000043 void VisitFieldDecl(FieldDecl *D);
Ted Kremenek2fee4e62010-01-14 01:50:21 +000044 void VisitFunctionDecl(FunctionDecl *D);
45 void VisitNamedDecl(NamedDecl *D);
46 void VisitNamespaceDecl(NamespaceDecl *D);
Ted Kremeneke74ef122010-04-16 21:31:52 +000047 void VisitObjCClassDecl(ObjCClassDecl *CD);
Ted Kremenek896b70f2010-03-13 02:50:34 +000048 void VisitObjCContainerDecl(ObjCContainerDecl *CD);
Ted Kremenek2fee4e62010-01-14 01:50:21 +000049 void VisitObjCMethodDecl(ObjCMethodDecl *MD);
Ted Kremeneke74ef122010-04-16 21:31:52 +000050 void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *P);
Ted Kremenek2fee4e62010-01-14 01:50:21 +000051 void VisitObjCPropertyDecl(ObjCPropertyDecl *D);
Ted Kremenekb82b3be2010-01-18 22:42:20 +000052 void VisitTagDecl(TagDecl *D);
Ted Kremenek2fee4e62010-01-14 01:50:21 +000053 void VisitTypedefDecl(TypedefDecl *D);
Ted Kremenek896b70f2010-03-13 02:50:34 +000054
Ted Kremenek6f153952010-04-15 21:51:13 +000055 /// Generate the string component containing the location of the
56 /// declaration.
57 void GenLoc(const Decl *D);
58
Ted Kremenek896b70f2010-03-13 02:50:34 +000059 /// String generation methods used both by the visitation methods
60 /// and from other clients that want to directly generate USRs. These
61 /// methods do not construct complete USRs (which incorporate the parents
62 /// of an AST element), but only the fragments concerning the AST element
63 /// itself.
64
65 /// Generate a USR fragment for a named declaration. This does
66 /// not include the USR component for the parent.
67 void GenNamedDecl(llvm::StringRef name);
68
69 /// Generate a USR for an Objective-C class.
70 void GenObjCClass(llvm::StringRef cls);
71 /// Generate a USR for an Objective-C class category.
72 void GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat);
73 /// Generate a USR fragment for an Objective-C instance variable. The
74 /// complete USR can be created by concatenating the USR for the
75 /// encompassing class with this USR fragment.
76 void GenObjCIvar(llvm::StringRef ivar);
77 /// Generate a USR fragment for an Objective-C method.
78 void GenObjCMethod(llvm::StringRef sel, bool isInstanceMethod);
79 /// Generate a USR fragment for an Objective-C property.
80 void GenObjCProperty(llvm::StringRef prop);
81 /// Generate a USR for an Objective-C protocol.
82 void GenObjCProtocol(llvm::StringRef prot);
Ted Kremenek2fee4e62010-01-14 01:50:21 +000083};
Ted Kremenek896b70f2010-03-13 02:50:34 +000084
85class StringUSRGenerator {
86private:
87 llvm::SmallString<1024> StrBuf;
88 llvm::raw_svector_ostream Out;
89 USRGenerator UG;
90public:
Ted Kremenek1865cfe2010-04-15 21:04:25 +000091 StringUSRGenerator(const CXCursor *C = 0)
92 : Out(StrBuf), UG(C ? cxcursor::getCursorASTUnit(*C) : 0, Out) {
Ted Kremenek0c0fb412010-03-25 02:00:36 +000093 // Add the USR space prefix.
Ted Kremenek1865cfe2010-04-15 21:04:25 +000094 Out << "c:";
Ted Kremenek0c0fb412010-03-25 02:00:36 +000095 }
Ted Kremenek896b70f2010-03-13 02:50:34 +000096
97 llvm::StringRef str() {
98 return Out.str();
99 }
100
101 USRGenerator* operator->() { return &UG; }
102
103 template <typename T>
104 llvm::raw_svector_ostream &operator<<(const T &x) {
105 Out << x;
106 return Out;
107 }
108};
109
Ted Kremenekc50277f2010-01-12 23:33:42 +0000110} // end anonymous namespace
111
Ted Kremenek896b70f2010-03-13 02:50:34 +0000112//===----------------------------------------------------------------------===//
113// Generating USRs from ASTS.
114//===----------------------------------------------------------------------===//
115
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000116void USRGenerator::VisitBlockDecl(BlockDecl *D) {
117 VisitDeclContext(D->getDeclContext());
118 // FIXME: Better support for anonymous blocks.
Ted Kremeneke74ef122010-04-16 21:31:52 +0000119 Out << "@B@anon";
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000120}
121
122void USRGenerator::VisitDeclContext(DeclContext *DC) {
123 if (NamedDecl *D = dyn_cast<NamedDecl>(DC))
124 Visit(D);
125}
126
Ted Kremenek3adca6d2010-01-18 22:02:49 +0000127void USRGenerator::VisitFieldDecl(FieldDecl *D) {
128 const std::string &s = D->getNameAsString();
129 if (s.empty()) {
130 // Bit fields can be anonymous.
131 IgnoreResults = true;
132 return;
133 }
134 VisitDeclContext(D->getDeclContext());
Ted Kremeneke74ef122010-04-16 21:31:52 +0000135 Out << "@FI@" << s;
Ted Kremenek3adca6d2010-01-18 22:02:49 +0000136}
137
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000138void USRGenerator::VisitFunctionDecl(FunctionDecl *D) {
139 VisitDeclContext(D->getDeclContext());
Ted Kremeneke74ef122010-04-16 21:31:52 +0000140 Out << "@F@" << D->getNameAsString();
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000141}
Ted Kremenekc50277f2010-01-12 23:33:42 +0000142
143void USRGenerator::VisitNamedDecl(NamedDecl *D) {
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000144 VisitDeclContext(D->getDeclContext());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000145 const std::string &s = D->getNameAsString();
Ted Kremeneke74ef122010-04-16 21:31:52 +0000146 // The string can be empty if the declaration has no name; e.g., it is
147 // the ParmDecl with no name for declaration of a function pointer type, e.g.:
148 // void (*f)(void *);
149 // In this case, don't generate a USR.
150 if (s.empty())
151 IgnoreResults = true;
152 else
153 GenNamedDecl(s);
Ted Kremenek2fee4e62010-01-14 01:50:21 +0000154}
155
156void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) {
157 VisitDeclContext(D->getDeclContext());
Ted Kremeneke74ef122010-04-16 21:31:52 +0000158 Out << "@N@" << D->getNameAsString();
Ted Kremenekc50277f2010-01-12 23:33:42 +0000159}
160
Ted Kremenekc50277f2010-01-12 23:33:42 +0000161void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) {
162 Visit(cast<Decl>(D->getDeclContext()));
Ted Kremenek896b70f2010-03-13 02:50:34 +0000163 GenObjCMethod(DeclarationName(D->getSelector()).getAsString(),
164 D->isInstanceMethod());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000165}
166
Ted Kremeneke74ef122010-04-16 21:31:52 +0000167void USRGenerator::VisitObjCClassDecl(ObjCClassDecl *D) {
168 // FIXME: @class declarations can refer to multiple classes. We need
169 // to be able to traverse these.
170 IgnoreResults = true;
171}
172
173void USRGenerator::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) {
174 // FIXME: @protocol declarations can refer to multiple protocols. We need
175 // to be able to traverse these.
176 IgnoreResults = true;
177}
178
Ted Kremenekc50277f2010-01-12 23:33:42 +0000179void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) {
180 switch (D->getKind()) {
181 default:
182 assert(false && "Invalid ObjC container.");
183 case Decl::ObjCInterface:
184 case Decl::ObjCImplementation:
Ted Kremenek896b70f2010-03-13 02:50:34 +0000185 GenObjCClass(D->getName());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000186 break;
187 case Decl::ObjCCategory: {
188 ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(D);
Ted Kremenekebfa3392010-03-19 20:39:03 +0000189 ObjCInterfaceDecl *ID = CD->getClassInterface();
190 if (!ID) {
191 // Handle invalid code where the @interface might not
192 // have been specified.
193 // FIXME: We should be able to generate this USR even if the
194 // @interface isn't available.
195 IgnoreResults = true;
196 return;
197 }
198 GenObjCCategory(ID->getName(), CD->getName());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000199 break;
200 }
201 case Decl::ObjCCategoryImpl: {
202 ObjCCategoryImplDecl *CD = cast<ObjCCategoryImplDecl>(D);
Ted Kremenekebfa3392010-03-19 20:39:03 +0000203 ObjCInterfaceDecl *ID = CD->getClassInterface();
204 if (!ID) {
205 // Handle invalid code where the @interface might not
206 // have been specified.
207 // FIXME: We should be able to generate this USR even if the
208 // @interface isn't available.
209 IgnoreResults = true;
210 return;
211 }
212 GenObjCCategory(ID->getName(), CD->getName());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000213 break;
214 }
215 case Decl::ObjCProtocol:
Ted Kremenek896b70f2010-03-13 02:50:34 +0000216 GenObjCProtocol(cast<ObjCProtocolDecl>(D)->getName());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000217 break;
218 }
219}
220
221void USRGenerator::VisitObjCPropertyDecl(ObjCPropertyDecl *D) {
222 Visit(cast<Decl>(D->getDeclContext()));
Ted Kremenek896b70f2010-03-13 02:50:34 +0000223 GenObjCProperty(D->getName());
Ted Kremenekc50277f2010-01-12 23:33:42 +0000224}
225
Ted Kremenekb82b3be2010-01-18 22:42:20 +0000226void USRGenerator::VisitTagDecl(TagDecl *D) {
Ted Kremenek6f153952010-04-15 21:51:13 +0000227 D = D->getCanonicalDecl();
Ted Kremenekb82b3be2010-01-18 22:42:20 +0000228 VisitDeclContext(D->getDeclContext());
229 switch (D->getTagKind()) {
Ted Kremeneke74ef122010-04-16 21:31:52 +0000230 case TagDecl::TK_struct: Out << "@S"; break;
231 case TagDecl::TK_class: Out << "@C"; break;
232 case TagDecl::TK_union: Out << "@U"; break;
233 case TagDecl::TK_enum: Out << "@E"; break;
234 }
235
236 const std::string &s = D->getNameAsString();
237 const TypedefDecl *TD = 0;
238 if (s.empty()) {
239 TD = D->getTypedefForAnonDecl();
240 Out << (TD ? 'A' : 'a');
Ted Kremenekb82b3be2010-01-18 22:42:20 +0000241 }
Ted Kremenek896b70f2010-03-13 02:50:34 +0000242
Ted Kremenek6f153952010-04-15 21:51:13 +0000243 // Add the location of the tag decl to handle resolution across
244 // translation units.
245 if (D->getLinkage() == NoLinkage) {
Ted Kremeneke74ef122010-04-16 21:31:52 +0000246 Out << '@';
Ted Kremenek6f153952010-04-15 21:51:13 +0000247 GenLoc(D);
248 if (IgnoreResults)
249 return;
250 }
251
Ted Kremenekc5b48b32010-01-15 23:34:31 +0000252 if (s.empty()) {
Ted Kremeneke74ef122010-04-16 21:31:52 +0000253 if (TD)
254 Out << '@' << TD->getNameAsString();
Ted Kremenekc5b48b32010-01-15 23:34:31 +0000255 }
256 else
Ted Kremeneke74ef122010-04-16 21:31:52 +0000257 Out << '@' << s;
Ted Kremenekc5b48b32010-01-15 23:34:31 +0000258}
259
Ted Kremenekc50277f2010-01-12 23:33:42 +0000260void USRGenerator::VisitTypedefDecl(TypedefDecl *D) {
261 DeclContext *DC = D->getDeclContext();
262 if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC))
Ted Kremenek896b70f2010-03-13 02:50:34 +0000263 Visit(DCN);
Ted Kremeneke74ef122010-04-16 21:31:52 +0000264 Out << "@T@";
265 if (D->getLinkage() == NoLinkage) {
266 GenLoc(D);
267 if (IgnoreResults)
268 return;
269 Out << '@';
270 }
Ted Kremenek6f153952010-04-15 21:51:13 +0000271 Out << D->getName();
272}
273
274void USRGenerator::GenLoc(const Decl *D) {
275 const SourceManager &SM = AU->getSourceManager();
276 SourceLocation L = D->getLocStart();
277 if (L.isInvalid()) {
278 IgnoreResults = true;
279 return;
280 }
281 L = SM.getInstantiationLoc(L);
282 const std::pair<FileID, unsigned> &Decomposed = SM.getDecomposedLoc(L);
283 const FileEntry *FE = SM.getFileEntryForID(Decomposed.first);
Ted Kremeneke74ef122010-04-16 21:31:52 +0000284 if (FE) {
285 llvm::sys::Path P(FE->getName());
286 Out << P.getLast();
287 }
Ted Kremenek6f153952010-04-15 21:51:13 +0000288 else {
289 // This case really isn't interesting.
290 IgnoreResults = true;
291 return;
292 }
Ted Kremeneke74ef122010-04-16 21:31:52 +0000293 Out << '@'
294 << SM.getLineNumber(Decomposed.first, Decomposed.second) << ':'
295 << SM.getColumnNumber(Decomposed.first, Decomposed.second);
Ted Kremenekc50277f2010-01-12 23:33:42 +0000296}
297
Ted Kremenek896b70f2010-03-13 02:50:34 +0000298//===----------------------------------------------------------------------===//
299// General purpose USR generation methods.
300//===----------------------------------------------------------------------===//
Ted Kremenekcf84aa42010-01-18 20:23:29 +0000301
Ted Kremenek896b70f2010-03-13 02:50:34 +0000302void USRGenerator::GenNamedDecl(llvm::StringRef name) {
Ted Kremeneke74ef122010-04-16 21:31:52 +0000303 Out << "@" << name;
Ted Kremenek896b70f2010-03-13 02:50:34 +0000304}
305
306void USRGenerator::GenObjCClass(llvm::StringRef cls) {
307 Out << "objc(cs)" << cls;
308}
309
310void USRGenerator::GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat) {
Ted Kremeneke74ef122010-04-16 21:31:52 +0000311 Out << "objc(cy)" << cls << '@' << cat;
Ted Kremenek896b70f2010-03-13 02:50:34 +0000312}
313
314void USRGenerator::GenObjCIvar(llvm::StringRef ivar) {
315 GenNamedDecl(ivar);
316}
317
318void USRGenerator::GenObjCMethod(llvm::StringRef meth, bool isInstanceMethod) {
319 Out << (isInstanceMethod ? "(im)" : "(cm)") << meth;
320}
321
322void USRGenerator::GenObjCProperty(llvm::StringRef prop) {
323 Out << "(py)" << prop;
324}
325
326void USRGenerator::GenObjCProtocol(llvm::StringRef prot) {
327 Out << "objc(pl)" << prot;
328}
329
330//===----------------------------------------------------------------------===//
331// API hooks.
332//===----------------------------------------------------------------------===//
Ted Kremenekcf84aa42010-01-18 20:23:29 +0000333
Benjamin Kramercfb51b62010-04-08 15:54:07 +0000334static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) {
335 return s.startswith("c:") ? s.substr(2) : "";
336}
337
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000338static CXString getDeclCursorUSR(const CXCursor &C) {
Ted Kremenek896b70f2010-03-13 02:50:34 +0000339 Decl *D = cxcursor::getCursorDecl(C);
Ted Kremeneke74ef122010-04-16 21:31:52 +0000340
341 // Don't generate USRs for things with invalid locations.
342 if (!D || D->getLocStart().isInvalid())
Ted Kremenek896b70f2010-03-13 02:50:34 +0000343 return createCXString(NULL);
344
Ted Kremenek1865cfe2010-04-15 21:04:25 +0000345 // Check if the cursor has 'NoLinkage'.
Ted Kremeneke74ef122010-04-16 21:31:52 +0000346 if (const NamedDecl *ND = dyn_cast<NamedDecl>(D))
Ted Kremenek1865cfe2010-04-15 21:04:25 +0000347 switch (ND->getLinkage()) {
348 case ExternalLinkage:
349 // Generate USRs for all entities with external linkage.
350 break;
351 case NoLinkage:
352 // We allow enums, typedefs, and structs that have no linkage to
353 // have USRs that are anchored to the file they were defined in
354 // (e.g., the header). This is a little gross, but in principal
355 // enums/anonymous structs/etc. defined in a common header file
356 // are referred to across multiple translation units.
Ted Kremenek6f153952010-04-15 21:51:13 +0000357 if (isa<TagDecl>(ND) || isa<TypedefDecl>(ND) ||
Ted Kremeneke74ef122010-04-16 21:31:52 +0000358 isa<EnumConstantDecl>(ND) || isa<FieldDecl>(ND))
Ted Kremenek1865cfe2010-04-15 21:04:25 +0000359 break;
360 // Fall-through.
361 case InternalLinkage:
362 case UniqueExternalLinkage:
363 return createCXString("");
364 }
365
366 StringUSRGenerator SUG(&C);
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000367 SUG->Visit(D);
Ted Kremenek896b70f2010-03-13 02:50:34 +0000368
Ted Kremenek0c0fb412010-03-25 02:00:36 +0000369 if (SUG->ignoreResults())
Ted Kremenekebfa3392010-03-19 20:39:03 +0000370 return createCXString("");
Ted Kremenek896b70f2010-03-13 02:50:34 +0000371
Ted Kremeneke74ef122010-04-16 21:31:52 +0000372 assert(SUG.str().size() > 3);
373
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000374 // Return a copy of the string that must be disposed by the caller.
Ted Kremenek896b70f2010-03-13 02:50:34 +0000375 return createCXString(SUG.str(), true);
376}
377
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000378extern "C" {
379
380CXString clang_getCursorUSR(CXCursor C) {
Ted Kremenekfa8231d2010-04-11 22:20:34 +0000381 const CXCursorKind &K = clang_getCursorKind(C);
382
383 if (clang_isDeclaration(K))
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000384 return getDeclCursorUSR(C);
Ted Kremenekfa8231d2010-04-11 22:20:34 +0000385
386 if (K == CXCursor_MacroDefinition) {
Ted Kremenek1865cfe2010-04-15 21:04:25 +0000387 StringUSRGenerator SUG(&C);
Ted Kremenekfa8231d2010-04-11 22:20:34 +0000388 SUG << "macro@"
389 << cxcursor::getCursorMacroDefinition(C)->getName()->getNameStart();
390 return createCXString(SUG.str(), true);
391 }
392
Ted Kremenekc3ef91d2010-04-11 22:20:26 +0000393 return createCXString("");
394}
395
Ted Kremenek896b70f2010-03-13 02:50:34 +0000396CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) {
397 StringUSRGenerator SUG;
Ted Kremenek0c0fb412010-03-25 02:00:36 +0000398 SUG << extractUSRSuffix(clang_getCString(classUSR));
Ted Kremenek896b70f2010-03-13 02:50:34 +0000399 SUG->GenObjCIvar(name);
400 return createCXString(SUG.str(), true);
401}
402
403CXString clang_constructUSR_ObjCMethod(const char *name,
404 unsigned isInstanceMethod,
405 CXString classUSR) {
406 StringUSRGenerator SUG;
Ted Kremenek0c0fb412010-03-25 02:00:36 +0000407 SUG << extractUSRSuffix(clang_getCString(classUSR));
Ted Kremenek896b70f2010-03-13 02:50:34 +0000408 SUG->GenObjCMethod(name, isInstanceMethod);
409 return createCXString(SUG.str(), true);
410}
411
412CXString clang_constructUSR_ObjCClass(const char *name) {
413 StringUSRGenerator SUG;
414 SUG->GenObjCClass(name);
415 return createCXString(SUG.str(), true);
416}
417
418CXString clang_constructUSR_ObjCProtocol(const char *name) {
419 StringUSRGenerator SUG;
420 SUG->GenObjCProtocol(name);
421 return createCXString(SUG.str(), true);
422}
423
Ted Kremenek66ccaec2010-03-15 17:38:58 +0000424CXString clang_constructUSR_ObjCCategory(const char *class_name,
Ted Kremenek0c0fb412010-03-25 02:00:36 +0000425 const char *category_name) {
Ted Kremenek896b70f2010-03-13 02:50:34 +0000426 StringUSRGenerator SUG;
427 SUG->GenObjCCategory(class_name, category_name);
428 return createCXString(SUG.str(), true);
429}
430
431CXString clang_constructUSR_ObjCProperty(const char *property,
432 CXString classUSR) {
433 StringUSRGenerator SUG;
Ted Kremenek0c0fb412010-03-25 02:00:36 +0000434 SUG << extractUSRSuffix(clang_getCString(classUSR));
Ted Kremenek896b70f2010-03-13 02:50:34 +0000435 SUG->GenObjCProperty(property);
436 return createCXString(SUG.str(), true);
Ted Kremenekcf84aa42010-01-18 20:23:29 +0000437}
Ted Kremenek1b6869a2010-01-05 22:06:45 +0000438
Ted Kremenek1b6869a2010-01-05 22:06:45 +0000439} // end extern "C"