r356062 - [libclang] Expose aligned() attribute.

Emilio Cobos Alvarez via cfe-commits cfe-commits at lists.llvm.org
Wed Mar 13 09:16:54 PDT 2019


Author: emilio
Date: Wed Mar 13 09:16:54 2019
New Revision: 356062

URL: http://llvm.org/viewvc/llvm-project?rev=356062&view=rev
Log:
[libclang] Expose aligned() attribute.

Summary:
This is useful because otherwise there's no easy way to distinguish #pragma
packed(N) from attribute(packed, aligned(N)) that isn't looking at field
offsets (since pragma packed() also creates a packed attribute).

Reviewers: Anastasia, arphaman, serge-sans-paille

Subscribers: cfe-commits

Tags: #clang

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

Modified:
    cfe/trunk/bindings/python/clang/cindex.py
    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/bindings/python/clang/cindex.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/clang/cindex.py?rev=356062&r1=356061&r2=356062&view=diff
==============================================================================
--- cfe/trunk/bindings/python/clang/cindex.py (original)
+++ cfe/trunk/bindings/python/clang/cindex.py Wed Mar 13 09:16:54 2019
@@ -1345,6 +1345,7 @@ CursorKind.DLLIMPORT_ATTR = CursorKind(4
 CursorKind.CONVERGENT_ATTR = CursorKind(438)
 CursorKind.WARN_UNUSED_ATTR = CursorKind(439)
 CursorKind.WARN_UNUSED_RESULT_ATTR = CursorKind(440)
+CursorKind.ALIGNED_ATTR = CursorKind(441)
 
 ###
 # Preprocessing

Modified: cfe/trunk/include/clang-c/Index.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang-c/Index.h?rev=356062&r1=356061&r2=356062&view=diff
==============================================================================
--- cfe/trunk/include/clang-c/Index.h (original)
+++ cfe/trunk/include/clang-c/Index.h Wed Mar 13 09:16:54 2019
@@ -32,7 +32,7 @@
  * compatible, thus CINDEX_VERSION_MAJOR is expected to remain stable.
  */
 #define CINDEX_VERSION_MAJOR 0
-#define CINDEX_VERSION_MINOR 53
+#define CINDEX_VERSION_MINOR 54
 
 #define CINDEX_VERSION_ENCODE(major, minor) ( \
       ((major) * 10000)                       \
@@ -2589,7 +2589,8 @@ enum CXCursorKind {
   CXCursor_ConvergentAttr                = 438,
   CXCursor_WarnUnusedAttr                = 439,
   CXCursor_WarnUnusedResultAttr          = 440,
-  CXCursor_LastAttr                      = CXCursor_WarnUnusedResultAttr,
+  CXCursor_AlignedAttr                   = 441,
+  CXCursor_LastAttr                      = CXCursor_AlignedAttr,
 
   /* 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=356062&r1=356061&r2=356062&view=diff
==============================================================================
--- cfe/trunk/test/Index/attributes.c (original)
+++ cfe/trunk/test/Index/attributes.c Wed Mar 13 09:16:54 2019
@@ -20,6 +20,14 @@ struct __attribute__((warn_unused)) Warn
   int b;
 };
 
+struct __attribute__((aligned(64))) Aligned1 {
+  int c;
+};
+
+struct Aligned2 {
+  int c;
+} __attribute__((aligned(64)));
+
 // 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]
@@ -39,3 +47,7 @@ struct __attribute__((warn_unused)) Warn
 // CHECK: attributes.c:17:44: attribute(warn_unused_result)= Extent=[17:44 - 17:62]
 // CHECK: attributes.c:19:37: StructDecl=WarnUnused:19:37 (Definition) Extent=[19:1 - 21:2]
 // CHECK: attributes.c:19:23: attribute(warn_unused)= Extent=[19:23 - 19:34]
+// CHECK: attributes.c:23:37: StructDecl=Aligned1:23:37 (Definition) Extent=[23:1 - 25:2]
+// CHECK: attributes.c:23:23: attribute(aligned)= Extent=[23:23 - 23:34]
+// CHECK: attributes.c:27:8: StructDecl=Aligned2:27:8 (Definition) Extent=[27:1 - 29:2]
+// CHECK: attributes.c:29:18: attribute(aligned)= Extent=[29:18 - 29:29]

Modified: cfe/trunk/tools/libclang/CIndex.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CIndex.cpp?rev=356062&r1=356061&r2=356062&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CIndex.cpp (original)
+++ cfe/trunk/tools/libclang/CIndex.cpp Wed Mar 13 09:16:54 2019
@@ -5484,6 +5484,8 @@ CXString clang_getCursorKindSpelling(enu
       return cxstring::createRef("attribute(warn_unused)");
   case CXCursor_WarnUnusedResultAttr:
       return cxstring::createRef("attribute(warn_unused_result)");
+  case CXCursor_AlignedAttr:
+      return cxstring::createRef("attribute(aligned)");
   }
 
   llvm_unreachable("Unhandled CXCursorKind");

Modified: cfe/trunk/tools/libclang/CXCursor.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/tools/libclang/CXCursor.cpp?rev=356062&r1=356061&r2=356062&view=diff
==============================================================================
--- cfe/trunk/tools/libclang/CXCursor.cpp (original)
+++ cfe/trunk/tools/libclang/CXCursor.cpp Wed Mar 13 09:16:54 2019
@@ -81,6 +81,7 @@ static CXCursorKind GetCursorKind(const
     case attr::Convergent: return CXCursor_ConvergentAttr;
     case attr::WarnUnused: return CXCursor_WarnUnusedAttr;
     case attr::WarnUnusedResult: return CXCursor_WarnUnusedResultAttr;
+    case attr::Aligned: return CXCursor_AlignedAttr;
   }
 
   return CXCursor_UnexposedAttr;




More information about the cfe-commits mailing list