Skip to content

Commit

Permalink
Merge pull request #30 from RadeonOpenCompute/roc-1.6.4
Browse files Browse the repository at this point in the history
roc-1.6.4 updates
  • Loading branch information
kzhuravl authored Oct 30, 2017
2 parents 138c802 + 150e757 commit 55c41de
Show file tree
Hide file tree
Showing 1,557 changed files with 74,834 additions and 27,023 deletions.
32 changes: 21 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,16 @@ endif()
# we can include cmake files from this directory.
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake/modules")

find_package(LibXml2 2.5.3 QUIET)
if (LIBXML2_FOUND)
set(CLANG_HAVE_LIBXML 1)
# Don't look for libxml if we're using MSan, since uninstrumented third party
# code may call MSan interceptors like strlen, leading to false positives.
if(NOT LLVM_USE_SANITIZER MATCHES "Memory.*")
set (LIBXML2_FOUND 0)
find_package(LibXml2 2.5.3 QUIET)
if (LIBXML2_FOUND)
set(CLANG_HAVE_LIBXML 1)
endif()
endif()

find_package(Z3 4.5)

include(CheckIncludeFile)
check_include_file(sys/resource.h CLANG_HAVE_RLIMITS)

Expand Down Expand Up @@ -376,11 +379,14 @@ option(CLANG_ENABLE_STATIC_ANALYZER "Build static analyzer." ON)
option(CLANG_ANALYZER_BUILD_Z3
"Build the static analyzer with the Z3 constraint manager." OFF)

option(CLANG_ENABLE_PROTO_FUZZER "Build Clang protobuf fuzzer." OFF)

if(NOT CLANG_ENABLE_STATIC_ANALYZER AND (CLANG_ENABLE_ARCMT OR CLANG_ANALYZER_BUILD_Z3))
message(FATAL_ERROR "Cannot disable static analyzer while enabling ARCMT or Z3")
endif()

if(CLANG_ANALYZER_BUILD_Z3)
find_package(Z3 4.5)
if(Z3_FOUND)
set(CLANG_ANALYZER_WITH_Z3 1)
else()
Expand All @@ -389,11 +395,7 @@ if(CLANG_ANALYZER_BUILD_Z3)
endif()

if(CLANG_ENABLE_ARCMT)
add_definitions(-DCLANG_ENABLE_ARCMT)
add_definitions(-DCLANG_ENABLE_OBJC_REWRITER)
endif()
if(CLANG_ENABLE_STATIC_ANALYZER)
add_definitions(-DCLANG_ENABLE_STATIC_ANALYZER)
set(CLANG_ENABLE_OBJC_REWRITER ON)
endif()

# Clang version information
Expand All @@ -415,7 +417,15 @@ add_subdirectory(include)

# All targets below may depend on all tablegen'd files.
get_property(CLANG_TABLEGEN_TARGETS GLOBAL PROPERTY CLANG_TABLEGEN_TARGETS)
list(APPEND LLVM_COMMON_DEPENDS ${CLANG_TABLEGEN_TARGETS})
add_custom_target(clang-tablegen-targets DEPENDS ${CLANG_TABLEGEN_TARGETS})
list(APPEND LLVM_COMMON_DEPENDS clang-tablegen-targets)

# Force target to be built as soon as possible. Clang modules builds depend
# header-wise on it as they ship all headers from the umbrella folders. Building
# an entire module might include header, which depends on intrinsics_gen.
if(LLVM_ENABLE_MODULES AND NOT CLANG_BUILT_STANDALONE)
list(APPEND LLVM_COMMON_DEPENDS intrinsics_gen)
endif()

add_subdirectory(lib)
add_subdirectory(tools)
Expand Down
1 change: 1 addition & 0 deletions README.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ on the Clang development mailing list:

If you find a bug in Clang, please file it in the LLVM bug tracker:
http://llvm.org/bugs/

72 changes: 67 additions & 5 deletions bindings/python/clang/cindex.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ def __del__(self):
conf.lib.clang_disposeString(self)

@staticmethod
def from_result(res, fn, args):
def from_result(res, fn=None, args=None):
assert isinstance(res, _CXString)
return conf.lib.clang_getCString(res)

