Ted Kremenek | 1b6869a | 2010-01-05 22:06:45 +0000 | [diff] [blame] | 1 | //===- 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 Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 15 | #include "CXCursor.h" |
Benjamin Kramer | 9895c6a | 2010-01-12 11:32:40 +0000 | [diff] [blame] | 16 | #include "clang/AST/DeclVisitor.h" |
Benjamin Kramer | b846deb | 2010-04-12 19:45:50 +0000 | [diff] [blame] | 17 | #include "clang/Lex/PreprocessingRecord.h" |
Ted Kremenek | 8776382 | 2010-01-12 02:07:58 +0000 | [diff] [blame] | 18 | #include "llvm/ADT/SmallString.h" |
Benjamin Kramer | 9895c6a | 2010-01-12 11:32:40 +0000 | [diff] [blame] | 19 | #include "llvm/Support/raw_ostream.h" |
Benjamin Kramer | b846deb | 2010-04-12 19:45:50 +0000 | [diff] [blame] | 20 | using namespace clang; |
Ted Kremenek | ee4db4f | 2010-02-17 00:41:08 +0000 | [diff] [blame] | 21 | using namespace clang::cxstring; |
| 22 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 23 | //===----------------------------------------------------------------------===// |
| 24 | // USR generation. |
| 25 | //===----------------------------------------------------------------------===// |
| 26 | |
| 27 | namespace { |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 28 | class USRGenerator : public DeclVisitor<USRGenerator> { |
| 29 | llvm::raw_ostream &Out; |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 30 | bool IgnoreResults; |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 31 | ASTUnit *AU; |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 32 | public: |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 33 | USRGenerator(ASTUnit *au, llvm::raw_ostream &out) |
| 34 | : Out(out), IgnoreResults(false), AU(au) {} |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 35 | |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 36 | bool ignoreResults() const { return IgnoreResults; } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 37 | |
| 38 | // Visitation methods from generating USRs from AST elements. |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 39 | void VisitBlockDecl(BlockDecl *D); |
| 40 | void VisitDeclContext(DeclContext *D); |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 41 | void VisitFieldDecl(FieldDecl *D); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 42 | void VisitFunctionDecl(FunctionDecl *D); |
| 43 | void VisitNamedDecl(NamedDecl *D); |
| 44 | void VisitNamespaceDecl(NamespaceDecl *D); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 45 | void VisitObjCContainerDecl(ObjCContainerDecl *CD); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 46 | void VisitObjCMethodDecl(ObjCMethodDecl *MD); |
| 47 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 48 | void VisitTagDecl(TagDecl *D); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 49 | void VisitTypedefDecl(TypedefDecl *D); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 50 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 51 | /// String generation methods used both by the visitation methods |
| 52 | /// and from other clients that want to directly generate USRs. These |
| 53 | /// methods do not construct complete USRs (which incorporate the parents |
| 54 | /// of an AST element), but only the fragments concerning the AST element |
| 55 | /// itself. |
| 56 | |
| 57 | /// Generate a USR fragment for a named declaration. This does |
| 58 | /// not include the USR component for the parent. |
| 59 | void GenNamedDecl(llvm::StringRef name); |
| 60 | |
| 61 | /// Generate a USR for an Objective-C class. |
| 62 | void GenObjCClass(llvm::StringRef cls); |
| 63 | /// Generate a USR for an Objective-C class category. |
| 64 | void GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat); |
| 65 | /// Generate a USR fragment for an Objective-C instance variable. The |
| 66 | /// complete USR can be created by concatenating the USR for the |
| 67 | /// encompassing class with this USR fragment. |
| 68 | void GenObjCIvar(llvm::StringRef ivar); |
| 69 | /// Generate a USR fragment for an Objective-C method. |
| 70 | void GenObjCMethod(llvm::StringRef sel, bool isInstanceMethod); |
| 71 | /// Generate a USR fragment for an Objective-C property. |
| 72 | void GenObjCProperty(llvm::StringRef prop); |
| 73 | /// Generate a USR for an Objective-C protocol. |
| 74 | void GenObjCProtocol(llvm::StringRef prot); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 75 | }; |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 76 | |
| 77 | class StringUSRGenerator { |
| 78 | private: |
| 79 | llvm::SmallString<1024> StrBuf; |
| 80 | llvm::raw_svector_ostream Out; |
| 81 | USRGenerator UG; |
| 82 | public: |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 83 | StringUSRGenerator(const CXCursor *C = 0) |
| 84 | : Out(StrBuf), UG(C ? cxcursor::getCursorASTUnit(*C) : 0, Out) { |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 85 | // Add the USR space prefix. |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 86 | Out << "c:"; |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 87 | } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 88 | |
| 89 | llvm::StringRef str() { |
| 90 | return Out.str(); |
| 91 | } |
| 92 | |
| 93 | USRGenerator* operator->() { return &UG; } |
| 94 | |
| 95 | template <typename T> |
| 96 | llvm::raw_svector_ostream &operator<<(const T &x) { |
| 97 | Out << x; |
| 98 | return Out; |
| 99 | } |
| 100 | }; |
| 101 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 102 | } // end anonymous namespace |
| 103 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 104 | //===----------------------------------------------------------------------===// |
| 105 | // Generating USRs from ASTS. |
| 106 | //===----------------------------------------------------------------------===// |
| 107 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 108 | void USRGenerator::VisitBlockDecl(BlockDecl *D) { |
| 109 | VisitDeclContext(D->getDeclContext()); |
| 110 | // FIXME: Better support for anonymous blocks. |
| 111 | Out << "@B^anon"; |
| 112 | } |
| 113 | |
| 114 | void USRGenerator::VisitDeclContext(DeclContext *DC) { |
| 115 | if (NamedDecl *D = dyn_cast<NamedDecl>(DC)) |
| 116 | Visit(D); |
| 117 | } |
| 118 | |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 119 | void USRGenerator::VisitFieldDecl(FieldDecl *D) { |
| 120 | const std::string &s = D->getNameAsString(); |
| 121 | if (s.empty()) { |
| 122 | // Bit fields can be anonymous. |
| 123 | IgnoreResults = true; |
| 124 | return; |
| 125 | } |
| 126 | VisitDeclContext(D->getDeclContext()); |
| 127 | Out << "@^FI^" << s; |
| 128 | } |
| 129 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 130 | void USRGenerator::VisitFunctionDecl(FunctionDecl *D) { |
| 131 | VisitDeclContext(D->getDeclContext()); |
| 132 | Out << "@F^" << D->getNameAsString(); |
| 133 | } |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 134 | |
| 135 | void USRGenerator::VisitNamedDecl(NamedDecl *D) { |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 136 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 137 | const std::string &s = D->getNameAsString(); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 138 | // assert(!s.empty()); |
| 139 | GenNamedDecl(s); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 140 | } |
| 141 | |
| 142 | void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) { |
| 143 | VisitDeclContext(D->getDeclContext()); |
| 144 | Out << "@N^" << D->getNameAsString(); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 145 | } |
| 146 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 147 | void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) { |
| 148 | Visit(cast<Decl>(D->getDeclContext())); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 149 | GenObjCMethod(DeclarationName(D->getSelector()).getAsString(), |
| 150 | D->isInstanceMethod()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) { |
| 154 | switch (D->getKind()) { |
| 155 | default: |
| 156 | assert(false && "Invalid ObjC container."); |
| 157 | case Decl::ObjCInterface: |
| 158 | case Decl::ObjCImplementation: |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 159 | GenObjCClass(D->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 160 | break; |
| 161 | case Decl::ObjCCategory: { |
| 162 | ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(D); |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 163 | ObjCInterfaceDecl *ID = CD->getClassInterface(); |
| 164 | if (!ID) { |
| 165 | // Handle invalid code where the @interface might not |
| 166 | // have been specified. |
| 167 | // FIXME: We should be able to generate this USR even if the |
| 168 | // @interface isn't available. |
| 169 | IgnoreResults = true; |
| 170 | return; |
| 171 | } |
| 172 | GenObjCCategory(ID->getName(), CD->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 173 | break; |
| 174 | } |
| 175 | case Decl::ObjCCategoryImpl: { |
| 176 | ObjCCategoryImplDecl *CD = cast<ObjCCategoryImplDecl>(D); |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 177 | ObjCInterfaceDecl *ID = CD->getClassInterface(); |
| 178 | if (!ID) { |
| 179 | // Handle invalid code where the @interface might not |
| 180 | // have been specified. |
| 181 | // FIXME: We should be able to generate this USR even if the |
| 182 | // @interface isn't available. |
| 183 | IgnoreResults = true; |
| 184 | return; |
| 185 | } |
| 186 | GenObjCCategory(ID->getName(), CD->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 187 | break; |
| 188 | } |
| 189 | case Decl::ObjCProtocol: |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 190 | GenObjCProtocol(cast<ObjCProtocolDecl>(D)->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 191 | break; |
| 192 | } |
| 193 | } |
| 194 | |
| 195 | void USRGenerator::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
| 196 | Visit(cast<Decl>(D->getDeclContext())); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 197 | GenObjCProperty(D->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 198 | } |
| 199 | |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 200 | void USRGenerator::VisitTagDecl(TagDecl *D) { |
| 201 | VisitDeclContext(D->getDeclContext()); |
| 202 | switch (D->getTagKind()) { |
| 203 | case TagDecl::TK_struct: Out << "@S^"; break; |
| 204 | case TagDecl::TK_class: Out << "@C^"; break; |
| 205 | case TagDecl::TK_union: Out << "@U^"; break; |
| 206 | case TagDecl::TK_enum: Out << "@E^"; break; |
| 207 | } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 208 | |
Ted Kremenek | c5b48b3 | 2010-01-15 23:34:31 +0000 | [diff] [blame] | 209 | // FIXME: Better support for anonymous structures and enums. |
| 210 | const std::string &s = D->getNameAsString(); |
| 211 | if (s.empty()) { |
| 212 | if (TypedefDecl *TD = D->getTypedefForAnonDecl()) |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 213 | Out << "^anontd^" << TD->getNameAsString(); |
Ted Kremenek | c5b48b3 | 2010-01-15 23:34:31 +0000 | [diff] [blame] | 214 | else |
| 215 | Out << "^anon"; |
| 216 | } |
| 217 | else |
| 218 | Out << s; |
| 219 | } |
| 220 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 221 | void USRGenerator::VisitTypedefDecl(TypedefDecl *D) { |
| 222 | DeclContext *DC = D->getDeclContext(); |
| 223 | if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC)) |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 224 | Visit(DCN); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 225 | Out << "typedef@" << D->getName(); |
| 226 | } |
| 227 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 228 | //===----------------------------------------------------------------------===// |
| 229 | // General purpose USR generation methods. |
| 230 | //===----------------------------------------------------------------------===// |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 231 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 232 | void USRGenerator::GenNamedDecl(llvm::StringRef name) { |
| 233 | Out << "@^" << name; |
| 234 | } |
| 235 | |
| 236 | void USRGenerator::GenObjCClass(llvm::StringRef cls) { |
| 237 | Out << "objc(cs)" << cls; |
| 238 | } |
| 239 | |
| 240 | void USRGenerator::GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat) { |
| 241 | Out << "objc(cy)" << cls << '^' << cat; |
| 242 | } |
| 243 | |
| 244 | void USRGenerator::GenObjCIvar(llvm::StringRef ivar) { |
| 245 | GenNamedDecl(ivar); |
| 246 | } |
| 247 | |
| 248 | void USRGenerator::GenObjCMethod(llvm::StringRef meth, bool isInstanceMethod) { |
| 249 | Out << (isInstanceMethod ? "(im)" : "(cm)") << meth; |
| 250 | } |
| 251 | |
| 252 | void USRGenerator::GenObjCProperty(llvm::StringRef prop) { |
| 253 | Out << "(py)" << prop; |
| 254 | } |
| 255 | |
| 256 | void USRGenerator::GenObjCProtocol(llvm::StringRef prot) { |
| 257 | Out << "objc(pl)" << prot; |
| 258 | } |
| 259 | |
| 260 | //===----------------------------------------------------------------------===// |
| 261 | // API hooks. |
| 262 | //===----------------------------------------------------------------------===// |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 263 | |
Benjamin Kramer | cfb51b6 | 2010-04-08 15:54:07 +0000 | [diff] [blame] | 264 | static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) { |
| 265 | return s.startswith("c:") ? s.substr(2) : ""; |
| 266 | } |
| 267 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 268 | static CXString getDeclCursorUSR(const CXCursor &C) { |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 269 | Decl *D = cxcursor::getCursorDecl(C); |
| 270 | if (!D) |
| 271 | return createCXString(NULL); |
| 272 | |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 273 | // Check if the cursor has 'NoLinkage'. |
| 274 | if (const NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D)) |
| 275 | switch (ND->getLinkage()) { |
| 276 | case ExternalLinkage: |
| 277 | // Generate USRs for all entities with external linkage. |
| 278 | break; |
| 279 | case NoLinkage: |
| 280 | // We allow enums, typedefs, and structs that have no linkage to |
| 281 | // have USRs that are anchored to the file they were defined in |
| 282 | // (e.g., the header). This is a little gross, but in principal |
| 283 | // enums/anonymous structs/etc. defined in a common header file |
| 284 | // are referred to across multiple translation units. |
| 285 | if (isa<TagDecl>(ND)) |
| 286 | break; |
| 287 | // Fall-through. |
| 288 | case InternalLinkage: |
| 289 | case UniqueExternalLinkage: |
| 290 | return createCXString(""); |
| 291 | } |
| 292 | |
| 293 | StringUSRGenerator SUG(&C); |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 294 | SUG->Visit(D); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 295 | |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 296 | if (SUG->ignoreResults()) |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 297 | return createCXString(""); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 298 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 299 | // Return a copy of the string that must be disposed by the caller. |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 300 | return createCXString(SUG.str(), true); |
| 301 | } |
| 302 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 303 | extern "C" { |
| 304 | |
| 305 | CXString clang_getCursorUSR(CXCursor C) { |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 306 | const CXCursorKind &K = clang_getCursorKind(C); |
| 307 | |
| 308 | if (clang_isDeclaration(K)) |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 309 | return getDeclCursorUSR(C); |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 310 | |
| 311 | if (K == CXCursor_MacroDefinition) { |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame^] | 312 | StringUSRGenerator SUG(&C); |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 313 | SUG << "macro@" |
| 314 | << cxcursor::getCursorMacroDefinition(C)->getName()->getNameStart(); |
| 315 | return createCXString(SUG.str(), true); |
| 316 | } |
| 317 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 318 | return createCXString(""); |
| 319 | } |
| 320 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 321 | CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) { |
| 322 | StringUSRGenerator SUG; |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 323 | SUG << extractUSRSuffix(clang_getCString(classUSR)); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 324 | SUG->GenObjCIvar(name); |
| 325 | return createCXString(SUG.str(), true); |
| 326 | } |
| 327 | |
| 328 | CXString clang_constructUSR_ObjCMethod(const char *name, |
| 329 | unsigned isInstanceMethod, |
| 330 | CXString classUSR) { |
| 331 | StringUSRGenerator SUG; |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 332 | SUG << extractUSRSuffix(clang_getCString(classUSR)); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 333 | SUG->GenObjCMethod(name, isInstanceMethod); |
| 334 | return createCXString(SUG.str(), true); |
| 335 | } |
| 336 | |
| 337 | CXString clang_constructUSR_ObjCClass(const char *name) { |
| 338 | StringUSRGenerator SUG; |
| 339 | SUG->GenObjCClass(name); |
| 340 | return createCXString(SUG.str(), true); |
| 341 | } |
| 342 | |
| 343 | CXString clang_constructUSR_ObjCProtocol(const char *name) { |
| 344 | StringUSRGenerator SUG; |
| 345 | SUG->GenObjCProtocol(name); |
| 346 | return createCXString(SUG.str(), true); |
| 347 | } |
| 348 | |
Ted Kremenek | 66ccaec | 2010-03-15 17:38:58 +0000 | [diff] [blame] | 349 | CXString clang_constructUSR_ObjCCategory(const char *class_name, |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 350 | const char *category_name) { |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 351 | StringUSRGenerator SUG; |
| 352 | SUG->GenObjCCategory(class_name, category_name); |
| 353 | return createCXString(SUG.str(), true); |
| 354 | } |
| 355 | |
| 356 | CXString clang_constructUSR_ObjCProperty(const char *property, |
| 357 | CXString classUSR) { |
| 358 | StringUSRGenerator SUG; |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 359 | SUG << extractUSRSuffix(clang_getCString(classUSR)); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 360 | SUG->GenObjCProperty(property); |
| 361 | return createCXString(SUG.str(), true); |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 362 | } |
Ted Kremenek | 1b6869a | 2010-01-05 22:06:45 +0000 | [diff] [blame] | 363 | |
Ted Kremenek | 1b6869a | 2010-01-05 22:06:45 +0000 | [diff] [blame] | 364 | } // end extern "C" |