Skip to content

Commit

Permalink
Merge pull request #29 from RadeonOpenCompute/roc-1.6.1
Browse files Browse the repository at this point in the history
roc-1.6.1 updates
  • Loading branch information
kzhuravl authored Jul 27, 2017
2 parents e74fd5c + a53b26b commit 138c802
Show file tree
Hide file tree
Showing 444 changed files with 18,006 additions and 5,031 deletions.
46 changes: 45 additions & 1 deletion bindings/python/clang/cindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -782,7 +782,7 @@ def __repr__(self):
# A C++ template type parameter
CursorKind.TEMPLATE_TYPE_PARAMETER = CursorKind(27)

# A C++ non-type template paramater.
# A C++ non-type template parameter.
CursorKind.TEMPLATE_NON_TYPE_PARAMETER = CursorKind(28)

# A C++ template template parameter.
Expand Down Expand Up @@ -1367,6 +1367,30 @@ class TemplateArgumentKind(BaseEnumeration):
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):
Expand Down Expand Up @@ -1586,6 +1610,18 @@ def result_type(self):

return self._result_type

@property
def exception_specification_kind(self):
'''
Retrieve the exception specification kind, which is one of the values
from the ExceptionSpecificationKind enumeration.
'''
if not hasattr(self, '_exception_specification_kind'):
exc_kind = conf.lib.clang_getCursorExceptionSpecificationType(self)
self._exception_specification_kind = ExceptionSpecificationKind.from_id(exc_kind)

return self._exception_specification_kind

@property
def underlying_typedef_type(self):
"""Return the underlying type of a typedef declaration.
Expand Down Expand Up @@ -2254,6 +2290,14 @@ def visitor(field, children):
callbacks['fields_visit'](visitor), fields)
return iter(fields)

def get_exception_specification_kind(self):
"""
Return the kind of the exception specification; a value from
the ExceptionSpecificationKind enumeration.
"""
return ExceptionSpecificationKind.from_id(
conf.lib.clang.getExceptionSpecificationType(self))

@property
def spelling(self):
"""Retrieve the spelling of this Type."""
Expand Down
27 changes: 27 additions & 0 deletions bindings/python/tests/test_exception_specification_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import clang.cindex
from clang.cindex import ExceptionSpecificationKind
from .util import get_tu


def find_function_declarations(node, declarations=[]):
if node.kind == clang.cindex.CursorKind.FUNCTION_DECL:
declarations.append((node.spelling, node.exception_specification_kind))
for child in node.get_children():
declarations = find_function_declarations(child, declarations)
return declarations


def test_exception_specification_kind():
source = """int square1(int x);
int square2(int x) noexcept;
int square3(int x) noexcept(noexcept(x * x));"""

tu = get_tu(source, lang='cpp', flags=['-std=c++14'])

declarations = find_function_declarations(tu.cursor)
expected = [
('square1', ExceptionSpecificationKind.NONE),
('square2', ExceptionSpecificationKind.BASIC_NOEXCEPT),
('square3', ExceptionSpecificationKind.COMPUTED_NOEXCEPT)
]
assert declarations == expected
Loading

0 comments on commit 138c802

Please sign in to comment.