summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-10-15 17:05:31 +0000
committerArgyrios Kyrtzidis <akyrtzi@gmail.com>2014-10-15 17:05:31 +0000
commit763069ac81d376e544b40a844a70e5e984e10bf4 (patch)
tree5b081535d201c7147d81b3edb7e2b304b17a5de1 /tools
parent822389da583d9d67f46e84552ecb580c49abcda7 (diff)
[libclang] Add function to retrieve storage class in libclang.
Patch by guibufolo! git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@219809 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'tools')
-rw-r--r--tools/libclang/CIndex.cpp35
-rw-r--r--tools/libclang/libclang.exports1
2 files changed, 36 insertions, 0 deletions
diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp
index 552f5a70a5..8b829c7d50 100644
--- a/tools/libclang/CIndex.cpp
+++ b/tools/libclang/CIndex.cpp
@@ -6418,6 +6418,41 @@ static const Decl *maybeGetTemplateCursor(const Decl *D) {
return D;
}
+
+enum CX_StorageClass clang_Cursor_getStorageClass(CXCursor C) {
+ StorageClass sc = SC_None;
+ const Decl *D = getCursorDecl(C);
+ if (D) {
+ if (const FunctionDecl *FD = dyn_cast<FunctionDecl>(D)) {
+ sc = FD->getStorageClass();
+ } else if (const VarDecl *VD = dyn_cast<VarDecl>(D)) {
+ sc = VD->getStorageClass();
+ } else {
+ return CX_SC_Invalid;
+ }
+ } else {
+ return CX_SC_Invalid;
+ }
+ switch (sc) {
+ case SC_None:
+ return CX_SC_None;
+ case SC_Extern:
+ return CX_SC_Extern;
+ case SC_Static:
+ return CX_SC_Static;
+ case SC_PrivateExtern:
+ return CX_SC_PrivateExtern;
+ case SC_OpenCLWorkGroupLocal:
+ return CX_SC_OpenCLWorkGroupLocal;
+ case SC_Auto:
+ return CX_SC_Auto;
+ case SC_Register:
+ return CX_SC_Register;
+ default:
+ return CX_SC_Invalid;
+ }
+}
+
CXCursor clang_getCursorSemanticParent(CXCursor cursor) {
if (clang_isDeclaration(cursor.kind)) {
if (const Decl *D = getCursorDecl(cursor)) {
diff --git a/tools/libclang/libclang.exports b/tools/libclang/libclang.exports
index d7701ad975..fa2c0e70bf 100644
--- a/tools/libclang/libclang.exports
+++ b/tools/libclang/libclang.exports
@@ -30,6 +30,7 @@ clang_Cursor_isNull
clang_Cursor_isObjCOptional
clang_Cursor_isVariadic
clang_Cursor_getModule
+clang_Cursor_getStorageClass
clang_File_isEqual
clang_Module_getASTFile
clang_Module_getParent