[PATCH] D149997: [clang] [test] Narrow down MSVC specific behaviours from "any windows" to only MSVC/clang-cl

Reid Kleckner via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Fri May 12 10:21:19 PDT 2023


rnk added a comment.

In D149997#4337548 <https://reviews.llvm.org/D149997#4337548>, @mstorsjo wrote:

> So, the reason why this failed, is that when invoked as `%clang_cc1` in a MSVC/clang-cl style build, `_MSC_VER` isn't predefined, while `_WIN32` is. When invoked via the Clang driver instead of directly going at `-cc1`, `_MSC_VER` does get defined.
>
> @rnk @hans @thakis - who know the intricacies of the MSVC target - do you happen to know why that is? How do I distinguish between MSVC-style behaviour and other cases (in particular, mingw) in a `%clang_cc1` test? Currently it uses `#idef _WIN32` but that's incorrect for mingw.

I think `_MSC_EXTENSIONS` will work, but it's kind of gross. `_MSC_VER` is controlled by `-fms-compatibility-verson=`, which I think is off by default or unset at the cc1 level:
https://github.com/llvm/llvm-project/blob/main/clang/lib/Basic/Targets/OSTargets.cpp#L206
`-fms-extensions` is on by default at cc1, I think.

This isn't great. It would be nice to have some kind of feature test mechanism for "which C++ ABI am I using, Itanium, one of the variants, or Microsoft".


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149997/new/

https://reviews.llvm.org/D149997



More information about the cfe-commits mailing list