Expand Down Expand Up @@ -459,8 +459,7 @@ def disable_option(self):
"""The command-line option that disables this diagnostic."""
disable = _CXString()
conf.lib.clang_getDiagnosticOption(self, byref(disable))

return conf.lib.clang_getCString(disable)
return _CXString.from_result(disable)

def format(self, options=None):
"""
Expand All @@ -473,8 +472,7 @@ def format(self, options=None):
options = conf.lib.clang_defaultDiagnosticDisplayOptions()
if options & ~Diagnostic._FormatOptionsMask:
raise ValueError('Invalid format options')
formatted = conf.lib.clang_formatDiagnostic(self, options)
return conf.lib.clang_getCString(formatted)
return conf.lib.clang_formatDiagnostic(self, options)

def __repr__(self):
return "<Diagnostic severity %r, location %r, spelling %r>" % (
Expand Down Expand Up @@ -1478,6 +1476,11 @@ def is_virtual_method(self):
"""
return conf.lib.clang_CXXMethod_isVirtual(self)

def is_scoped_enum(self):
"""Returns True if the cursor refers to a scoped enum declaration.
"""
return conf.lib.clang_EnumDecl_isScoped(self)

def get_definition(self):
"""
If the cursor is a reference to a declaration or a declaration of
Expand Down Expand Up @@ -1545,6 +1548,22 @@ def location(self):

return self._loc

@property
def linkage(self):
"""Return the linkage of this cursor."""
if not hasattr(self, '_linkage'):
self._linkage = conf.lib.clang_getCursorLinkage(self)

return LinkageKind.from_id(self._linkage)

@property
def tls_kind(self):
"""Return the thread-local storage (TLS) kind of this cursor."""
if not hasattr(self, '_tls_kind'):
self._tls_kind = conf.lib.clang_getCursorTLSKind(self)

return TLSKind.from_id(self._tls_kind)

@property
def extent(self):
"""
Expand Down Expand Up @@ -2058,6 +2077,42 @@ def __repr__(self):
RefQualifierKind.LVALUE = RefQualifierKind(1)
RefQualifierKind.RVALUE = RefQualifierKind(2)

class LinkageKind(BaseEnumeration):
"""Describes the kind of linkage of a cursor."""

# The unique kind objects, indexed by id.
_kinds = []
_name_map = None

def from_param(self):
return self.value

def __repr__(self):
return 'LinkageKind.%s' % (self.name,)

LinkageKind.INVALID = LinkageKind(0)
LinkageKind.NO_LINKAGE = LinkageKind(1)
LinkageKind.INTERNAL = LinkageKind(2)
LinkageKind.UNIQUE_EXTERNAL = LinkageKind(3)
LinkageKind.EXTERNAL = LinkageKind(4)

class TLSKind(BaseEnumeration):
"""Describes the kind of thread-local storage (TLS) of a cursor."""

# The unique kind objects, indexed by id.
_kinds = []
_name_map = None

def from_param(self):
return self.value

def __repr__(self):
return 'TLSKind.%s' % (self.name,)

TLSKind.NONE = TLSKind(0)
TLSKind.DYNAMIC = TLSKind(1)
TLSKind.STATIC = TLSKind(2)

