[PATCH] D37378: [clang] [python] Move test_exception_specification_kind to correct subdir

2017-09-08 Thread Andrew J. Bennieston via Phabricator via cfe-commits
ajbennieston accepted this revision.
ajbennieston added a comment.
This revision is now accepted and ready to land.

Looks good to me.


Repository:
  rL LLVM

https://reviews.llvm.org/D37378



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-27 Thread Andrew J. Bennieston via Phabricator via cfe-commits
ajbennieston added a comment.

Jon, by all means go ahead!


https://reviews.llvm.org/D34091



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-17 Thread Andrew J. Bennieston via Phabricator via cfe-commits
ajbennieston updated this revision to Diff 102934.
ajbennieston added a comment.

V3 with indentation and punctuation fixes.


https://reviews.llvm.org/D34091

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_exception_specification_kind.py
  include/clang-c/Index.h
  test/Index/get-cursor.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -175,6 +175,7 @@
 clang_getCursorDefinition
 clang_getCursorDisplayName
 clang_getCursorExtent
+clang_getCursorExceptionSpecificationType
 clang_getCursorKind
 clang_getCursorKindSpelling
 clang_getCursorLanguage
@@ -210,6 +211,7 @@
 clang_getEnumConstantDeclUnsignedValue
 clang_getEnumConstantDeclValue
 clang_getEnumDeclIntegerType
+clang_getExceptionSpecificationType
 clang_getFieldDeclBitWidth
 clang_getExpansionLocation
 clang_getFile
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -684,6 +684,24 @@
   return MakeCXType(QualType(), cxcursor::getCursorTU(C));
 }
 
