From: Steve Naroff Date: Fri, 25 Sep 2009 21:45:39 +0000 (+0000) Subject: Add clang_getDeclSource(). X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=ee9405e807d7c447c0143c2bd865b759192e97b3;p=clang Add clang_getDeclSource(). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@82807 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 2203e28723..3178017e45 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -177,6 +177,7 @@ CXEntity clang_getEntityFromDecl(CXDecl); const char *clang_getDeclSpelling(CXDecl); unsigned clang_getDeclLine(CXDecl); unsigned clang_getDeclColumn(CXDecl); +const char *clang_getDeclSource(CXDecl); /* * CXCursor Operations. diff --git a/tools/CIndex/CIndex.cpp b/tools/CIndex/CIndex.cpp index 74b3cfd8af..ff0be0d9e2 100644 --- a/tools/CIndex/CIndex.cpp +++ b/tools/CIndex/CIndex.cpp @@ -370,6 +370,14 @@ unsigned clang_getDeclColumn(CXDecl AnonDecl) return SourceMgr.getSpellingLineNumber(ND->getLocation()); } +const char *clang_getDeclSource(CXDecl AnonDecl) +{ + assert(AnonDecl && "Passed null CXDecl"); + NamedDecl *ND = static_cast(AnonDecl); + SourceManager &SourceMgr = ND->getASTContext().getSourceManager(); + return SourceMgr.getBufferName(ND->getLocation()); +} + const char *clang_getCursorSpelling(CXCursor C) { assert(C.decl && "CXCursor has null decl"); diff --git a/tools/CIndex/CIndex.exports b/tools/CIndex/CIndex.exports index 8cfc1a9d7f..c1ca0c7735 100644 --- a/tools/CIndex/CIndex.exports +++ b/tools/CIndex/CIndex.exports @@ -11,6 +11,7 @@ _clang_getDeclarationName _clang_getDeclSpelling _clang_getDeclLine _clang_getDeclColumn +_clang_getDeclSource _clang_getEntity _clang_getEntityFromDecl _clang_getURI