r209767 - Expose CUDA function attributes to the C interface.
Eli Bendersky
eliben at google.com
Wed May 28 12:29:58 PDT 2014
Author: eliben
Date: Wed May 28 14:29:58 2014
New Revision: 209767
URL: http://llvm.org/viewvc/llvm-project?rev=209767&view=rev
Log:
Expose CUDA function attributes to the C interface.
Until now all CUDA-specific attributes were represented with
CXCursor_UnexposedAttr; now they are actually implemented, including the Python
bindings.
Added:
cfe/trunk/test/Index/attributes-cuda.cu
Modified:
cfe/trunk/bindings/python/clang/cindex.py
cfe/trunk/include/clang-c/Index.h
cfe/trunk/tools/libclang/CIndex.cpp
cfe/trunk/tools/libclang/CXCursor.cpp
Modified: cfe/trunk/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=209767&r1=209766&r2=209767&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed May 28 14:29:58 2014
@@ -1082,6 +1082,10 @@ CursorKind.PACKED_ATTR = CursorKind(408)
CursorKind.PURE_ATTR = CursorKind(409)
CursorKind.CONST_ATTR = CursorKind(410)
CursorKind.NODUPLICATE_ATTR = CursorKind(411)
+CursorKind.CUDACONSTANT_ATTR = CursorKind(412)
+CursorKind.CUDADEVICE_ATTR = CursorKind(413)
+CursorKind.CUDAGLOBAL_ATTR = CursorKind(414)
+CursorKind.CUDAHOST_ATTR = CursorKind(415)
###
# Preprocessing
Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=209767&r1=209766&r2=209767&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed May 28 14:29:58 2014
@@ -2168,8 +2168,12 @@ enum CXCursorKind {
CXCursor_PureAttr = 409,
CXCursor_ConstAttr = 410,
CXCursor_NoDuplicateAttr = 411,
- CXCursor_LastAttr = CXCursor_NoDuplicateAttr,
-
+ CXCursor_CUDAConstantAttr = 412,
+ CXCursor_CUDADeviceAttr = 413,
+ CXCursor_CUDAGlobalAttr = 414,
+ CXCursor_CUDAHostAttr = 415,
+ CXCursor_LastAttr = CXCursor_CUDAHostAttr,
+
/* Preprocessing */
CXCursor_PreprocessingDirective = 500,
CXCursor_MacroDefinition = 501,
Added: cfe/trunk/test/Index/attributes-cuda.cu
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes-cuda.cu?rev=209767&view=auto
==============================================================================
--- cfe/trunk/test/Index/attributes-cuda.cu (added)
+++ cfe/trunk/test/Index/attributes-cuda.cu Wed May 28 14:29:58 2014
@@ -0,0 +1,16 @@
+// RUN: c-index-test -test-load-source all -x cuda %s | FileCheck %s
+
+__attribute__((device)) void f_device();
+__attribute__((global)) void f_global();
+__attribute__((constant)) int* g_constant;
+__attribute__((host)) void f_host();
+
+
+// CHECK: attributes-cuda.cu:3:30: FunctionDecl=f_device:3:30
+// CHECK-NEXT: attributes-cuda.cu:3:16: attribute(device)
+// CHECK: attributes-cuda.cu:4:30: FunctionDecl=f_global:4:30
+// CHECK-NEXT: attributes-cuda.cu:4:16: attribute(global)
+// CHECK: attributes-cuda.cu:5:32: VarDecl=g_constant:5:32 (Definition)
+// CHECK-NEXT: attributes-cuda.cu:5:16: attribute(constant)
+// CHECK: attributes-cuda.cu:6:28: FunctionDecl=f_host:6:28
+// CHECK-NEXT: attributes-cuda.cu:6:16: attribute(host)
Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=209767&r1=209766&r2=209767&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed May 28 14:29:58 2014
@@ -3879,6 +3879,14 @@ CXString clang_getCursorKindSpelling(enu
return cxstring::createRef("attribute(const)");
case CXCursor_NoDuplicateAttr:
return cxstring::createRef("attribute(noduplicate)");
+ case CXCursor_CUDAConstantAttr:
+ return cxstring::createRef("attribute(constant)");
+ case CXCursor_CUDADeviceAttr:
+ return cxstring::createRef("attribute(device)");
+ case CXCursor_CUDAGlobalAttr:
+ return cxstring::createRef("attribute(global)");
+ case CXCursor_CUDAHostAttr:
+ return cxstring::createRef("attribute(host)");
case CXCursor_PreprocessingDirective:
return cxstring::createRef("preprocessing directive");
case CXCursor_MacroDefinition:
Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=209767&r1=209766&r2=209767&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Wed May 28 14:29:58 2014
@@ -53,6 +53,10 @@ static CXCursorKind GetCursorKind(const
case attr::Pure: return CXCursor_PureAttr;
case attr::Const: return CXCursor_ConstAttr;
case attr::NoDuplicate: return CXCursor_NoDuplicateAttr;
+ case attr::CUDAConstant: return CXCursor_CUDAConstantAttr;
+ case attr::CUDADevice: return CXCursor_CUDADeviceAttr;
+ case attr::CUDAGlobal: return CXCursor_CUDAGlobalAttr;
+ case attr::CUDAHost: return CXCursor_CUDAHostAttr;
}
return CXCursor_UnexposedAttr;
More information about the cfe-commits
mailing list