r317706 - [bindings] fix TLS test failure

Masud Rahman via cfe-commits cfe-commits at lists.llvm.org
Wed Nov 8 11:17:27 PST 2017


Author: frutiger
Date: Wed Nov  8 11:17:27 2017
New Revision: 317706

URL: http://llvm.org/viewvc/llvm-project?rev=317706&view=rev
Log:
[bindings] fix TLS test failure

Since cfe commit r237337, '__declspec(thread)' and 'thread_local' have
been the same since MSVC 2015.  i.e. they are both considered to supply
a dynamic TLS kind, not a static TLS kind.

This test originally did not specify which version of MS compatibility
to assume.  As a result, the test was brittle, since changing the
default compatibility version could break the test.

This commit adds a specific version when building up the flags used to
parse the translation unit, and tests both versions.

Modified:
    cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py

Modified: cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py?rev=317706&r1=317705&r2=317706&view=diff
==============================================================================
--- cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py (original)
+++ cfe/trunk/bindings/python/tests/cindex/test_tls_kind.py Wed Nov  8 11:17:27 2017
@@ -27,11 +27,21 @@ _Thread_local int tls_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']
+    flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32',
+             '-fms-compatibility-version=18']
     tu = get_tu("""
-__declspec(thread) int tls_declspec;
+__declspec(thread) int tls_declspec_msvc18;
 """, lang = 'cpp', flags=flags)
 
-    tls_declspec = get_cursor(tu.cursor, 'tls_declspec')
-    assert tls_declspec.tls_kind == TLSKind.STATIC
+    tls_declspec_msvc18 = get_cursor(tu.cursor, 'tls_declspec_msvc18')
+    assert tls_declspec_msvc18.tls_kind == TLSKind.STATIC
+
+    flags = ['-fms-extensions', '-target', 'x86_64-unknown-windows-win32',
+             '-fms-compatibility-version=19']
+    tu = get_tu("""
+__declspec(thread) int tls_declspec_msvc19;
+""", lang = 'cpp', flags=flags)
+
+    tls_declspec_msvc19 = get_cursor(tu.cursor, 'tls_declspec_msvc19')
+    assert tls_declspec_msvc19.tls_kind == TLSKind.DYNAMIC
 




More information about the cfe-commits mailing list