blob: a0b49c41691ba639a15318d639c31276ccd31fa4 [file] [log] [blame]
Ted Kremenek1ca68fb2009-08-26 22:36:44 +00001//===- CIndex.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 Clang-C Source Indexing library.
11//
12//===----------------------------------------------------------------------===//
13
14#include "clang-c/Index.h"
Steve Naroff3ba83e92009-08-28 15:28:48 +000015#include "clang/Index/Program.h"
16#include "clang/Index/Indexer.h"
Steve Naroff3ba83e92009-08-28 15:28:48 +000017#include "clang/AST/DeclVisitor.h"
Steve Naroff51366e92009-09-02 13:28:54 +000018#include "clang/AST/Decl.h"
Benjamin Kramer2fa4a242009-08-29 12:56:35 +000019#include "clang/Basic/FileManager.h"
Steve Naroff52833ba2009-08-31 14:26:51 +000020#include "clang/Basic/SourceManager.h"
Benjamin Kramer2fa4a242009-08-29 12:56:35 +000021#include "clang/Frontend/ASTUnit.h"
22#include <cstdio>
Steve Naroff3ba83e92009-08-28 15:28:48 +000023using namespace clang;
24using namespace idx;
25
Steve Naroffc674c2d2009-08-31 00:59:03 +000026namespace {
27
28// Translation Unit Visitor.
29class TUVisitor : public DeclVisitor<TUVisitor> {
30 CXTranslationUnit TUnit;
31 CXTranslationUnitIterator Callback;
Steve Naroffb836cb72009-09-01 15:55:40 +000032 CXClientData CData;
33
34 void Call(enum CXCursorKind CK, NamedDecl *ND) {
35 CXCursor C = { CK, ND };
36 Callback(TUnit, C, CData);
37 }
Steve Naroffc674c2d2009-08-31 00:59:03 +000038public:
Steve Naroffb836cb72009-09-01 15:55:40 +000039 TUVisitor(CXTranslationUnit CTU,
40 CXTranslationUnitIterator cback, CXClientData D) :
41 TUnit(CTU), Callback(cback), CData(D) {}
Steve Naroffc674c2d2009-08-31 00:59:03 +000042
43 void VisitTranslationUnitDecl(TranslationUnitDecl *D) {
44 VisitDeclContext(dyn_cast<DeclContext>(D));
45 }
46 void VisitDeclContext(DeclContext *DC) {
47 for (DeclContext::decl_iterator
48 I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I)
49 Visit(*I);
50 }
Steve Naroffb836cb72009-09-01 15:55:40 +000051 void VisitTypedefDecl(TypedefDecl *ND) {
52 Call(CXCursor_TypedefDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +000053 }
54 void VisitTagDecl(TagDecl *ND) {
Steve Naroff51366e92009-09-02 13:28:54 +000055 switch (ND->getTagKind()) {
56 case TagDecl::TK_struct:
57 Call(CXCursor_StructDecl, ND);
58 break;
59 case TagDecl::TK_class:
60 Call(CXCursor_ClassDecl, ND);
61 break;
62 case TagDecl::TK_union:
63 Call(CXCursor_UnionDecl, ND);
64 break;
65 case TagDecl::TK_enum:
66 Call(CXCursor_EnumDecl, ND);
67 break;
68 }
Steve Naroffc674c2d2009-08-31 00:59:03 +000069 }
Steve Naroff6b0576b2009-09-03 00:32:06 +000070 void VisitVarDecl(VarDecl *ND) {
71 Call(CXCursor_VarDecl, ND);
72 }
Steve Naroffc674c2d2009-08-31 00:59:03 +000073 void VisitFunctionDecl(FunctionDecl *ND) {
Steve Naroff51366e92009-09-02 13:28:54 +000074 Call(ND->isThisDeclarationADefinition() ? CXCursor_FunctionDefn
75 : CXCursor_FunctionDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +000076 }
77 void VisitObjCInterfaceDecl(ObjCInterfaceDecl *ND) {
Steve Naroffb836cb72009-09-01 15:55:40 +000078 Call(CXCursor_ObjCInterfaceDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +000079 }
80 void VisitObjCCategoryDecl(ObjCCategoryDecl *ND) {
Steve Naroffb836cb72009-09-01 15:55:40 +000081 Call(CXCursor_ObjCCategoryDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +000082 }
83 void VisitObjCProtocolDecl(ObjCProtocolDecl *ND) {
Steve Naroffb836cb72009-09-01 15:55:40 +000084 Call(CXCursor_ObjCProtocolDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +000085 }
Steve Naroff51366e92009-09-02 13:28:54 +000086 void VisitObjCImplementationDecl(ObjCImplementationDecl *ND) {
87 Call(CXCursor_ObjCClassDefn, ND);
88 }
89 void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *ND) {
90 Call(CXCursor_ObjCCategoryDefn, ND);
91 }
Steve Naroffc674c2d2009-08-31 00:59:03 +000092};
93
Steve Naroff51366e92009-09-02 13:28:54 +000094// Declaration visitor.
95class CDeclVisitor : public DeclVisitor<CDeclVisitor> {
96 CXDecl CDecl;
97 CXDeclIterator Callback;
98 CXClientData CData;
99
100 void Call(enum CXCursorKind CK, NamedDecl *ND) {
Steve Naroff6b0576b2009-09-03 00:32:06 +0000101 // Disable the callback when the context is equal to the visiting decl.
102 if (CDecl == ND)
103 return;
Steve Naroff51366e92009-09-02 13:28:54 +0000104 CXCursor C = { CK, ND };
105 Callback(CDecl, C, CData);
106 }
Steve Naroffc674c2d2009-08-31 00:59:03 +0000107public:
Steve Naroff51366e92009-09-02 13:28:54 +0000108 CDeclVisitor(CXDecl C, CXDeclIterator cback, CXClientData D) :
109 CDecl(C), Callback(cback), CData(D) {}
110
111 void VisitObjCInterfaceDecl(ObjCInterfaceDecl *D) {
Steve Naroffa82c7d02009-09-02 18:26:48 +0000112 // Issue callbacks for super class and protocols.
113 if (D->getSuperClass())
114 Call(CXCursor_ObjCSuperClassRef, D);
115
Steve Naroff51366e92009-09-02 13:28:54 +0000116 VisitDeclContext(dyn_cast<DeclContext>(D));
117 }
118 void VisitTagDecl(TagDecl *D) {
119 VisitDeclContext(dyn_cast<DeclContext>(D));
120 }
121 void VisitObjCImplementationDecl(ObjCImplementationDecl *D) {
122 VisitDeclContext(dyn_cast<DeclContext>(D));
123 }
124 void VisitObjCCategoryImplDecl(ObjCCategoryImplDecl *D) {
125 VisitDeclContext(dyn_cast<DeclContext>(D));
126 }
Steve Naroffc674c2d2009-08-31 00:59:03 +0000127 void VisitDeclContext(DeclContext *DC) {
128 for (DeclContext::decl_iterator
129 I = DC->decls_begin(), E = DC->decls_end(); I != E; ++I)
130 Visit(*I);
131 }
132 void VisitEnumConstantDecl(EnumConstantDecl *ND) {
Steve Naroff51366e92009-09-02 13:28:54 +0000133 Call(CXCursor_EnumConstantDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +0000134 }
135 void VisitFieldDecl(FieldDecl *ND) {
Steve Naroff51366e92009-09-02 13:28:54 +0000136 Call(CXCursor_FieldDecl, ND);
137 }
Steve Naroff6b0576b2009-09-03 00:32:06 +0000138 void VisitVarDecl(VarDecl *ND) {
139 Call(CXCursor_VarDecl, ND);
140 }
141 void VisitParmVarDecl(ParmVarDecl *ND) {
142 Call(CXCursor_ParmDecl, ND);
143 }
Steve Naroff51366e92009-09-02 13:28:54 +0000144 void VisitObjCPropertyDecl(ObjCPropertyDecl *ND) {
145 Call(CXCursor_ObjCPropertyDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +0000146 }
147 void VisitObjCIvarDecl(ObjCIvarDecl *ND) {
Steve Naroff51366e92009-09-02 13:28:54 +0000148 Call(CXCursor_ObjCIvarDecl, ND);
149 }
Steve Naroff6b0576b2009-09-03 00:32:06 +0000150 void VisitFunctionDecl(FunctionDecl *ND) {
151 if (ND->isThisDeclarationADefinition()) {
152 VisitDeclContext(dyn_cast<DeclContext>(ND));
153 }
154 }
Steve Naroff51366e92009-09-02 13:28:54 +0000155 void VisitObjCMethodDecl(ObjCMethodDecl *ND) {
156 if (ND->getBody()) {
157 Call(ND->isInstanceMethod() ? CXCursor_ObjCInstanceMethodDefn
158 : CXCursor_ObjCClassMethodDefn, ND);
Steve Naroff6b0576b2009-09-03 00:32:06 +0000159 VisitDeclContext(dyn_cast<DeclContext>(ND));
Steve Naroff51366e92009-09-02 13:28:54 +0000160 } else
161 Call(ND->isInstanceMethod() ? CXCursor_ObjCInstanceMethodDecl
162 : CXCursor_ObjCClassMethodDecl, ND);
Steve Naroffc674c2d2009-08-31 00:59:03 +0000163 }
164};
165
166}
167
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000168extern "C" {
Ted Kremenek1ca68fb2009-08-26 22:36:44 +0000169
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000170CXIndex clang_createIndex()
Steve Naroff3ba83e92009-08-28 15:28:48 +0000171{
172 return new Indexer(*new Program(), *new FileManager());
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000173}
174
Steve Naroff3ba83e92009-08-28 15:28:48 +0000175// FIXME: need to pass back error info.
176CXTranslationUnit clang_createTranslationUnit(
177 CXIndex CIdx, const char *ast_filename)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000178{
Steve Naroff3ba83e92009-08-28 15:28:48 +0000179 assert(CIdx && "Passed null CXIndex");
180 Indexer *CXXIdx = static_cast<Indexer *>(CIdx);
181 std::string astName(ast_filename);
182 std::string ErrMsg;
183
184 return ASTUnit::LoadFromPCHFile(astName, CXXIdx->getFileManager(), &ErrMsg);
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000185}
186
Steve Naroff6b0576b2009-09-03 00:32:06 +0000187const char *clang_getTranslationUnitSpelling(CXTranslationUnit CTUnit)
188{
189 assert(CTUnit && "Passed null CXTranslationUnit");
190 ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
191 return CXXUnit->getOriginalSourceFileName().c_str();
192}
Daniel Dunbar60dafce2009-08-28 16:30:07 +0000193
Steve Naroff51366e92009-09-02 13:28:54 +0000194void clang_loadTranslationUnit(CXTranslationUnit CTUnit,
195 CXTranslationUnitIterator callback,
196 CXClientData CData)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000197{
Steve Naroff3ba83e92009-08-28 15:28:48 +0000198 assert(CTUnit && "Passed null CXTranslationUnit");
199 ASTUnit *CXXUnit = static_cast<ASTUnit *>(CTUnit);
200 ASTContext &Ctx = CXXUnit->getASTContext();
201
Steve Naroffb836cb72009-09-01 15:55:40 +0000202 TUVisitor DVisit(CTUnit, callback, CData);
Steve Naroff3ba83e92009-08-28 15:28:48 +0000203 DVisit.Visit(Ctx.getTranslationUnitDecl());
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000204}
205
Steve Naroff51366e92009-09-02 13:28:54 +0000206void clang_loadDeclaration(CXDecl Dcl,
207 CXDeclIterator callback,
208 CXClientData CData)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000209{
Steve Naroff51366e92009-09-02 13:28:54 +0000210 assert(Dcl && "Passed null CXDecl");
211
212 CDeclVisitor DVisit(Dcl, callback, CData);
213 DVisit.Visit(static_cast<Decl *>(Dcl));
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000214}
215
Steve Naroff00eb51c2009-08-28 12:07:44 +0000216// Some notes on CXEntity:
217//
218// - Since the 'ordinary' namespace includes functions, data, typedefs,
219// ObjC interfaces, thecurrent algorithm is a bit naive (resulting in one
220// entity for 2 different types). For example:
221//
222// module1.m: @interface Foo @end Foo *x;
223// module2.m: void Foo(int);
224//
225// - Since the unique name spans translation units, static data/functions
226// within a CXTranslationUnit are *not* currently represented by entities.
227// As a result, there will be no entity for the following:
228//
229// module.m: static void Foo() { }
230//
231
232
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000233const char *clang_getDeclarationName(CXEntity)
234{
235 return "";
236}
237const char *clang_getURI(CXEntity)
238{
239 return "";
240}
241
242CXEntity clang_getEntity(const char *URI)
243{
244 return 0;
245}
246
247//
248// CXDecl Operations.
249//
250CXCursor clang_getCursorFromDecl(CXDecl)
251{
Steve Naroffc674c2d2009-08-31 00:59:03 +0000252 return CXCursor();
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000253}
254CXEntity clang_getEntityFromDecl(CXDecl)
255{
256 return 0;
257}
Steve Naroffc674c2d2009-08-31 00:59:03 +0000258const char *clang_getDeclSpelling(CXDecl AnonDecl)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000259{
Steve Naroffc674c2d2009-08-31 00:59:03 +0000260 assert(AnonDecl && "Passed null CXDecl");
261 NamedDecl *ND = static_cast<NamedDecl *>(AnonDecl);
Steve Naroff51366e92009-09-02 13:28:54 +0000262
263 if (ObjCMethodDecl *OMD = dyn_cast<ObjCMethodDecl>(ND)) {
264 return OMD->getSelector().getAsString().c_str();
265 }
Steve Naroffc674c2d2009-08-31 00:59:03 +0000266 if (ND->getIdentifier())
267 return ND->getIdentifier()->getName();
Steve Naroff51366e92009-09-02 13:28:54 +0000268 else
Steve Naroffc674c2d2009-08-31 00:59:03 +0000269 return "";
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000270}
Steve Naroffa82c7d02009-09-02 18:26:48 +0000271
272const char *clang_getCursorSpelling(CXCursor C)
273{
274 assert(C.decl && "CXCursor has null decl");
275 NamedDecl *ND = static_cast<NamedDecl *>(C.decl);
276
277 if (clang_isReference(C.kind)) {
278 switch (C.kind) {
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000279 case CXCursor_ObjCSuperClassRef:
280 {
Steve Naroffa82c7d02009-09-02 18:26:48 +0000281 ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND);
282 assert(OID && "clang_getCursorLine(): Missing interface decl");
283 return OID->getSuperClass()->getIdentifier()->getName();
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000284 }
Steve Naroffa82c7d02009-09-02 18:26:48 +0000285 default:
286 return "<not implemented>";
287 }
288 }
289 return clang_getDeclSpelling(C.decl);
290}
291
292const char *clang_getCursorKindSpelling(enum CXCursorKind Kind)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000293{
Steve Naroffc674c2d2009-08-31 00:59:03 +0000294 switch (Kind) {
295 case CXCursor_FunctionDecl: return "FunctionDecl";
296 case CXCursor_TypedefDecl: return "TypedefDecl";
297 case CXCursor_EnumDecl: return "EnumDecl";
298 case CXCursor_EnumConstantDecl: return "EnumConstantDecl";
Steve Naroff51366e92009-09-02 13:28:54 +0000299 case CXCursor_StructDecl: return "StructDecl";
300 case CXCursor_UnionDecl: return "UnionDecl";
301 case CXCursor_ClassDecl: return "ClassDecl";
Steve Naroffc674c2d2009-08-31 00:59:03 +0000302 case CXCursor_FieldDecl: return "FieldDecl";
303 case CXCursor_VarDecl: return "VarDecl";
304 case CXCursor_ParmDecl: return "ParmDecl";
305 case CXCursor_ObjCInterfaceDecl: return "ObjCInterfaceDecl";
306 case CXCursor_ObjCCategoryDecl: return "ObjCCategoryDecl";
307 case CXCursor_ObjCProtocolDecl: return "ObjCProtocolDecl";
308 case CXCursor_ObjCPropertyDecl: return "ObjCPropertyDecl";
309 case CXCursor_ObjCIvarDecl: return "ObjCIvarDecl";
Steve Naroff51366e92009-09-02 13:28:54 +0000310 case CXCursor_ObjCInstanceMethodDecl: return "ObjCInstanceMethodDecl";
311 case CXCursor_ObjCClassMethodDecl: return "ObjCClassMethodDecl";
312 case CXCursor_FunctionDefn: return "FunctionDefn";
313 case CXCursor_ObjCInstanceMethodDefn: return "ObjCInstanceMethodDefn";
314 case CXCursor_ObjCClassMethodDefn: return "ObjCClassMethodDefn";
315 case CXCursor_ObjCClassDefn: return "ObjCClassDefn";
316 case CXCursor_ObjCCategoryDefn: return "ObjCCategoryDefn";
Steve Naroffa82c7d02009-09-02 18:26:48 +0000317 case CXCursor_ObjCSuperClassRef: return "ObjCSuperClassRef";
Steve Naroffc674c2d2009-08-31 00:59:03 +0000318 default: return "<not implemented>";
319 }
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000320}
Steve Naroffc674c2d2009-08-31 00:59:03 +0000321
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000322//
323// CXCursor Operations.
324//
325CXCursor clang_getCursor(CXTranslationUnit, const char *source_name,
326 unsigned line, unsigned column)
327{
Steve Naroffc674c2d2009-08-31 00:59:03 +0000328 return CXCursor();
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000329}
330
331CXCursorKind clang_getCursorKind(CXCursor)
332{
Steve Naroffc674c2d2009-08-31 00:59:03 +0000333 return CXCursor_Invalid;
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000334}
335
Steve Naroffc674c2d2009-08-31 00:59:03 +0000336unsigned clang_isDeclaration(enum CXCursorKind K)
337{
338 return K >= CXCursor_FirstDecl && K <= CXCursor_LastDecl;
339}
Steve Naroff52833ba2009-08-31 14:26:51 +0000340
Steve Naroffa82c7d02009-09-02 18:26:48 +0000341unsigned clang_isReference(enum CXCursorKind K)
342{
343 return K >= CXCursor_FirstRef && K <= CXCursor_LastRef;
344}
345
346unsigned clang_isDefinition(enum CXCursorKind K)
347{
348 return K >= CXCursor_FirstDefn && K <= CXCursor_LastDefn;
349}
350
351static SourceLocation getLocationFromCursor(CXCursor C,
352 SourceManager &SourceMgr,
353 NamedDecl *ND) {
Steve Naroffa82c7d02009-09-02 18:26:48 +0000354 if (clang_isReference(C.kind)) {
355 switch (C.kind) {
356 case CXCursor_ObjCSuperClassRef:
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000357 {
Steve Naroffa82c7d02009-09-02 18:26:48 +0000358 ObjCInterfaceDecl *OID = dyn_cast<ObjCInterfaceDecl>(ND);
359 assert(OID && "clang_getCursorLine(): Missing interface decl");
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000360 return OID->getSuperClassLoc();
361 }
Steve Naroffa82c7d02009-09-02 18:26:48 +0000362 default:
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000363 return SourceLocation();
Steve Naroffa82c7d02009-09-02 18:26:48 +0000364 }
365 } else { // We have a declaration or a definition.
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000366 SourceLocation SLoc = ND->getLocation();
Steve Naroffa82c7d02009-09-02 18:26:48 +0000367 if (SLoc.isInvalid())
368 return SourceLocation();
Steve Naroffaafbd3d2009-09-02 18:58:52 +0000369 return SourceMgr.getSpellingLoc(SLoc); // handles macro instantiations.
Steve Naroffa82c7d02009-09-02 18:26:48 +0000370 }
Steve Naroffa82c7d02009-09-02 18:26:48 +0000371}
372
Steve Naroff52833ba2009-08-31 14:26:51 +0000373unsigned clang_getCursorLine(CXCursor C)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000374{
Steve Naroff52833ba2009-08-31 14:26:51 +0000375 assert(C.decl && "CXCursor has null decl");
376 NamedDecl *ND = static_cast<NamedDecl *>(C.decl);
Steve Naroff52833ba2009-08-31 14:26:51 +0000377 SourceManager &SourceMgr = ND->getASTContext().getSourceManager();
Steve Naroffa82c7d02009-09-02 18:26:48 +0000378
379 SourceLocation SLoc = getLocationFromCursor(C, SourceMgr, ND);
Steve Naroff52833ba2009-08-31 14:26:51 +0000380 return SourceMgr.getSpellingLineNumber(SLoc);
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000381}
Steve Naroffa82c7d02009-09-02 18:26:48 +0000382
Steve Naroff52833ba2009-08-31 14:26:51 +0000383unsigned clang_getCursorColumn(CXCursor C)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000384{
Steve Naroff52833ba2009-08-31 14:26:51 +0000385 assert(C.decl && "CXCursor has null decl");
386 NamedDecl *ND = static_cast<NamedDecl *>(C.decl);
Steve Naroff52833ba2009-08-31 14:26:51 +0000387 SourceManager &SourceMgr = ND->getASTContext().getSourceManager();
Steve Naroffa82c7d02009-09-02 18:26:48 +0000388
389 SourceLocation SLoc = getLocationFromCursor(C, SourceMgr, ND);
Steve Naroff52833ba2009-08-31 14:26:51 +0000390 return SourceMgr.getSpellingColumnNumber(SLoc);
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000391}
Steve Naroff52833ba2009-08-31 14:26:51 +0000392const char *clang_getCursorSource(CXCursor C)
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000393{
Steve Naroff52833ba2009-08-31 14:26:51 +0000394 assert(C.decl && "CXCursor has null decl");
395 NamedDecl *ND = static_cast<NamedDecl *>(C.decl);
Steve Naroff52833ba2009-08-31 14:26:51 +0000396 SourceManager &SourceMgr = ND->getASTContext().getSourceManager();
Steve Naroffa82c7d02009-09-02 18:26:48 +0000397
398 SourceLocation SLoc = getLocationFromCursor(C, SourceMgr, ND);
Steve Naroff52833ba2009-08-31 14:26:51 +0000399 return SourceMgr.getBufferName(SLoc);
Steve Naroffa6fc61b2009-08-27 19:51:58 +0000400}
401
402// If CXCursorKind == Cursor_Reference, then this will return the referenced declaration.
403// If CXCursorKind == Cursor_Declaration, then this will return the declaration.
404CXDecl clang_getCursorDecl(CXCursor)
405{
406 return 0;
407}
408
409} // end extern "C"