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

2017-09-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

Nevermind. I found out what's wrong via looking at the older patch versions.


Repository:
  rL LLVM

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-09-01 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

@ajbennieston, ping.


Repository:
  rL LLVM

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-07-26 Thread Michał Górny via Phabricator via cfe-commits
mgorny added a comment.

This patch has introduced a test suite failure:

  ==
  ERROR: Failure: ImportError (No module named util)
  --
  Traceback (most recent call last):
File "/usr/lib64/python2.7/site-packages/nose/loader.py", line 420, in 
loadTestsFromName
  addr.filename, addr.module)
File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 47, in 
importFromPath
  return self.importFromDir(dir_path, fqname)
File "/usr/lib64/python2.7/site-packages/nose/importer.py", line 94, in 
importFromDir
  mod = load_module(part_fqname, fh, filename, desc)
File 
"/usr/src/llvm/tools/clang/bindings/python/tests/test_exception_specification_kind.py",
 line 3, in 
  from .util import get_tu
  ImportError: No module named util

I presume that this patch meant to include the `util` module but you forgot to 
add the file. Could you fix that, please?




Comment at: 
cfe/trunk/bindings/python/tests/test_exception_specification_kind.py:3
+from clang.cindex import ExceptionSpecificationKind
+from .util import get_tu
+

It seems that the `util` module has never been committed.


Repository:
  rL LLVM

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-27 Thread Jonathan B Coe via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL306483: [libclang] Support for querying the exception 
specification type through… (authored by jbcoe).

Changed prior to commit:
  https://reviews.llvm.org/D34091?vs=102934=104301#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D34091

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

Index: cfe/trunk/tools/libclang/libclang.exports
===
--- cfe/trunk/tools/libclang/libclang.exports
+++ cfe/trunk/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: cfe/trunk/tools/libclang/CXType.cpp
===
--- cfe/trunk/tools/libclang/CXType.cpp
+++ cfe/trunk/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: cfe/trunk/tools/c-index-test/c-index-test.c
===
--- cfe/trunk/tools/c-index-test/c-index-test.c
+++ cfe/trunk/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: cfe/trunk/bindings/python/clang/cindex.py
===
--- cfe/trunk/bindings/python/clang/cindex.py
+++ cfe/trunk/bindings/python/clang/cindex.py
@@ -1367,6 +1367,30 @@
 TemplateArgumentKind.NULLPTR = TemplateArgumentKind(3)
 TemplateArgumentKind.INTEGRAL = TemplateArgumentKind(4)
 
+### Exception Specification Kinds ###
+class ExceptionSpecificationKind(BaseEnumeration):
+"""
+An ExceptionSpecificationKind describes the kind of exception specification
+that a function has.
+"""
+
+# The required BaseEnumeration declarations.
+_kinds = []
+_name_map = None
+
+def __repr__(self):
+return 'ExceptionSpecificationKind.{}'.format(self.name)
+
+ExceptionSpecificationKind.NONE = ExceptionSpecificationKind(0)
+ExceptionSpecificationKind.DYNAMIC_NONE = ExceptionSpecificationKind(1)
+ExceptionSpecificationKind.DYNAMIC = ExceptionSpecificationKind(2)
+ExceptionSpecificationKind.MS_ANY = ExceptionSpecificationKind(3)
+ExceptionSpecificationKind.BASIC_NOEXCEPT = ExceptionSpecificationKind(4)
+ExceptionSpecificationKind.COMPUTED_NOEXCEPT = ExceptionSpecificationKind(5)
+ExceptionSpecificationKind.UNEVALUATED = ExceptionSpecificationKind(6)
+ExceptionSpecificationKind.UNINSTANTIATED = ExceptionSpecificationKind(7)
+ExceptionSpecificationKind.UNPARSED = ExceptionSpecificationKind(8)
+
 ### Cursors ###
 
 class Cursor(Structure):
@@ -1587,6 +1611,18 @@
 return self._result_type
 
 @property
+def exception_specification_kind(self):
+'''
+

[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-26 Thread Jonathan B Coe via Phabricator via cfe-commits
jbcoe added a comment.

I can merge this for you Andrew.


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-26 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman accepted this revision.
aaron.ballman added a comment.
This revision is now accepted and ready to land.

LGTM!


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 Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang-c/Index.h:213
+  /**
+   * \brief The exception specification has not yet been evaluated
+   */

This comment is now missing the full-stop at the end of the sentence (you 
dropped one too many periods).



Comment at: tools/libclang/CXType.cpp:693
+
+if (const FunctionProtoType* FD = T->getAs()) {
+return static_cast(FD->getExceptionSpecType());

aaron.ballman wrote:
> Use `const auto *` and elide the braces.
You should run your patch through clang-format; the asterisk should bind to 
`FD` rather than `auto` and the indentation is too large in the patch.


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-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-14 Thread Aaron Ballman via Phabricator via cfe-commits
aaron.ballman added inline comments.



Comment at: include/clang-c/Index.h:185
+   */
+  CXCursor_ExceptionSpecificationKind_None, ///< no exception specification
+

You can drop the trailing comment.



Comment at: include/clang-c/Index.h:208
+  /**
+   * \brief The cursor has exception specification computed noexcept..
+   */

Spurious trailing full stop.



Comment at: include/clang-c/Index.h:213
+  /**
+   * \brief The exception specification has not yet been evaluated..
+   */

Same here.



Comment at: test/Index/get-cursor.cpp:152
+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(...);

The comment isn't helpful and can be removed.



Comment at: tools/libclang/CXType.cpp:689
+QualType T = GetQualType(X);
+if (T.isNull()) {
+return -1;

Can elide the braces.



Comment at: tools/libclang/CXType.cpp:693
+
+if (const FunctionProtoType* FD = T->getAs()) {
+return static_cast(FD->getExceptionSpecType());

Use `const auto *` and elide the braces.



Comment at: tools/libclang/CXType.cpp:695
+return static_cast(FD->getExceptionSpecType());
+} else {
+return -1;

No `else` after a `return`; you can just lower this into the function scope and 
remove the `else`.



Comment at: tools/libclang/CXType.cpp:703
+return clang_getExceptionSpecificationType(clang_getCursorType(C));
+} else {
+return -1;

No `else` after a `return` and can elide the braces for the `if`.


Repository:
  rL LLVM

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-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