[PATCH] Added functions to retrieve information about variable storage in libclang and its python bindings.
guibufolo+llvm at gmail.com
guibufolo+llvm at gmail.com
Tue Jun 30 00:06:47 PDT 2015
http://reviews.llvm.org/D10834
Files:
bindings/python/clang/cindex.py
include/clang-c/Index.h
tools/libclang/CIndex.cpp
Index: bindings/python/clang/cindex.py
===================================================================
--- bindings/python/clang/cindex.py
+++ bindings/python/clang/cindex.py
@@ -1404,6 +1404,20 @@
return self._referenced
@property
+ def has_local_storage(self):
+ if not hasattr(self, '_localstorage'):
+ self._localstorage = conf.lib.clang_Cursor_hasLocalStorage(self)
+
+ return self._localstorage
+
+ @property
+ def is_static_local(self):
+ if not hasattr(self, '_staticlocal'):
+ self._staticlocal = conf.lib.clang_Cursor_isStaticLocal(self)
+
+ return self._staticlocal
+
+ @property
def brief_comment(self):
"""Returns the brief comment text associated with that Cursor"""
return conf.lib.clang_Cursor_getBriefCommentText(self)
Index: include/clang-c/Index.h
===================================================================
--- include/clang-c/Index.h
+++ include/clang-c/Index.h
@@ -3813,6 +3813,16 @@
CINDEX_LINKAGE unsigned clang_Cursor_isVariadic(CXCursor C);
/**
+ * \brief Returns true if a variable with function scope is a non-static local variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_hasLocalStorage(CXCursor C);
+
+/*
+ * \brief Returns true if a variable with function scope is a static local variable.
+ */
+CINDEX_LINKAGE bool clang_Cursor_isStaticLocal(CXCursor C);
+
+/**
* \brief Given a cursor that represents a declaration, return the associated
* comment's source range. The range may include multiple consecutive comments
* with whitespace in between.
Index: tools/libclang/CIndex.cpp
===================================================================
--- tools/libclang/CIndex.cpp
+++ tools/libclang/CIndex.cpp
@@ -6667,6 +6667,32 @@
return 0;
}
+bool clang_Cursor_hasLocalStorage(CXCursor C) {
+ if (C.kind != CXCursor_VarDecl) {
+ return false;
+ }
+
+ const Decl *D = getCursorDecl(C);
+ if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ return VD->hasLocalStorage();
+ }
+
+ return false;
+}
+
+bool clang_Cursor_isStaticLocal(CXCursor C) {
+ if (C.kind != CXCursor_VarDecl) {
+ return false;
+ }
+
+ const Decl *D = getCursorDecl(C);
+ if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ return VD->isStaticLocal();
+ }
+
+ return false;
+}
+
CXSourceRange clang_Cursor_getCommentRange(CXCursor C) {
if (!clang_isDeclaration(C.kind))
return clang_getNullRange();
EMAIL PREFERENCES
http://reviews.llvm.org/settings/panel/emailpreferences/
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D10834.28758.patch
Type: text/x-patch
Size: 2459 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20150630/bba6cc28/attachment.bin>
More information about the cfe-commits
mailing list