diff options
| author | Ted Kremenek <kremenek@apple.com> | 2010-03-03 06:36:57 +0000 |
|---|---|---|
| committer | Ted Kremenek <kremenek@apple.com> | 2010-03-03 06:36:57 +0000 |
| commit | fb4961dfd0385c6e3d6c324187cf2d74ecfc964b (patch) | |
| tree | 2433d92a887d489528e38373869e1061e79794d2 | |
| parent | 3e1ffd06fcdbd6c92c1afd73bd903f4fbaf1d4b8 (diff) | |
| download | bcm5719-llvm-fb4961dfd0385c6e3d6c324187cf2d74ecfc964b.tar.gz bcm5719-llvm-fb4961dfd0385c6e3d6c324187cf2d74ecfc964b.zip | |
Add clang_getCursorLinkage(), which returns the
underlying linkage for the entity referred to by a
CXCursor.
llvm-svn: 97646
| -rw-r--r-- | clang/include/clang-c/Index.h | 26 | ||||
| -rw-r--r-- | clang/tools/CIndex/CIndex.cpp | 19 |
2 files changed, 45 insertions, 0 deletions
diff --git a/clang/include/clang-c/Index.h b/clang/include/clang-c/Index.h index c1238e5d88e..7bc290d88f4 100644 --- a/clang/include/clang-c/Index.h +++ b/clang/include/clang-c/Index.h @@ -889,6 +889,32 @@ CINDEX_LINKAGE unsigned clang_isInvalid(enum CXCursorKind); CINDEX_LINKAGE unsigned clang_isTranslationUnit(enum CXCursorKind); /** + * \brief Describe the linkage of the entity referred to by a cursor. + */ +enum CXLinkageKind { + /** \brief This value indicates that no linkage information is available + * for a provided CXCursor. */ + CXLinkage_Invalid, + /** + * \brief This is the linkage for variables, parameters, and so on that + * have automatic storage. This covers normal (non-extern) local variables. + */ + CXLinkage_NoLinkage, + /** \brief This is the linkage for static variables and static functions. */ + CXLinkage_Internal, + /** \brief This is the linkage for entities with external linkage that live + * in C++ anonymous namespaces.*/ + CXLinkage_UniqueExternal, + /** \brief This is the linkage for entities with true, external linkage. */ + CXLinkage_External +}; + +/** + * \brief Determine the linkage of the entity referred to be a given cursor. + */ +CINDEX_LINKAGE enum CXLinkageKind clang_getCursorLinkage(CXCursor cursor); + +/** * @} */ diff --git a/clang/tools/CIndex/CIndex.cpp b/clang/tools/CIndex/CIndex.cpp index e13dddfcad5..6fc7b530307 100644 --- a/clang/tools/CIndex/CIndex.cpp +++ b/clang/tools/CIndex/CIndex.cpp @@ -2210,6 +2210,25 @@ void clang_disposeTokens(CXTranslationUnit TU, } // end: extern "C" //===----------------------------------------------------------------------===// +// Operations for querying linkage of a cursor. +//===----------------------------------------------------------------------===// + +extern "C" { +CXLinkageKind clang_getCursorLinkage(CXCursor cursor) { + Decl *D = cxcursor::getCursorDecl(cursor); + if (NamedDecl *ND = dyn_cast_or_null<NamedDecl>(D)) + switch (ND->getLinkage()) { + case NoLinkage: return CXLinkage_NoLinkage; + case InternalLinkage: return CXLinkage_Internal; + case UniqueExternalLinkage: return CXLinkage_UniqueExternal; + case ExternalLinkage: return CXLinkage_External; + }; + + return CXLinkage_Invalid; +} +} // end: extern "C" + +//===----------------------------------------------------------------------===// // CXString Operations. //===----------------------------------------------------------------------===// |

