hans added inline comments.
================ Comment at: clang/test/Driver/cl-zc.cpp:98 // thread safe statics are off for versions < 19. // RUN: %clang_cl /c -### -fms-compatibility-version=18 -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s // RUN: %clang_cl /Zc:threadSafeInit /Zc:threadSafeInit- /c -### -- %s 2>&1 | FileCheck -check-prefix=NoThreadSafeStatics %s ---------------- steplong wrote: > This line will fail, but I can't find any documentation on thread safe > statics being off for versions < 19. > https://docs.microsoft.com/en-us/cpp/build/reference/zc-threadsafeinit-thread-safe-local-static-initialization?view=msvc-170 > says Visual Studio 2015 implements this by default. VS 2015 has _MSC_VER 1900. The test was added here: https://github.com/llvm/llvm-project/commit/c371ff048df8731052976f4e628ed1861cf61cfd and I assume David verified locally that 19 is the real cutoff. I just tested locally with VS 2013, and it is indeed off there ``` C:\src\tmp>type a.cc && cl -c a.cc && dumpbin /disasm a.obj int g(); int f() { static int x = g(); return x; } Microsoft (R) C/C++ Optimizing Compiler Version 18.00.31101 for x86 Copyright (C) Microsoft Corporation. All rights reserved. a.cc Microsoft (R) COFF/PE Dumper Version 12.00.31101.0 Copyright (C) Microsoft Corporation. All rights reserved. Dump of file a.obj File Type: COFF OBJECT ?f@@YAHXZ (int __cdecl f(void)): 00000000: 55 push ebp 00000001: 8B EC mov ebp,esp 00000003: A1 00 00 00 00 mov eax,dword ptr [?$S1@?1??f@@YAHXZ@4IA] 00000008: 83 E0 01 and eax,1 0000000B: 75 19 jne 00000026 0000000D: 8B 0D 00 00 00 00 mov ecx,dword ptr [?$S1@?1??f@@YAHXZ@4IA] 00000013: 83 C9 01 or ecx,1 00000016: 89 0D 00 00 00 00 mov dword ptr [?$S1@?1??f@@YAHXZ@4IA],ecx 0000001C: E8 00 00 00 00 call ?g@@YAHXZ 00000021: A3 00 00 00 00 mov dword ptr [?x@?1??f@@YAHXZ@4HA],eax 00000026: A1 00 00 00 00 mov eax,dword ptr [?x@?1??f@@YAHXZ@4HA] 0000002B: 5D pop ebp 0000002C: C3 ret Summary 8 .bss 64 .debug$S 2F .drectve 2D .text$mn ``` ================ Comment at: clang/tools/driver/driver.cpp:237 +static void insertDefaultClangCLZcConformanceArgs( + SmallVectorImpl<const char *> &ArgVector) { ---------------- Instead of injecting flags like this which seems a bit crude and won't work in non-clang-cl mode, can't we just enable these features keyed off the MSVC version like we already do for e.g. thread-safe statics? Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D127641/new/ https://reviews.llvm.org/D127641 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits