2 from clang
.cindex
import Config
4 if "CLANG_LIBRARY_PATH" in os
.environ
:
5 Config
.set_library_path(os
.environ
["CLANG_LIBRARY_PATH"])
7 from clang
.cindex
import TLSKind
8 from clang
.cindex
import Cursor
9 from clang
.cindex
import TranslationUnit
11 from .util
import get_cursor
12 from .util
import get_tu
17 class TestTLSKind(unittest
.TestCase
):
18 def test_tls_kind(self
):
19 """Ensure that thread-local storage kinds are available on cursors."""
24 thread_local int tls_dynamic;
25 _Thread_local int tls_static;
30 tls_none
= get_cursor(tu
.cursor
, "tls_none")
31 self
.assertEqual(tls_none
.tls_kind
, TLSKind
.NONE
)
33 tls_dynamic
= get_cursor(tu
.cursor
, "tls_dynamic")
34 self
.assertEqual(tls_dynamic
.tls_kind
, TLSKind
.DYNAMIC
)
36 tls_static
= get_cursor(tu
.cursor
, "tls_static")
37 self
.assertEqual(tls_static
.tls_kind
, TLSKind
.STATIC
)
39 # The following case tests '__declspec(thread)'. Since it is a Microsoft
40 # specific extension, specific flags are required for the parser to pick
45 "x86_64-unknown-windows-win32",
46 "-fms-compatibility-version=18",
50 __declspec(thread) int tls_declspec_msvc18;
56 tls_declspec_msvc18
= get_cursor(tu
.cursor
, "tls_declspec_msvc18")
57 self
.assertEqual(tls_declspec_msvc18
.tls_kind
, TLSKind
.STATIC
)
62 "x86_64-unknown-windows-win32",
63 "-fms-compatibility-version=19",
67 __declspec(thread) int tls_declspec_msvc19;
73 tls_declspec_msvc19
= get_cursor(tu
.cursor
, "tls_declspec_msvc19")
74 self
.assertEqual(tls_declspec_msvc19
.tls_kind
, TLSKind
.DYNAMIC
)