class Type(Structure):
"""
The type of an element in the abstract syntax tree.
Expand Down Expand Up @@ -3188,6 +3243,7 @@ def extent(self):
def cursor(self):
"""The Cursor this Token corresponds to."""
cursor = Cursor()
cursor._tu = self._tu

conf.lib.clang_annotateTokens(self._tu, byref(self), 1, byref(cursor))

Expand Down Expand Up @@ -3314,6 +3370,10 @@ def cursor(self):
[Cursor],
bool),

("clang_EnumDecl_isScoped",
[Cursor],
bool),

("clang_defaultDiagnosticDisplayOptions",
[],
c_uint),
Expand Down Expand Up @@ -4057,8 +4117,10 @@ def register_enumerations():
'File',
'FixIt',
'Index',
'LinkageKind',
'SourceLocation',
'SourceRange',
'TLSKind',
'TokenKind',
'Token',
'TranslationUnitLoadError',
Expand Down
38 changes: 38 additions & 0 deletions bindings/python/tests/cindex/test_cursor.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,22 @@ def test_is_virtual_method():
assert foo.is_virtual_method()
assert not bar.is_virtual_method()

def test_is_scoped_enum():
"""Ensure Cursor.is_scoped_enum works."""
source = 'class X {}; enum RegularEnum {}; enum class ScopedEnum {};'
tu = get_tu(source, lang='cpp')

cls = get_cursor(tu, 'X')
regular_enum = get_cursor(tu, 'RegularEnum')
scoped_enum = get_cursor(tu, 'ScopedEnum')
assert cls is not None
assert regular_enum is not None
assert scoped_enum is not None

assert not cls.is_scoped_enum()
assert not regular_enum.is_scoped_enum()
assert scoped_enum.is_scoped_enum()

def test_underlying_type():
tu = get_tu('typedef int foo;')
typedef = get_cursor(tu, 'foo')
Expand Down Expand Up @@ -379,6 +395,28 @@ def test_get_tokens():
assert tokens[0].spelling == 'int'
assert tokens[1].spelling == 'foo'

def test_get_token_cursor():
"""Ensure we can map tokens to cursors."""
tu = get_tu('class A {}; int foo(A var = A());', lang='cpp')
foo = get_cursor(tu, 'foo')

for cursor in foo.walk_preorder():
if cursor.kind.is_expression() and not cursor.kind.is_statement():
break
else:
assert False, "Could not find default value expression"

tokens = list(cursor.get_tokens())
assert len(tokens) == 4, [t.spelling for t in tokens]
assert tokens[0].spelling == '='
assert tokens[1].spelling == 'A'
assert tokens[2].spelling == '('
assert tokens[3].spelling == ')'
t_cursor = tokens[1].cursor
assert t_cursor.kind == CursorKind.TYPE_REF
r_cursor = t_cursor.referenced # should not raise an exception
assert r_cursor.kind == CursorKind.CLASS_DECL

def test_get_arguments():
tu = get_tu('void foo(int i, int j);')
foo = get_cursor(tu, 'foo')
Expand Down
8 changes: 8 additions & 0 deletions bindings/python/tests/cindex/test_diagnostics.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,3 +92,11 @@ def test_diagnostic_children():
assert children[0].spelling.endswith('declared here')
assert children[0].location.line == 1
assert children[0].location.column == 1

def test_diagnostic_string_repr():
tu = get_tu('struct MissingSemicolon{}')
assert len(tu.diagnostics) == 1
d = tu.diagnostics[0]

assert repr(d) == '<Diagnostic severity 3, location <SourceLocation file \'t.c\', line 1, column 26>, spelling "expected \';\' after struct">'

30 changes: 30 additions & 0 deletions bindings/python/tests/cindex/test_linkage.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

from clang.cindex import LinkageKind
from clang.cindex import Cursor
from clang.cindex import TranslationUnit

from .util import get_cursor
from .util import get_tu

def test_linkage():
"""Ensure that linkage specifers are available on cursors"""

tu = get_tu("""
void foo() { int no_linkage; }
static int internal;
namespace { extern int unique_external; }
extern int external;
""", lang = 'cpp')

no_linkage = get_cursor(tu.cursor, 'no_linkage')
assert no_linkage.linkage == LinkageKind.NO_LINKAGE;

internal = get_cursor(tu.cursor, 'internal')
assert internal.linkage == LinkageKind.INTERNAL

unique_external = get_cursor(tu.cursor, 'unique_external')
assert unique_external.linkage == LinkageKind.UNIQUE_EXTERNAL

external = get_cursor(tu.cursor, 'external')
assert external.linkage == LinkageKind.EXTERNAL

37 changes: 37 additions & 0 deletions bindings/python/tests/cindex/test_tls_kind.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

from clang.cindex import TLSKind
from clang.cindex import Cursor
from clang.cindex import TranslationUnit

from .util import get_cursor
from .util import get_tu

def test_tls_kind():
"""Ensure that thread-local storage kinds are available on cursors."""

tu = get_tu("""
int tls_none;
thread_local int tls_dynamic;
_Thread_local int tls_static;
""", lang = 'cpp')

tls_none = get_cursor(tu.cursor, 'tls_none')
assert tls_none.tls_kind == TLSKind.NONE;

tls_dynamic = get_cursor(tu.cursor, 'tls_dynamic')
assert tls_dynamic.tls_kind == TLSKind.DYNAMIC

tls_static = get_cursor(tu.cursor, 'tls_static')
assert tls_static.tls_kind == TLSKind.STATIC

# The following case tests '__declspec(thread)'. Since it is a Microsoft
# specific extension, specific flags are required for the parser to pick
# these up.
flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32']
tu = get_tu("""
__declspec(thread) int tls_declspec;
""", lang = 'cpp', flags=flags)

tls_declspec = get_cursor(tu.cursor, 'tls_declspec')
assert tls_declspec.tls_kind == TLSKind.STATIC

52 changes: 52 additions & 0 deletions cmake/caches/Android-stage2.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
set(LLVM_TARGETS_TO_BUILD X86;ARM;AArch64 CACHE STRING "")

set(CLANG_VENDOR Android CACHE STRING "")
set(CMAKE_BUILD_TYPE Release CACHE STRING "")
set(LLVM_ENABLE_THREADS OFF CACHE BOOL "")
set(LLVM_ENABLE_ASSERTIONS ON CACHE BOOL "")
set(LLVM_LIBDIR_SUFFIX 64 CACHE STRING "")
set(LLVM_ENABLE_LIBCXX ON CACHE BOOL "")

set(ANDROID_RUNTIMES_ENABLE_ASSERTIONS ON CACHE BOOL "")
set(ANDROID_RUNTIMES_BUILD_TYPE Release CACHE STRING "")
set(ANDROID_BUILTINS_BUILD_TYPE Release CACHE STRING "")

set(LLVM_BUILTIN_TARGETS "i686-linux-android;x86_64-linux-android;aarch64-linux-android;armv7-linux-android" CACHE STRING "")
foreach(target i686;x86_64;aarch64;armv7)
set(BUILTINS_${target}-linux-android_ANDROID 1 CACHE STRING "")
set(BUILTINS_${target}-linux-android_CMAKE_BUILD_TYPE ${ANDROID_BUILTINS_BUILD_TYPE} CACHE STRING "")
set(BUILTINS_${target}-linux-android_CMAKE_ASM_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
set(BUILTINS_${target}-linux-android_CMAKE_C_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
set(BUILTINS_${target}-linux-android_CMAKE_SYSROOT ${ANDROID_${target}_SYSROOT} CACHE PATH "")
set(BUILTINS_${target}-linux-android_CMAKE_EXE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
set(BUILTINS_${target}-linux-android_CMAKE_SHARED_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
set(BUILTINS_${target}-linux-android_CMAKE_MOUDLE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
endforeach()


set(LLVM_RUNTIME_TARGETS "i686-linux-android;x86_64-linux-android;aarch64-linux-android;armv7-linux-android" CACHE STRING "")
foreach(target i686;x86_64;aarch64;armv7)
set(RUNTIMES_${target}-linux-android_ANDROID 1 CACHE STRING "")
set(RUNTIMES_${target}-linux-android_CMAKE_ASM_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_BUILD_TYPE ${ANDROID_RUNTIMES_BUILD_TYPE} CACHE STRING "")
set(RUNTIMES_${target}-linux-android_CMAKE_C_FLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_CXX_FLAGS ${ANDROID_${target}_CXX_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_SYSROOT ${ANDROID_${target}_SYSROOT} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_EXE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_SHARED_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_CMAKE_MODULE_LINKER_FLAGS ${ANDROID_${target}_LINKER_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_COMPILER_RT_ENABLE_WERROR ON CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_COMPILER_RT_TEST_COMPILER_CFLAGS ${ANDROID_${target}_C_FLAGS} CACHE PATH "")
set(RUNTIMES_${target}-linux-android_COMPILER_RT_INCLUDE_TESTS OFF CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_ASSERTIONS ${ANDROID_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_LIBCXX ON CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LLVM_ENABLE_THREADS OFF CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LLVM_INCLUDE_TESTS OFF CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LIBCXX_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LIBUNWIND_HAS_NO_EXCEPTIONS_FLAG ON CACHE BOOL "")
set(RUNTIMES_${target}-linux-android_LIBUNWIND_HAS_FUNWIND_TABLES ON CACHE BOOL "")
endforeach()

set(RUNTIMES_armv7-linux-android_LIBCXXABI_USE_LLVM_UNWINDER ON CACHE BOOL "")

Loading

0 comments on commit 55c41de

Please sign in to comment.