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/
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();
_______________________________________________
cfe-commits mailing list
cfe-commits@cs.uiuc.edu
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to