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" |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 17 | #include "clang/Frontend/ASTUnit.h" |
Benjamin Kramer | b846deb | 2010-04-12 19:45:50 +0000 | [diff] [blame] | 18 | #include "clang/Lex/PreprocessingRecord.h" |
Ted Kremenek | 8776382 | 2010-01-12 02:07:58 +0000 | [diff] [blame] | 19 | #include "llvm/ADT/SmallString.h" |
Benjamin Kramer | 9895c6a | 2010-01-12 11:32:40 +0000 | [diff] [blame] | 20 | #include "llvm/Support/raw_ostream.h" |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 21 | |
Benjamin Kramer | b846deb | 2010-04-12 19:45:50 +0000 | [diff] [blame] | 22 | using namespace clang; |
Ted Kremenek | ee4db4f | 2010-02-17 00:41:08 +0000 | [diff] [blame] | 23 | using namespace clang::cxstring; |
| 24 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 25 | //===----------------------------------------------------------------------===// |
| 26 | // USR generation. |
| 27 | //===----------------------------------------------------------------------===// |
| 28 | |
| 29 | namespace { |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 30 | class USRGenerator : public DeclVisitor<USRGenerator> { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 31 | llvm::SmallString<1024> Buf; |
| 32 | llvm::raw_svector_ostream Out; |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 33 | bool IgnoreResults; |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 34 | ASTUnit *AU; |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 35 | bool generatedLoc; |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 36 | public: |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 37 | USRGenerator(const CXCursor *C = 0) |
| 38 | : Out(Buf), |
| 39 | IgnoreResults(false), |
| 40 | AU(C ? cxcursor::getCursorASTUnit(*C) : 0), |
| 41 | generatedLoc(false) |
| 42 | { |
| 43 | // Add the USR space prefix. |
| 44 | Out << "c:"; |
| 45 | } |
| 46 | |
| 47 | llvm::StringRef str() { |
| 48 | return Out.str(); |
| 49 | } |
| 50 | |
| 51 | USRGenerator* operator->() { return this; } |
| 52 | |
| 53 | template <typename T> |
| 54 | llvm::raw_svector_ostream &operator<<(const T &x) { |
| 55 | Out << x; |
| 56 | return Out; |
| 57 | } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 58 | |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 59 | bool ignoreResults() const { return IgnoreResults; } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 60 | |
| 61 | // Visitation methods from generating USRs from AST elements. |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 62 | void VisitDeclContext(DeclContext *D); |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 63 | void VisitFieldDecl(FieldDecl *D); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 64 | void VisitFunctionDecl(FunctionDecl *D); |
| 65 | void VisitNamedDecl(NamedDecl *D); |
| 66 | void VisitNamespaceDecl(NamespaceDecl *D); |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 67 | void VisitObjCClassDecl(ObjCClassDecl *CD); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 68 | void VisitObjCContainerDecl(ObjCContainerDecl *CD); |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 69 | void VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *P); |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 70 | void VisitObjCMethodDecl(ObjCMethodDecl *MD); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 71 | void VisitObjCPropertyDecl(ObjCPropertyDecl *D); |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 72 | void VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D); |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 73 | void VisitTagDecl(TagDecl *D); |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 74 | void VisitTypedefDecl(TypedefDecl *D); |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 75 | void VisitVarDecl(VarDecl *D); |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 76 | void VisitLinkageSpecDecl(LinkageSpecDecl *D) { |
| 77 | IgnoreResults = true; |
| 78 | return; |
| 79 | } |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 80 | |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 81 | /// Generate the string component containing the location of the |
| 82 | /// declaration. |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 83 | bool GenLoc(const Decl *D); |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 84 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 85 | /// String generation methods used both by the visitation methods |
| 86 | /// and from other clients that want to directly generate USRs. These |
| 87 | /// methods do not construct complete USRs (which incorporate the parents |
| 88 | /// of an AST element), but only the fragments concerning the AST element |
| 89 | /// itself. |
| 90 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 91 | /// Generate a USR for an Objective-C class. |
| 92 | void GenObjCClass(llvm::StringRef cls); |
| 93 | /// Generate a USR for an Objective-C class category. |
| 94 | void GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat); |
| 95 | /// Generate a USR fragment for an Objective-C instance variable. The |
| 96 | /// complete USR can be created by concatenating the USR for the |
| 97 | /// encompassing class with this USR fragment. |
| 98 | void GenObjCIvar(llvm::StringRef ivar); |
| 99 | /// Generate a USR fragment for an Objective-C method. |
| 100 | void GenObjCMethod(llvm::StringRef sel, bool isInstanceMethod); |
| 101 | /// Generate a USR fragment for an Objective-C property. |
| 102 | void GenObjCProperty(llvm::StringRef prop); |
| 103 | /// Generate a USR for an Objective-C protocol. |
| 104 | void GenObjCProtocol(llvm::StringRef prot); |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 105 | |
| 106 | void VisitType(QualType T); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 107 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 108 | /// Emit a Decl's name using NamedDecl::printName() and return true if |
| 109 | /// the decl had no name. |
| 110 | bool EmitDeclName(const NamedDecl *D); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 111 | }; |
| 112 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 113 | } // end anonymous namespace |
| 114 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 115 | //===----------------------------------------------------------------------===// |
| 116 | // Generating USRs from ASTS. |
| 117 | //===----------------------------------------------------------------------===// |
| 118 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 119 | bool USRGenerator::EmitDeclName(const NamedDecl *D) { |
| 120 | Out.flush(); |
| 121 | const unsigned startSize = Buf.size(); |
| 122 | D->printName(Out); |
| 123 | Out.flush(); |
| 124 | const unsigned endSize = Buf.size(); |
| 125 | return startSize == endSize; |
| 126 | } |
| 127 | |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 128 | static bool InAnonymousNamespace(const Decl *D) { |
| 129 | if (const NamespaceDecl *ND = dyn_cast<NamespaceDecl>(D->getDeclContext())) |
| 130 | return ND->isAnonymousNamespace(); |
| 131 | return false; |
| 132 | } |
| 133 | |
| 134 | static inline bool ShouldGenerateLocation(const NamedDecl *D) { |
| 135 | return D->getLinkage() != ExternalLinkage && !InAnonymousNamespace(D); |
| 136 | } |
| 137 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 138 | void USRGenerator::VisitDeclContext(DeclContext *DC) { |
| 139 | if (NamedDecl *D = dyn_cast<NamedDecl>(DC)) |
| 140 | Visit(D); |
| 141 | } |
| 142 | |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 143 | void USRGenerator::VisitFieldDecl(FieldDecl *D) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 144 | VisitDeclContext(D->getDeclContext()); |
| 145 | Out << (isa<ObjCIvarDecl>(D) ? "@" : "@FI@"); |
| 146 | if (EmitDeclName(D)) { |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 147 | // Bit fields can be anonymous. |
| 148 | IgnoreResults = true; |
| 149 | return; |
| 150 | } |
Ted Kremenek | 3adca6d | 2010-01-18 22:02:49 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 153 | void USRGenerator::VisitFunctionDecl(FunctionDecl *D) { |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 154 | if (ShouldGenerateLocation(D) && GenLoc(D)) |
| 155 | return; |
Ted Kremenek | cf99910 | 2010-04-29 17:43:29 +0000 | [diff] [blame] | 156 | |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 157 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 158 | Out << "@F@"; |
| 159 | D->printName(Out); |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 160 | |
| 161 | ASTContext &Ctx = AU->getASTContext(); |
| 162 | if (!Ctx.getLangOptions().CPlusPlus || D->isExternC()) |
| 163 | return; |
| 164 | |
| 165 | // Mangle in type information for the arguments. |
| 166 | for (FunctionDecl::param_iterator I = D->param_begin(), E = D->param_end(); |
| 167 | I != E; ++I) { |
| 168 | Out << '#'; |
| 169 | if (ParmVarDecl *PD = *I) |
| 170 | VisitType(PD->getType()); |
| 171 | } |
| 172 | if (D->isVariadic()) |
| 173 | Out << '.'; |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 174 | Out << '#'; |
| 175 | if (CXXMethodDecl *MD = dyn_cast<CXXMethodDecl>(D)) { |
| 176 | if (MD->isStatic()) |
| 177 | Out << 'S'; |
| 178 | if (unsigned quals = MD->getTypeQualifiers()) |
| 179 | Out << (char)('0' + quals); |
| 180 | } |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 181 | } |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 182 | |
| 183 | void USRGenerator::VisitNamedDecl(NamedDecl *D) { |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 184 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 185 | Out << "@"; |
| 186 | |
| 187 | if (EmitDeclName(D)) { |
| 188 | // The string can be empty if the declaration has no name; e.g., it is |
| 189 | // the ParmDecl with no name for declaration of a function pointer type, |
| 190 | // e.g.: void (*f)(void *); |
| 191 | // In this case, don't generate a USR. |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 192 | IgnoreResults = true; |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 193 | } |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 194 | } |
| 195 | |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 196 | void USRGenerator::VisitVarDecl(VarDecl *D) { |
| 197 | // VarDecls can be declared 'extern' within a function or method body, |
| 198 | // but their enclosing DeclContext is the function, not the TU. We need |
| 199 | // to check the storage class to correctly generate the USR. |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 200 | if (ShouldGenerateLocation(D) && GenLoc(D)) |
| 201 | return; |
| 202 | |
| 203 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 204 | |
Ted Kremenek | cf99910 | 2010-04-29 17:43:29 +0000 | [diff] [blame] | 205 | // Variables always have simple names. |
| 206 | llvm::StringRef s = D->getName(); |
| 207 | |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 208 | // The string can be empty if the declaration has no name; e.g., it is |
| 209 | // the ParmDecl with no name for declaration of a function pointer type, e.g.: |
| 210 | // void (*f)(void *); |
| 211 | // In this case, don't generate a USR. |
| 212 | if (s.empty()) |
| 213 | IgnoreResults = true; |
| 214 | else |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 215 | Out << '@' << s; |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 216 | } |
| 217 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 218 | void USRGenerator::VisitNamespaceDecl(NamespaceDecl *D) { |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 219 | if (D->isAnonymousNamespace()) { |
| 220 | Out << "@aN"; |
| 221 | return; |
| 222 | } |
| 223 | |
Ted Kremenek | 2fee4e6 | 2010-01-14 01:50:21 +0000 | [diff] [blame] | 224 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 225 | if (!IgnoreResults) |
| 226 | Out << "@N@" << D->getName(); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 227 | } |
| 228 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 229 | void USRGenerator::VisitObjCMethodDecl(ObjCMethodDecl *D) { |
| 230 | Visit(cast<Decl>(D->getDeclContext())); |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 231 | // Ideally we would use 'GenObjCMethod', but this is such a hot path |
| 232 | // for Objective-C code that we don't want to use |
| 233 | // DeclarationName::getAsString(). |
| 234 | Out << (D->isInstanceMethod() ? "(im)" : "(cm)"); |
| 235 | DeclarationName N(D->getSelector()); |
| 236 | N.printName(Out); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 237 | } |
| 238 | |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 239 | void USRGenerator::VisitObjCClassDecl(ObjCClassDecl *D) { |
| 240 | // FIXME: @class declarations can refer to multiple classes. We need |
| 241 | // to be able to traverse these. |
| 242 | IgnoreResults = true; |
| 243 | } |
| 244 | |
| 245 | void USRGenerator::VisitObjCForwardProtocolDecl(ObjCForwardProtocolDecl *D) { |
| 246 | // FIXME: @protocol declarations can refer to multiple protocols. We need |
| 247 | // to be able to traverse these. |
| 248 | IgnoreResults = true; |
| 249 | } |
| 250 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 251 | void USRGenerator::VisitObjCContainerDecl(ObjCContainerDecl *D) { |
| 252 | switch (D->getKind()) { |
| 253 | default: |
| 254 | assert(false && "Invalid ObjC container."); |
| 255 | case Decl::ObjCInterface: |
| 256 | case Decl::ObjCImplementation: |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 257 | GenObjCClass(D->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 258 | break; |
| 259 | case Decl::ObjCCategory: { |
| 260 | ObjCCategoryDecl *CD = cast<ObjCCategoryDecl>(D); |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 261 | ObjCInterfaceDecl *ID = CD->getClassInterface(); |
| 262 | if (!ID) { |
| 263 | // Handle invalid code where the @interface might not |
| 264 | // have been specified. |
| 265 | // FIXME: We should be able to generate this USR even if the |
| 266 | // @interface isn't available. |
| 267 | IgnoreResults = true; |
| 268 | return; |
| 269 | } |
| 270 | GenObjCCategory(ID->getName(), CD->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 271 | break; |
| 272 | } |
| 273 | case Decl::ObjCCategoryImpl: { |
| 274 | ObjCCategoryImplDecl *CD = cast<ObjCCategoryImplDecl>(D); |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 275 | ObjCInterfaceDecl *ID = CD->getClassInterface(); |
| 276 | if (!ID) { |
| 277 | // Handle invalid code where the @interface might not |
| 278 | // have been specified. |
| 279 | // FIXME: We should be able to generate this USR even if the |
| 280 | // @interface isn't available. |
| 281 | IgnoreResults = true; |
| 282 | return; |
| 283 | } |
| 284 | GenObjCCategory(ID->getName(), CD->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 285 | break; |
| 286 | } |
| 287 | case Decl::ObjCProtocol: |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 288 | GenObjCProtocol(cast<ObjCProtocolDecl>(D)->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 289 | break; |
| 290 | } |
| 291 | } |
| 292 | |
| 293 | void USRGenerator::VisitObjCPropertyDecl(ObjCPropertyDecl *D) { |
| 294 | Visit(cast<Decl>(D->getDeclContext())); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 295 | GenObjCProperty(D->getName()); |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 296 | } |
| 297 | |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 298 | void USRGenerator::VisitObjCPropertyImplDecl(ObjCPropertyImplDecl *D) { |
| 299 | if (ObjCPropertyDecl *PD = D->getPropertyDecl()) { |
| 300 | VisitObjCPropertyDecl(PD); |
| 301 | return; |
| 302 | } |
| 303 | |
| 304 | IgnoreResults = true; |
| 305 | } |
| 306 | |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 307 | void USRGenerator::VisitTagDecl(TagDecl *D) { |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 308 | // Add the location of the tag decl to handle resolution across |
| 309 | // translation units. |
| 310 | if (ShouldGenerateLocation(D) && GenLoc(D)) |
| 311 | return; |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 312 | |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 313 | D = D->getCanonicalDecl(); |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 314 | VisitDeclContext(D->getDeclContext()); |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 315 | |
Ted Kremenek | b82b3be | 2010-01-18 22:42:20 +0000 | [diff] [blame] | 316 | switch (D->getTagKind()) { |
Abramo Bagnara | 465d41b | 2010-05-11 21:36:43 +0000 | [diff] [blame] | 317 | case TTK_Struct: Out << "@S"; break; |
| 318 | case TTK_Class: Out << "@C"; break; |
| 319 | case TTK_Union: Out << "@U"; break; |
| 320 | case TTK_Enum: Out << "@E"; break; |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 321 | } |
| 322 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 323 | Out << '@'; |
| 324 | Out.flush(); |
| 325 | assert(Buf.size() > 0); |
| 326 | const unsigned off = Buf.size() - 1; |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 327 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 328 | if (EmitDeclName(D)) { |
| 329 | if (const TypedefDecl *TD = D->getTypedefForAnonDecl()) { |
| 330 | Buf[off] = 'A'; |
Benjamin Kramer | 900fc63 | 2010-04-17 09:33:03 +0000 | [diff] [blame] | 331 | Out << '@' << TD; |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 332 | } |
| 333 | else |
| 334 | Buf[off] = 'a'; |
Ted Kremenek | c5b48b3 | 2010-01-15 23:34:31 +0000 | [diff] [blame] | 335 | } |
Ted Kremenek | c5b48b3 | 2010-01-15 23:34:31 +0000 | [diff] [blame] | 336 | } |
| 337 | |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 338 | void USRGenerator::VisitTypedefDecl(TypedefDecl *D) { |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 339 | if (ShouldGenerateLocation(D) && GenLoc(D)) |
| 340 | return; |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 341 | DeclContext *DC = D->getDeclContext(); |
| 342 | if (NamedDecl *DCN = dyn_cast<NamedDecl>(DC)) |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 343 | Visit(DCN); |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 344 | Out << "@T@"; |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 345 | Out << D->getName(); |
| 346 | } |
| 347 | |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 348 | bool USRGenerator::GenLoc(const Decl *D) { |
| 349 | if (generatedLoc) |
| 350 | return IgnoreResults; |
| 351 | generatedLoc = true; |
| 352 | |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 353 | const SourceManager &SM = AU->getSourceManager(); |
| 354 | SourceLocation L = D->getLocStart(); |
| 355 | if (L.isInvalid()) { |
| 356 | IgnoreResults = true; |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 357 | return true; |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 358 | } |
| 359 | L = SM.getInstantiationLoc(L); |
| 360 | const std::pair<FileID, unsigned> &Decomposed = SM.getDecomposedLoc(L); |
| 361 | const FileEntry *FE = SM.getFileEntryForID(Decomposed.first); |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 362 | if (FE) { |
| 363 | llvm::sys::Path P(FE->getName()); |
| 364 | Out << P.getLast(); |
| 365 | } |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 366 | else { |
| 367 | // This case really isn't interesting. |
| 368 | IgnoreResults = true; |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 369 | return true; |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 370 | } |
Ted Kremenek | f48b531 | 2010-07-22 11:14:15 +0000 | [diff] [blame^] | 371 | // Use the offest into the FileID to represent the location. Using |
| 372 | // a line/column can cause us to look back at the original source file, |
| 373 | // which is expensive. |
| 374 | Out << '@' << Decomposed.second; |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 375 | return IgnoreResults; |
Ted Kremenek | c50277f | 2010-01-12 23:33:42 +0000 | [diff] [blame] | 376 | } |
| 377 | |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 378 | void USRGenerator::VisitType(QualType T) { |
| 379 | // This method mangles in USR information for types. It can possibly |
| 380 | // just reuse the naming-mangling logic used by codegen, although the |
| 381 | // requirements for USRs might not be the same. |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 382 | ASTContext &Ctx = AU->getASTContext(); |
| 383 | |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 384 | do { |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 385 | T = Ctx.getCanonicalType(T); |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 386 | Qualifiers Q = T.getQualifiers(); |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 387 | unsigned qVal = 0; |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 388 | if (Q.hasConst()) |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 389 | qVal |= 0x1; |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 390 | if (Q.hasVolatile()) |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 391 | qVal |= 0x2; |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 392 | if (Q.hasRestrict()) |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 393 | qVal |= 0x4; |
| 394 | if(qVal) |
| 395 | Out << ((char) ('0' + qVal)); |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 396 | |
| 397 | // Mangle in ObjC GC qualifiers? |
| 398 | |
| 399 | if (const PointerType *PT = T->getAs<PointerType>()) { |
| 400 | Out << '*'; |
| 401 | T = PT->getPointeeType(); |
| 402 | continue; |
| 403 | } |
| 404 | if (const ReferenceType *RT = T->getAs<ReferenceType>()) { |
| 405 | Out << '&'; |
| 406 | T = RT->getPointeeType(); |
| 407 | continue; |
| 408 | } |
| 409 | if (const FunctionProtoType *FT = T->getAs<FunctionProtoType>()) { |
| 410 | Out << 'F'; |
| 411 | VisitType(FT->getResultType()); |
| 412 | for (FunctionProtoType::arg_type_iterator |
| 413 | I = FT->arg_type_begin(), E = FT->arg_type_end(); I!=E; ++I) { |
| 414 | VisitType(*I); |
| 415 | } |
| 416 | if (FT->isVariadic()) |
| 417 | Out << '.'; |
| 418 | return; |
| 419 | } |
| 420 | if (const BlockPointerType *BT = T->getAs<BlockPointerType>()) { |
| 421 | Out << 'B'; |
| 422 | T = BT->getPointeeType(); |
| 423 | continue; |
| 424 | } |
| 425 | if (const BuiltinType *BT = T->getAs<BuiltinType>()) { |
| 426 | unsigned char c = '\0'; |
| 427 | switch (BT->getKind()) { |
| 428 | case BuiltinType::Void: |
| 429 | c = 'v'; break; |
| 430 | case BuiltinType::Bool: |
| 431 | c = 'b'; break; |
| 432 | case BuiltinType::Char_U: |
| 433 | case BuiltinType::UChar: |
| 434 | c = 'c'; break; |
| 435 | case BuiltinType::Char16: |
| 436 | c = 'q'; break; |
| 437 | case BuiltinType::Char32: |
| 438 | c = 'w'; break; |
| 439 | case BuiltinType::UShort: |
| 440 | c = 's'; break; |
| 441 | case BuiltinType::UInt: |
| 442 | c = 'i'; break; |
| 443 | case BuiltinType::ULong: |
| 444 | c = 'l'; break; |
| 445 | case BuiltinType::ULongLong: |
| 446 | c = 'k'; break; |
| 447 | case BuiltinType::UInt128: |
| 448 | c = 'j'; break; |
| 449 | case BuiltinType::Char_S: |
| 450 | case BuiltinType::SChar: |
| 451 | c = 'C'; break; |
| 452 | case BuiltinType::WChar: |
| 453 | c = 'W'; break; |
| 454 | case BuiltinType::Short: |
| 455 | c = 'S'; break; |
| 456 | case BuiltinType::Int: |
| 457 | c = 'I'; break; |
| 458 | case BuiltinType::Long: |
| 459 | c = 'L'; break; |
| 460 | case BuiltinType::LongLong: |
| 461 | c = 'K'; break; |
| 462 | case BuiltinType::Int128: |
| 463 | c = 'J'; break; |
| 464 | case BuiltinType::Float: |
| 465 | c = 'f'; break; |
| 466 | case BuiltinType::Double: |
| 467 | c = 'd'; break; |
| 468 | case BuiltinType::LongDouble: |
| 469 | c = 'D'; break; |
| 470 | case BuiltinType::NullPtr: |
| 471 | c = 'n'; break; |
| 472 | case BuiltinType::Overload: |
| 473 | case BuiltinType::Dependent: |
| 474 | case BuiltinType::UndeducedAuto: |
| 475 | IgnoreResults = true; |
| 476 | return; |
| 477 | case BuiltinType::ObjCId: |
| 478 | c = 'o'; break; |
| 479 | case BuiltinType::ObjCClass: |
| 480 | c = 'O'; break; |
| 481 | case BuiltinType::ObjCSel: |
| 482 | c = 'e'; break; |
| 483 | } |
| 484 | Out << c; |
| 485 | return; |
| 486 | } |
| 487 | if (const ComplexType *CT = T->getAs<ComplexType>()) { |
| 488 | Out << '<'; |
| 489 | T = CT->getElementType(); |
| 490 | continue; |
| 491 | } |
Ted Kremenek | 2ea5baf | 2010-05-07 20:39:40 +0000 | [diff] [blame] | 492 | if (const TagType *TT = T->getAs<TagType>()) { |
| 493 | Out << '$'; |
| 494 | VisitTagDecl(TT->getDecl()); |
| 495 | return; |
| 496 | } |
Ted Kremenek | 8e67219 | 2010-05-07 01:04:32 +0000 | [diff] [blame] | 497 | |
| 498 | // Unhandled type. |
| 499 | Out << ' '; |
| 500 | break; |
| 501 | } while (true); |
| 502 | } |
| 503 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 504 | //===----------------------------------------------------------------------===// |
| 505 | // General purpose USR generation methods. |
| 506 | //===----------------------------------------------------------------------===// |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 507 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 508 | void USRGenerator::GenObjCClass(llvm::StringRef cls) { |
| 509 | Out << "objc(cs)" << cls; |
| 510 | } |
| 511 | |
| 512 | void USRGenerator::GenObjCCategory(llvm::StringRef cls, llvm::StringRef cat) { |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 513 | Out << "objc(cy)" << cls << '@' << cat; |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 514 | } |
| 515 | |
| 516 | void USRGenerator::GenObjCIvar(llvm::StringRef ivar) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 517 | Out << '@' << ivar; |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 518 | } |
| 519 | |
| 520 | void USRGenerator::GenObjCMethod(llvm::StringRef meth, bool isInstanceMethod) { |
| 521 | Out << (isInstanceMethod ? "(im)" : "(cm)") << meth; |
| 522 | } |
| 523 | |
| 524 | void USRGenerator::GenObjCProperty(llvm::StringRef prop) { |
| 525 | Out << "(py)" << prop; |
| 526 | } |
| 527 | |
| 528 | void USRGenerator::GenObjCProtocol(llvm::StringRef prot) { |
| 529 | Out << "objc(pl)" << prot; |
| 530 | } |
| 531 | |
| 532 | //===----------------------------------------------------------------------===// |
| 533 | // API hooks. |
| 534 | //===----------------------------------------------------------------------===// |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 535 | |
Benjamin Kramer | cfb51b6 | 2010-04-08 15:54:07 +0000 | [diff] [blame] | 536 | static inline llvm::StringRef extractUSRSuffix(llvm::StringRef s) { |
| 537 | return s.startswith("c:") ? s.substr(2) : ""; |
| 538 | } |
| 539 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 540 | static CXString getDeclCursorUSR(const CXCursor &C) { |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 541 | Decl *D = cxcursor::getCursorDecl(C); |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 542 | |
| 543 | // Don't generate USRs for things with invalid locations. |
| 544 | if (!D || D->getLocStart().isInvalid()) |
Ted Kremenek | 1af0a2a | 2010-04-17 00:21:38 +0000 | [diff] [blame] | 545 | return createCXString(""); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 546 | |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 547 | // Check if the cursor has 'NoLinkage'. |
Ted Kremenek | e74ef12 | 2010-04-16 21:31:52 +0000 | [diff] [blame] | 548 | if (const NamedDecl *ND = dyn_cast<NamedDecl>(D)) |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 549 | switch (ND->getLinkage()) { |
| 550 | case ExternalLinkage: |
| 551 | // Generate USRs for all entities with external linkage. |
| 552 | break; |
| 553 | case NoLinkage: |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 554 | case UniqueExternalLinkage: |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 555 | // We allow enums, typedefs, and structs that have no linkage to |
| 556 | // have USRs that are anchored to the file they were defined in |
| 557 | // (e.g., the header). This is a little gross, but in principal |
| 558 | // enums/anonymous structs/etc. defined in a common header file |
| 559 | // are referred to across multiple translation units. |
Ted Kremenek | 6f15395 | 2010-04-15 21:51:13 +0000 | [diff] [blame] | 560 | if (isa<TagDecl>(ND) || isa<TypedefDecl>(ND) || |
Ted Kremenek | cf99910 | 2010-04-29 17:43:29 +0000 | [diff] [blame] | 561 | isa<EnumConstantDecl>(ND) || isa<FieldDecl>(ND) || |
Ted Kremenek | cbd66f0 | 2010-05-06 23:38:28 +0000 | [diff] [blame] | 562 | isa<VarDecl>(ND) || isa<NamespaceDecl>(ND)) |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 563 | break; |
| 564 | // Fall-through. |
| 565 | case InternalLinkage: |
Ted Kremenek | cf99910 | 2010-04-29 17:43:29 +0000 | [diff] [blame] | 566 | if (isa<FunctionDecl>(ND)) |
| 567 | break; |
Ted Kremenek | 1865cfe | 2010-04-15 21:04:25 +0000 | [diff] [blame] | 568 | } |
| 569 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 570 | USRGenerator UG(&C); |
| 571 | UG->Visit(D); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 572 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 573 | if (UG->ignoreResults()) |
Ted Kremenek | ebfa339 | 2010-03-19 20:39:03 +0000 | [diff] [blame] | 574 | return createCXString(""); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 575 | |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 576 | #if 0 |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 577 | // For development testing. |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 578 | assert(UG.str().size() > 2); |
| 579 | #endif |
Ted Kremenek | e542f77 | 2010-04-20 23:15:40 +0000 | [diff] [blame] | 580 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 581 | // Return a copy of the string that must be disposed by the caller. |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 582 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 583 | } |
| 584 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 585 | extern "C" { |
| 586 | |
| 587 | CXString clang_getCursorUSR(CXCursor C) { |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 588 | const CXCursorKind &K = clang_getCursorKind(C); |
| 589 | |
| 590 | if (clang_isDeclaration(K)) |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 591 | return getDeclCursorUSR(C); |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 592 | |
| 593 | if (K == CXCursor_MacroDefinition) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 594 | USRGenerator UG(&C); |
| 595 | UG << "macro@" |
| 596 | << cxcursor::getCursorMacroDefinition(C)->getName()->getNameStart(); |
| 597 | return createCXString(UG.str(), true); |
Ted Kremenek | fa8231d | 2010-04-11 22:20:34 +0000 | [diff] [blame] | 598 | } |
| 599 | |
Ted Kremenek | c3ef91d | 2010-04-11 22:20:26 +0000 | [diff] [blame] | 600 | return createCXString(""); |
| 601 | } |
| 602 | |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 603 | CXString clang_constructUSR_ObjCIvar(const char *name, CXString classUSR) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 604 | USRGenerator UG; |
| 605 | UG << extractUSRSuffix(clang_getCString(classUSR)); |
| 606 | UG->GenObjCIvar(name); |
| 607 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 608 | } |
| 609 | |
| 610 | CXString clang_constructUSR_ObjCMethod(const char *name, |
| 611 | unsigned isInstanceMethod, |
| 612 | CXString classUSR) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 613 | USRGenerator UG; |
| 614 | UG << extractUSRSuffix(clang_getCString(classUSR)); |
| 615 | UG->GenObjCMethod(name, isInstanceMethod); |
| 616 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 617 | } |
| 618 | |
| 619 | CXString clang_constructUSR_ObjCClass(const char *name) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 620 | USRGenerator UG; |
| 621 | UG->GenObjCClass(name); |
| 622 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 623 | } |
| 624 | |
| 625 | CXString clang_constructUSR_ObjCProtocol(const char *name) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 626 | USRGenerator UG; |
| 627 | UG->GenObjCProtocol(name); |
| 628 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 629 | } |
| 630 | |
Ted Kremenek | 66ccaec | 2010-03-15 17:38:58 +0000 | [diff] [blame] | 631 | CXString clang_constructUSR_ObjCCategory(const char *class_name, |
Ted Kremenek | 0c0fb41 | 2010-03-25 02:00:36 +0000 | [diff] [blame] | 632 | const char *category_name) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 633 | USRGenerator UG; |
| 634 | UG->GenObjCCategory(class_name, category_name); |
| 635 | return createCXString(UG.str(), true); |
Ted Kremenek | 896b70f | 2010-03-13 02:50:34 +0000 | [diff] [blame] | 636 | } |
| 637 | |
| 638 | CXString clang_constructUSR_ObjCProperty(const char *property, |
| 639 | CXString classUSR) { |
Ted Kremenek | 3ebd8dc | 2010-05-07 20:07:23 +0000 | [diff] [blame] | 640 | USRGenerator UG; |
| 641 | UG << extractUSRSuffix(clang_getCString(classUSR)); |
| 642 | UG->GenObjCProperty(property); |
| 643 | return createCXString(UG.str(), true); |
Ted Kremenek | cf84aa4 | 2010-01-18 20:23:29 +0000 | [diff] [blame] | 644 | } |
Ted Kremenek | 1b6869a | 2010-01-05 22:06:45 +0000 | [diff] [blame] | 645 | |
Ted Kremenek | 1b6869a | 2010-01-05 22:06:45 +0000 | [diff] [blame] | 646 | } // end extern "C" |