This is an archive of the discontinued LLVM Phabricator instance.

[clang] [test] Narrow down an MSVC specific behaviour to only not covever MinGW
ClosedPublic

Authored by mstorsjo on May 29 2023, 1:19 PM.

Details

Summary

This uses the same logic as in c2b256a990590dc8b69930259650cfeb085add03;
we can't check defined(_MSC_VER) invoked as %clang_cc1, therefore
check for !defined(MINGW32) instead.

This fixes the same issue in a new testcase that was added after this
issue was fixed last time in c2b256a990590dc8b69930259650cfeb085add03.

Diff Detail

Event Timeline

mstorsjo created this revision.May 29 2023, 1:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2023, 1:19 PM
mstorsjo requested review of this revision.May 29 2023, 1:19 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 29 2023, 1:19 PM
Endill accepted this revision.May 29 2023, 11:40 PM

Thank you!
I've asked Aaron what is the best way to check for MSVC-like triple before relanding this test. So today we both learned.

This revision is now accepted and ready to land.May 29 2023, 11:40 PM

Thank you!
I've asked Aaron what is the best way to check for MSVC-like triple before relanding this test. So today we both learned.

Generally, the canonical way to check for it is #ifdef _MSC_VER - however in the %clang_cc1 tests, it's not automatically defined. This, because the driver heuristically tries to guess a MSVC version to mimic, which it then passes as a version number to clang -cc1 with -fms-compatibility-version or similar. When invoking clang -cc1 manually, this doesn't get set and _MSC_VER is undefined. (I'm considering changing code to make sure that _MSC_VER always is defined in such cases too, even to a dummy version number .)

Thank you!
I've asked Aaron what is the best way to check for MSVC-like triple before relanding this test. So today we both learned.

Generally, the canonical way to check for it is #ifdef _MSC_VER - however in the %clang_cc1 tests, it's not automatically defined. This, because the driver heuristically tries to guess a MSVC version to mimic, which it then passes as a version number to clang -cc1 with -fms-compatibility-version or similar. When invoking clang -cc1 manually, this doesn't get set and _MSC_VER is undefined.

Yes, I remember checking _MSC_VER and _MSC_FULL_VER, but they didn't work.

(I'm considering changing code to make sure that _MSC_VER always is defined in such cases too, even to a dummy version number .)

That would be fantastic for DR and conformance tests!