+int clang_getExceptionSpecificationType(CXType X) {
+  QualType T = GetQualType(X);
+  if (T.isNull())
+return -1;
+  
+  if (const auto *FD = T->getAs())
+return static_cast(FD->getExceptionSpecType());
+
+  return -1;
+}
+
+int clang_getCursorExceptionSpecificationType(CXCursor C) {
+  if (clang_isDeclaration(C.kind))
+return clang_getExceptionSpecificationType(clang_getCursorType(C));
+
+  return -1;
+}
+
 unsigned clang_isPODType(CXType X) {
   QualType T = GetQualType(X);
   if (T.isNull())
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -809,6 +809,37 @@
 if (clang_Cursor_isObjCOptional(Cursor))
   printf(" (@optional)");
 
+switch (clang_getCursorExceptionSpecificationType(Cursor))
+{
+  case CXCursor_ExceptionSpecificationKind_None:
+break;
+
+  case CXCursor_ExceptionSpecificationKind_DynamicNone:
+printf(" (noexcept dynamic none)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Dynamic:
+printf(" (noexcept dynamic)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_MSAny:
+printf(" (noexcept dynamic any)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_BasicNoexcept:
+printf(" (noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_ComputedNoexcept:
+printf(" (computed-noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Unevaluated:
+  case CXCursor_ExceptionSpecificationKind_Uninstantiated:
+  case CXCursor_ExceptionSpecificationKind_Unparsed:
+break;
+}
+
 {
   CXString language;
   CXString definedIn;
Index: test/Index/get-cursor.cpp
===
--- test/Index/get-cursor.cpp
+++ test/Index/get-cursor.cpp
@@ -145,6 +145,13 @@
 
 const int operator""_toint(unsigned long long val) { return int(val); }
 
+// noexcept specifications
+void f_noexcept() noexcept;
+template  void f_computed_noexcept(T t) noexcept(noexcept(t+t));
+void f_dynamic_noexcept_none() throw();
+void f_dynamic_noexcept() throw(int);
+void f_dynamic_noexcept_any() throw(...);
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -209,11 +216,11 @@
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 

[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-15 Thread Andrew J. Bennieston via Phabricator via cfe-commits
ajbennieston updated this revision to Diff 102707.
ajbennieston added a comment.

Fixes for review comments.


https://reviews.llvm.org/D34091

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_exception_specification_kind.py
  include/clang-c/Index.h
  test/Index/get-cursor.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -175,6 +175,7 @@
 clang_getCursorDefinition
 clang_getCursorDisplayName
 clang_getCursorExtent
+clang_getCursorExceptionSpecificationType
 clang_getCursorKind
 clang_getCursorKindSpelling
 clang_getCursorLanguage
@@ -210,6 +211,7 @@
 clang_getEnumConstantDeclUnsignedValue
 clang_getEnumConstantDeclValue
 clang_getEnumDeclIntegerType
+clang_getExceptionSpecificationType
 clang_getFieldDeclBitWidth
 clang_getExpansionLocation
 clang_getFile
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -684,6 +684,24 @@
   return MakeCXType(QualType(), cxcursor::getCursorTU(C));
 }
 
+int clang_getExceptionSpecificationType(CXType X) {
+QualType T = GetQualType(X);
+if (T.isNull())
+return -1;
+
+if (const auto* FD = T->getAs())
+return static_cast(FD->getExceptionSpecType());
+
+return -1;
+}
+
+int clang_getCursorExceptionSpecificationType(CXCursor C) {
+if (clang_isDeclaration(C.kind))
+return clang_getExceptionSpecificationType(clang_getCursorType(C));
+
+return -1;
+}
+
 unsigned clang_isPODType(CXType X) {
   QualType T = GetQualType(X);
   if (T.isNull())
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -809,6 +809,37 @@
 if (clang_Cursor_isObjCOptional(Cursor))
   printf(" (@optional)");
 
+switch (clang_getCursorExceptionSpecificationType(Cursor))
+{
+  case CXCursor_ExceptionSpecificationKind_None:
+break;
+
+  case CXCursor_ExceptionSpecificationKind_DynamicNone:
+printf(" (noexcept dynamic none)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Dynamic:
+printf(" (noexcept dynamic)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_MSAny:
+printf(" (noexcept dynamic any)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_BasicNoexcept:
+printf(" (noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_ComputedNoexcept:
+printf(" (computed-noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Unevaluated:
+  case CXCursor_ExceptionSpecificationKind_Uninstantiated:
+  case CXCursor_ExceptionSpecificationKind_Unparsed:
+break;
+}
+
 {
   CXString language;
   CXString definedIn;
Index: test/Index/get-cursor.cpp
===
--- test/Index/get-cursor.cpp
+++ test/Index/get-cursor.cpp
@@ -145,6 +145,13 @@
 
 const int operator""_toint(unsigned long long val) { return int(val); }
 
+// noexcept specifications
+void f_noexcept() noexcept;
+template  void f_computed_noexcept(T t) noexcept(noexcept(t+t));
+void f_dynamic_noexcept_none() throw();
+void f_dynamic_noexcept() throw(int);
+void f_dynamic_noexcept_any() throw(...);
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -209,11 +216,11 @@
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6 -cursor-at=%s:114:6 -cursor-at=%s:117:8 -cursor-at=%s:118:8 -cursor-at=%s:120:8 -cursor-at=%s:121:8 -cursor-at=%s:122:8 -cursor-at=%s:123:8 -cursor-at=%s:124:8 -cursor-at=%s:125:8 -cursor-at=%s:128:6 

[PATCH] D34091: Support for querying the exception specification type through libclang

2017-06-11 Thread Andrew J. Bennieston via Phabricator via cfe-commits
ajbennieston created this revision.

This patch exposes the exception specification type (noexcept, etc.) of a C++ 
function through libclang and Python clang.cindex.


Repository:
  rL LLVM

https://reviews.llvm.org/D34091

Files:
  bindings/python/clang/cindex.py
  bindings/python/tests/cindex/test_exception_specification_kind.py
  include/clang-c/Index.h
  test/Index/get-cursor.cpp
  tools/c-index-test/c-index-test.c
  tools/libclang/CXType.cpp
  tools/libclang/libclang.exports

Index: tools/libclang/libclang.exports
===
--- tools/libclang/libclang.exports
+++ tools/libclang/libclang.exports
@@ -175,6 +175,7 @@
 clang_getCursorDefinition
 clang_getCursorDisplayName
 clang_getCursorExtent
+clang_getCursorExceptionSpecificationType
 clang_getCursorKind
 clang_getCursorKindSpelling
 clang_getCursorLanguage
@@ -210,6 +211,7 @@
 clang_getEnumConstantDeclUnsignedValue
 clang_getEnumConstantDeclValue
 clang_getEnumDeclIntegerType
+clang_getExceptionSpecificationType
 clang_getFieldDeclBitWidth
 clang_getExpansionLocation
 clang_getFile
Index: tools/libclang/CXType.cpp
===
--- tools/libclang/CXType.cpp
+++ tools/libclang/CXType.cpp
@@ -684,6 +684,27 @@
   return MakeCXType(QualType(), cxcursor::getCursorTU(C));
 }
 
+int clang_getExceptionSpecificationType(CXType X) {
+QualType T = GetQualType(X);
+if (T.isNull()) {
+return -1;
+}
+
+if (const FunctionProtoType* FD = T->getAs()) {
+return static_cast(FD->getExceptionSpecType());
+} else {
+return -1;
+}
+}
+
+int clang_getCursorExceptionSpecificationType(CXCursor C) {
+if (clang_isDeclaration(C.kind)) {
+return clang_getExceptionSpecificationType(clang_getCursorType(C));
+} else {
+return -1;
+}
+}
+
 unsigned clang_isPODType(CXType X) {
   QualType T = GetQualType(X);
   if (T.isNull())
Index: tools/c-index-test/c-index-test.c
===
--- tools/c-index-test/c-index-test.c
+++ tools/c-index-test/c-index-test.c
@@ -809,6 +809,37 @@
 if (clang_Cursor_isObjCOptional(Cursor))
   printf(" (@optional)");
 
+switch (clang_getCursorExceptionSpecificationType(Cursor))
+{
+  case CXCursor_ExceptionSpecificationKind_None:
+break;
+
+  case CXCursor_ExceptionSpecificationKind_DynamicNone:
+printf(" (noexcept dynamic none)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Dynamic:
+printf(" (noexcept dynamic)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_MSAny:
+printf(" (noexcept dynamic any)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_BasicNoexcept:
+printf(" (noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_ComputedNoexcept:
+printf(" (computed-noexcept)");
+break;
+
+  case CXCursor_ExceptionSpecificationKind_Unevaluated:
+  case CXCursor_ExceptionSpecificationKind_Uninstantiated:
+  case CXCursor_ExceptionSpecificationKind_Unparsed:
+break;
+}
+
 {
   CXString language;
   CXString definedIn;
Index: test/Index/get-cursor.cpp
===
--- test/Index/get-cursor.cpp
+++ test/Index/get-cursor.cpp
@@ -145,6 +145,13 @@
 
 const int operator""_toint(unsigned long long val) { return int(val); }
 
+// noexcept specifications
+void f_noexcept() noexcept;
+template  void f_computed_noexcept(T t) noexcept(noexcept(t+t));
+void f_dynamic_noexcept_none() throw();
+void f_dynamic_noexcept() throw(int); // just for testing, throwing int is not ideal.
+void f_dynamic_noexcept_any() throw(...);
+
 // RUN: c-index-test -cursor-at=%s:6:4 %s | FileCheck -check-prefix=CHECK-COMPLETION-1 %s
 // CHECK-COMPLETION-1: CXXConstructor=X:6:3
 // CHECK-COMPLETION-1-NEXT: Completion string: {TypedText X}{LeftParen (}{Placeholder int}{Comma , }{Placeholder int}{RightParen )}
@@ -209,11 +216,11 @@
 // RUN: c-index-test -cursor-at=%s:66:23 %s | FileCheck -check-prefix=CHECK-TEMPLSPEC %s
 // CHECK-TEMPLSPEC: 66:23 ClassDecl=TC:66:23 (Definition) [Specialization of TC:59:7] Extent=[66:1 - 66:31] Spelling=TC ([66:23 - 66:25])
 
-// RUN: c-index-test -cursor-at=%s:69:3 -cursor-at=%s:70:11 -cursor-at=%s:73:6 -cursor-at=%s:74:6 -cursor-at=%s:77:8 -cursor-at=%s:78:8 -cursor-at=%s:79:8 -cursor-at=%s:80:8 -cursor-at=%s:81:8 -cursor-at=%s:82:8 -cursor-at=%s:85:6 -cursor-at=%s:86:6 -cursor-at=%s:87:6 -cursor-at=%s:88:6 -cursor-at=%s:91:5 -cursor-at=%s:92:5 -cursor-at=%s:93:5 -cursor-at=%s:94:5 -cursor-at=%s:95:5 -cursor-at=%s:96:5 -cursor-at=%s:97:5 -cursor-at=%s:98:5 -cursor-at=%s:100:5 -cursor-at=%s:101:5 -cursor-at=%s:104:6 -cursor-at=%s:105:6 -cursor-at=%s:106:6 -cursor-at=%s:107:6 -cursor-at=%s:108:6 -cursor-at=%s:109:6 -cursor-at=%s:110:6 -cursor-at=%s:111:6 -cursor-at=%s:113:6