r338820 - [libclang 8/8] Add support for the flag_enum attribute

Michael Wu via cfe-commits cfe-commits at lists.llvm.org
Thu Aug 2 22:55:40 PDT 2018


Author: mwu
Date: Thu Aug  2 22:55:40 2018
New Revision: 338820

URL: http://llvm.org/viewvc/llvm-project?rev=338820&view=rev
Log:
[libclang 8/8] Add support for the flag_enum attribute

Summary:
This adds support to libclang for reading the flag_enum attribute.

This also bumps CINDEX_VERSION_MINOR for this patch series.

Reviewers: yvvan, jbcoe

Reviewed By: yvvan

Subscribers: cfe-commits

Differential Revision: https://reviews.llvm.org/D49635

Modified:
    cfe/trunk/include/clang-c/Index.h
    cfe/trunk/test/Index/attributes.c
    cfe/trunk/tools/libclang/CIndex.cpp
    cfe/trunk/tools/libclang/CXCursor.cpp

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=338820&r1=338819&r2=338820&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Thu Aug  2 22:55:40 2018
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 49
+#define CINDEX_VERSION_MINOR 50
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
       ((major) * 10000)                       \
@@ -2585,7 +2585,8 @@ enum CXCursorKind {
   CXCursor_ObjCDesignatedInitializer     = 434,
   CXCursor_ObjCRuntimeVisible            = 435,
   CXCursor_ObjCBoxable                   = 436,
-  CXCursor_LastAttr                      = CXCursor_ObjCBoxable,
+  CXCursor_FlagEnum                      = 437,
+  CXCursor_LastAttr                      = CXCursor_FlagEnum,
 
   /* Preprocessing */
   CXCursor_PreprocessingDirective        = 500,

Modified: cfe/trunk/test/Index/attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Index/attributes.c?rev=338820&r1=338819&r2=338820&view=diff
==============================================================================
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Thu Aug  2 22:55:40 2018
@@ -8,6 +8,10 @@ void pure_fn() __attribute__((pure));
 void const_fn() __attribute__((const));
 void noduplicate_fn() __attribute__((noduplicate));
 
+enum __attribute((flag_enum)) FlagEnum {
+  Foo
+};
+
 // 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]
@@ -18,3 +22,5 @@ void noduplicate_fn() __attribute__((nod
 // 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]
+// CHECK: attributes.c:11:31: EnumDecl=FlagEnum:11:31 (Definition) Extent=[11:1 - 13:2]
+// CHECK: attributes.c:11:19: attribute(flag_enum)= Extent=[11:19 - 11:28]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=338820&r1=338819&r2=338820&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Thu Aug  2 22:55:40 2018
@@ -5313,6 +5313,8 @@ CXString clang_getCursorKindSpelling(enu
     return cxstring::createRef("attribute(objc_runtime_visible)");
   case CXCursor_ObjCBoxable:
     return cxstring::createRef("attribute(objc_boxable)");
+  case CXCursor_FlagEnum:
+    return cxstring::createRef("attribute(flag_enum)");
   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=338820&r1=338819&r2=338820&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Thu Aug  2 22:55:40 2018
@@ -78,6 +78,7 @@ static CXCursorKind GetCursorKind(const
     case attr::ObjCDesignatedInitializer: return CXCursor_ObjCDesignatedInitializer;
     case attr::ObjCRuntimeVisible: return CXCursor_ObjCRuntimeVisible;
     case attr::ObjCBoxable: return CXCursor_ObjCBoxable;
+    case attr::FlagEnum: return CXCursor_FlagEnum;
   }
 
   return CXCursor_UnexposedAttr;




More information about the cfe-commits mailing list