From: Joey Gouly Date: Thu, 1 May 2014 15:41:58 +0000 (+0000) Subject: [libclang] Add attribute support for 'pure', 'const' and 'noduplicate'. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=bfbb72a5880662a18d1ce0d01d1539426e879166;p=clang [libclang] Add attribute support for 'pure', 'const' and 'noduplicate'. This bumps CINDEX_VERSION_MINOR up (to 26). git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@207767 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/bindings/python/clang/cindex.py b/bindings/python/clang/cindex.py index 21c3f9a8f3..81b2f3f605 100644 --- a/bindings/python/clang/cindex.py +++ b/bindings/python/clang/cindex.py @@ -1079,6 +1079,9 @@ CursorKind.CXX_OVERRIDE_ATTR = CursorKind(405) CursorKind.ANNOTATE_ATTR = CursorKind(406) CursorKind.ASM_LABEL_ATTR = CursorKind(407) CursorKind.PACKED_ATTR = CursorKind(408) +CursorKind.PURE_ATTR = CursorKind(409) +CursorKind.CONST_ATTR = CursorKind(410) +CursorKind.NODUPLICATE_ATTR = CursorKind(411) ### # Preprocessing diff --git a/include/clang-c/Index.h b/include/clang-c/Index.h index 8393c6b7d4..87b1f432fa 100644 --- a/include/clang-c/Index.h +++ b/include/clang-c/Index.h @@ -32,7 +32,7 @@ * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable. */ #define CINDEX_VERSION_MAJOR 0 -#define CINDEX_VERSION_MINOR 25 +#define CINDEX_VERSION_MINOR 26 #define CINDEX_VERSION_ENCODE(major, minor) ( \ ((major) * 10000) \ @@ -2165,7 +2165,10 @@ enum CXCursorKind { CXCursor_AnnotateAttr = 406, CXCursor_AsmLabelAttr = 407, CXCursor_PackedAttr = 408, - CXCursor_LastAttr = CXCursor_PackedAttr, + CXCursor_PureAttr = 409, + CXCursor_ConstAttr = 410, + CXCursor_NoDuplicateAttr = 411, + CXCursor_LastAttr = CXCursor_NoDuplicateAttr, /* Preprocessing */ CXCursor_PreprocessingDirective = 500, diff --git a/test/Index/attributes.c b/test/Index/attributes.c index 3e60e6c0e4..95d9c7548b 100644 --- a/test/Index/attributes.c +++ b/test/Index/attributes.c @@ -4,7 +4,17 @@ struct __attribute__((packed)) Test2 { char a; }; +void pure_fn() __attribute__((pure)); +void const_fn() __attribute__((const)); +void noduplicate_fn() __attribute__((noduplicate)); + // CHECK: attributes.c:3:32: StructDecl=Test2:3:32 (Definition) Extent=[3:1 - 5:2] // CHECK: attributes.c:3:23: attribute(packed)=packed Extent=[3:23 - 3:29] // CHECK: attributes.c:4:8: FieldDecl=a:4:8 (Definition) Extent=[4:3 - 4:9] [access=public] +// CHECK: attributes.c:7:6: FunctionDecl=pure_fn:7:6 Extent=[7:1 - 7:37] +// CHECK: attributes.c:7:31: attribute(pure)= Extent=[7:31 - 7:35] +// CHECK: attributes.c:8:6: FunctionDecl=const_fn:8:6 Extent=[8:1 - 8:39] +// CHECK: attributes.c:8:32: attribute(const)= Extent=[8:32 - 8:37] +// CHECK: attributes.c:9:6: FunctionDecl=noduplicate_fn:9:6 Extent=[9:1 - 9:51] +// CHECK: attributes.c:9:38: attribute(noduplicate)= Extent=[9:38 - 9:49] diff --git a/tools/libclang/CIndex.cpp b/tools/libclang/CIndex.cpp index 26b3bf16af..5191dbfa9b 100644 --- a/tools/libclang/CIndex.cpp +++ b/tools/libclang/CIndex.cpp @@ -3867,6 +3867,12 @@ CXString clang_getCursorKindSpelling(enum CXCursorKind Kind) { return cxstring::createRef("asm label"); case CXCursor_PackedAttr: return cxstring::createRef("attribute(packed)"); + case CXCursor_PureAttr: + return cxstring::createRef("attribute(pure)"); + case CXCursor_ConstAttr: + return cxstring::createRef("attribute(const)"); + case CXCursor_NoDuplicateAttr: + return cxstring::createRef("attribute(noduplicate)"); case CXCursor_PreprocessingDirective: return cxstring::createRef("preprocessing directive"); case CXCursor_MacroDefinition: diff --git a/tools/libclang/CXCursor.cpp b/tools/libclang/CXCursor.cpp index d682986b3f..fb4ce66d3a 100644 --- a/tools/libclang/CXCursor.cpp +++ b/tools/libclang/CXCursor.cpp @@ -50,6 +50,9 @@ static CXCursorKind GetCursorKind(const Attr *A) { case attr::Annotate: return CXCursor_AnnotateAttr; case attr::AsmLabel: return CXCursor_AsmLabelAttr; case attr::Packed: return CXCursor_PackedAttr; + case attr::Pure: return CXCursor_PureAttr; + case attr::Const: return CXCursor_ConstAttr; + case attr::NoDuplicate: return CXCursor_NoDuplicateAttr; } return CXCursor_UnexposedAttr;