Skip to content

Commit b47f06e

Browse files
authored
Merge pull request #21 from schweitzpgi/master
merge the latest LLVM master branch changes
2 parents ad859d2 + d54efe3 commit b47f06e

File tree

1,599 files changed

+56941
-33030
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

1,599 files changed

+56941
-33030
lines changed

bindings/python/clang/cindex.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,12 @@ def get_usr(self):
15111511
another translation unit."""
15121512
return conf.lib.clang_getCursorUSR(self)
15131513

1514+
def get_included_file(self):
1515+
"""Returns the File that is included by the current inclusion cursor."""
1516+
assert self.kind == CursorKind.INCLUSION_DIRECTIVE
1517+
1518+
return conf.lib.clang_getIncludedFile(self)
1519+
15141520
@property
15151521
def kind(self):
15161522
"""Return the kind of this cursor."""
@@ -1644,7 +1650,7 @@ def canonical(self):
16441650
def result_type(self):
16451651
"""Retrieve the Type of the result for this Cursor."""
16461652
if not hasattr(self, '_result_type'):
1647-
self._result_type = conf.lib.clang_getResultType(self.type)
1653+
self._result_type = conf.lib.clang_getCursorResultType(self)
16481654

16491655
return self._result_type
16501656

@@ -3085,8 +3091,9 @@ def __repr__(self):
30853091
return "<File: %s>" % (self.name)
30863092

30873093
@staticmethod
3088-
def from_cursor_result(res, fn, args):
3089-
assert isinstance(res, File)
3094+
def from_result(res, fn, args):
3095+
assert isinstance(res, c_object_p)
3096+
res = File(res)
30903097

30913098
# Copy a reference to the TranslationUnit to prevent premature GC.
30923099
res._tu = args[0]._tu
@@ -3568,6 +3575,11 @@ def cursor(self):
35683575
[Cursor, c_uint, c_uint],
35693576
SourceRange),
35703577

3578+
("clang_getCursorResultType",
3579+
[Cursor],
3580+
Type,
3581+
Type.from_result),
3582+
35713583
("clang_getCursorSemanticParent",
35723584
[Cursor],
35733585
Cursor,
@@ -3696,8 +3708,8 @@ def cursor(self):
36963708

36973709
("clang_getIncludedFile",
36983710
[Cursor],
3699-
File,
3700-
File.from_cursor_result),
3711+
c_object_p,
3712+
File.from_result),
37013713

37023714
("clang_getInclusions",
37033715
[TranslationUnit, callbacks['translation_unit_includes'], py_object]),

bindings/python/tests/cindex/test_cursor.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -429,6 +429,18 @@ def test_result_type(self):
429429
t = foo.result_type
430430
self.assertEqual(t.kind, TypeKind.INT)
431431

432+
def test_result_type_objc_method_decl(self):
433+
code = """\
434+
@interface Interface : NSObject
435+
-(void)voidMethod;
436+
@end
437+
"""
438+
tu = get_tu(code, lang='objc')
439+
cursor = get_cursor(tu, 'voidMethod')
440+
result_type = cursor.result_type
441+
self.assertEqual(cursor.kind, CursorKind.OBJC_INSTANCE_METHOD_DECL)
442+
self.assertEqual(result_type.kind, TypeKind.VOID)
443+
432444
def test_availability(self):
433445
tu = get_tu('class A { A(A const&) = delete; };', lang='cpp')
434446

bindings/python/tests/cindex/test_translation_unit.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,18 @@ def eq(expected, actual):
108108
for i in zip(inc, tu.get_includes()):
109109
eq(i[0], i[1])
110110

111+
def test_inclusion_directive(self):
112+
src = os.path.join(kInputsDir, 'include.cpp')
113+
h1 = os.path.join(kInputsDir, "header1.h")
114+
h2 = os.path.join(kInputsDir, "header2.h")
115+
h3 = os.path.join(kInputsDir, "header3.h")
116+
inc = [h1, h3, h2, h3, h1]
117+
118+
tu = TranslationUnit.from_source(src, options=TranslationUnit.PARSE_DETAILED_PROCESSING_RECORD)
119+
inclusion_directive_files = [c.get_included_file().name for c in tu.cursor.get_children() if c.kind == CursorKind.INCLUSION_DIRECTIVE]
120+
for i in zip(inc, inclusion_directive_files):
121+
self.assert_normpaths_equal(i[0], i[1])
122+
111123
def test_save(self):
112124
"""Ensure TranslationUnit.save() works."""
113125

cmake/caches/Fuchsia-stage2.cmake

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -27,27 +27,29 @@ set(CMAKE_BUILD_TYPE RelWithDebInfo CACHE STRING "")
2727
set(CMAKE_C_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
2828
set(CMAKE_CXX_FLAGS_RELWITHDEBINFO "-O3 -gline-tables-only -DNDEBUG" CACHE STRING "")
2929

30+
set(FUCHSIA_BUILTINS_BUILD_TYPE Release CACHE STRING "")
31+
set(FUCHSIA_RUNTIMES_BUILD_TYPE Release CACHE STRING "")
32+
set(FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS ON CACHE BOOL "")
33+
3034
set(LLVM_BUILTIN_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia" CACHE STRING "")
3135

3236
# Set the per-target builtins options.
3337
foreach(target x86_64;aarch64)
34-
set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
3538
set(BUILTINS_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
39+
set(BUILTINS_${target}-fuchsia_CMAKE_BUILD_TYPE ${FUCHSIA_BUILTINS_BUILD_TYPE} CACHE STRING "")
40+
set(BUILTINS_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} CACHE PATH "")
41+
set(BUILTINS_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} CACHE PATH "")
42+
set(BUILTINS_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
43+
set(BUILTINS_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
44+
set(BUILTINS_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
45+
set(BUILTINS_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
46+
set(BUILTINS_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
3647
endforeach()
3748

3849
set(LLVM_RUNTIME_TARGETS "default;x86_64-fuchsia;aarch64-fuchsia;x86_64-fuchsia-asan:x86_64-fuchsia;aarch64-fuchsia-asan:aarch64-fuchsia" CACHE STRING "")
3950

4051
# Set the default target runtimes options.
41-
if(APPLE)
42-
# Disable installing libc++, libc++abi or libunwind on Darwin, since Clang
43-
# driver doesn't know how to use libraries that are part of the toolchain.
44-
set(LIBUNWIND_INSTALL_HEADERS OFF CACHE BOOL "")
45-
set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
46-
set(LIBCXXABI_INSTALL_HEADERS OFF CACHE BOOL "")
47-
set(LIBCXXABI_INSTALL_LIBRARY OFF CACHE BOOL "")
48-
set(LIBCXX_INSTALL_HEADERS OFF CACHE BOOL "")
49-
set(LIBCXX_INSTALL_LIBRARY OFF CACHE BOOL "")
50-
else()
52+
if(NOT APPLE)
5153
set(LIBUNWIND_ENABLE_SHARED OFF CACHE BOOL "")
5254
set(LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
5355
set(LIBUNWIND_INSTALL_LIBRARY OFF CACHE BOOL "")
@@ -63,10 +65,17 @@ endif()
6365

6466
# Set the per-target runtimes options.
6567
foreach(target x86_64;aarch64)
66-
set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE BOOL "")
67-
set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
6868
set(RUNTIMES_${target}-fuchsia_CMAKE_SYSTEM_NAME Fuchsia CACHE STRING "")
69-
set(RUNTIMES_${target}-fuchsia_UNIX 1 CACHE BOOL "")
69+
set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_TYPE ${FUCHSIA_RUNTIMES_BUILD_TYPE} CACHE STRING "")
70+
set(RUNTIMES_${target}-fuchsia_CMAKE_BUILD_WITH_INSTALL_RPATH ON CACHE STRING "")
71+
set(RUNTIMES_${target}-fuchsia_CMAKE_ASM_FLAGS ${FUCHSIA_${target}_C_FLAGS} CACHE PATH "")
72+
set(RUNTIMES_${target}-fuchsia_CMAKE_C_FLAGS ${FUCHSIA_${target}_C_FLAGS} CACHE PATH "")
73+
set(RUNTIMES_${target}-fuchsia_CMAKE_CXX_FLAGS ${FUCHSIA_${target}_CXX_FLAGS} CACHE PATH "")
74+
set(RUNTIMES_${target}-fuchsia_CMAKE_EXE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
75+
set(RUNTIMES_${target}-fuchsia_CMAKE_SHARED_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
76+
set(RUNTIMES_${target}-fuchsia_CMAKE_MODULE_LINKER_FLAGS ${FUCHSIA_${target}_LINKER_FLAGS} CACHE PATH "")
77+
set(RUNTIMES_${target}-fuchsia_CMAKE_SYSROOT ${FUCHSIA_${target}_SYSROOT} CACHE PATH "")
78+
set(RUNTIMES_${target}-fuchsia_LLVM_ENABLE_ASSERTIONS ${FUCHSIA_RUNTIMES_ENABLE_ASSERTIONS} CACHE BOOL "")
7079
set(RUNTIMES_${target}-fuchsia_LIBUNWIND_USE_COMPILER_RT ON CACHE BOOL "")
7180
set(RUNTIMES_${target}-fuchsia_LIBUNWIND_ENABLE_STATIC OFF CACHE BOOL "")
7281
set(RUNTIMES_${target}-fuchsia_LIBCXXABI_USE_COMPILER_RT ON CACHE BOOL "")
@@ -100,6 +109,7 @@ set(LLVM_TOOLCHAIN_TOOLS
100109
llvm-readelf
101110
llvm-readobj
102111
llvm-size
112+
llvm-strip
103113
llvm-symbolizer
104114
opt
105115
sancov

cmake/caches/Fuchsia.cmake

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,11 @@ set(CLANG_BOOTSTRAP_TARGETS
4040
install-distribution
4141
clang CACHE STRING "")
4242

43-
foreach(target x86_64;aarch64)
44-
if(FUCHSIA_${target}_SYSROOT)
45-
list(APPEND EXTRA_ARGS -DFUCHSIA_${target}_SYSROOT=${FUCHSIA_${target}_SYSROOT})
43+
get_cmake_property(variableNames VARIABLES)
44+
foreach(variableName ${variableNames})
45+
if(variableName MATCHES "^STAGE2_")
46+
string(REPLACE "STAGE2_" "" new_name ${variableName})
47+
list(APPEND EXTRA_ARGS "-D${new_name}=${${variableName}}")
4648
endif()
4749
endforeach()
4850

0 commit comments

Comments
 (0)