VS2015 Update 3 type_traits Header Issues

I upgraded my install of VS2015 to VS2015 Update 3 and it appears to have broken the ability of an in-house tool that is based on Clang to parse type_traits. It appears that is_assignable is now implemented in terms of an intrinsic named __is_assignable. Is there a work around or a fix for this?

From Microsoft’s implementation of type_traits:

// TEMPLATE CLASS is_assignable
template<class _To,
class _From>
struct is_assignable
: integral_constant<bool, __is_assignable(_To, _From)>
{ // determine whether _From can be assigned to _To
};

When I parse a file that include type_traits indirectly I get the following errors:

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(524,45): error : ‘_To’ does not refer to a value
: integral_constant<bool, __is_assignable(_To, _From)>
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(521,16) : note: declared here
template<class _To,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(524,50): error : ‘_From’ does not refer to a value
: integral_constant<bool, __is_assignable(_To, _From)>
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(522,8) : note: declared here
class _From>
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits(525,2): error : expected class name
{ // determine whether _From can be assigned to _To
^
3 errors generated.

Yes, David implemented support in Clang r270458.

Cheers,
Hans

I am now building my tool against trunk. I am seeing the following errors, which I had a long time ago and I seem to remember that the tool had to know about where the Clang build copied certain files. Is there some other project that needs to be built to make this work? I have already set clang-headers as a dependency.

CUSTOMBUILD : warning : unknown argument ignored in clang-cl: ‘-resource-dir=D:\Some\Directory\lib\clang\3.9.0’
CUSTOMBUILD : warning : unknown argument ignored in clang-cl: ‘-resource-dir=D:\Some\Directory\lib\clang\3.9.0’
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\string:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\istream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ostream:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\ios:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocnum:10:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\streambuf:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xiosbase:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xlocale:8:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\stdexcept:7:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstring:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xmemory0:1151:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\intrin.h:24:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(776,28): error : invalid token in macro parameter list
#define _mm256_loadu2_m128(/* float const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(780,29): error : invalid token in macro parameter list
#define _mm256_loadu2_m128d(/
double const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(784,29): error : invalid token in macro parameter list
#define _mm256_loadu2_m128i(/
__m128i const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(794,29): error : invalid token in macro parameter list
#define _mm256_storeu2_m128(/
float* / hiaddr, / float* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(802,30): error : invalid token in macro parameter list
#define _mm256_storeu2_m128d(/
double* / hiaddr, / double* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(810,30): error : invalid token in macro parameter list
#define _mm256_storeu2_m128i(/
__m128i* / hiaddr, / __m128i* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1129,25): error : invalid token in macro parameter list
#define _mm256_set_m128(/
__m128 / hi, / __m128 / lo)
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1132,26): error : invalid token in macro parameter list
#define _mm256_set_m128d(/
__m128d / hi, / __m128d / lo)
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1135,26): error : invalid token in macro parameter list
#define _mm256_set_m128i(/
__m128i / hi, / __m128i */ lo)
^
9 errors generated.

This looks like the problem. I don't know where this flag is coming
from, but does it work better if you remove the '='?

My command line roughly looks like this:
MyTool.exe D:\Source1.cpp D:\Source2.cpp – --driver-mode=cl -Wno-c99-extensions -Wno-microsoft-enum-value -Wno-undefined-internal -fms-compatibility-version=19 -EHsc

My code to parse the command line arguments is this:
CommonOptionsParser optionsParser(argc, const_cast<const char**>(argv), gMyToolCategory);

The only places where the code mentions -resource-dir are in Clang or LLVM code.

I am uncertain on how to proceed with this. immintrin.h (as provided by clang) is in the directory specified by -resource-dir. In order for clang (and tools based on it) to handle the Windows header files, it must use these files or you get lots of errors parsing Microsoft’s standard library implementation.

Since the -resource-dir flag doesn’t appear to be valid anymore (but is still generated by clang), what is the method to cause clang to use the files in this directory?

I didn’t think -resource-dir was a driver option, it’s a -cc1 option. I’m not sure how to set it in the context of a clang tool, but there should be a way to get it through. Worst case you can use -Xclang.

That sounds reasonable, but the tool is generating the -resource-dir argument. I am processing command line arguments using:

CommonOptionsParser optionsParser(argc, const_cast<const char**>(argv), gMyToolCategory);

I never pass -resource-dir to the tool. My code works (other than when using VS2015 Update 3) when it is built against Clang 3.8.0.

This is still causing me problems. My tool works fine when compiled against Clang 3.8.0 and running against the VS2013 libraries.

When I attempt to run against the VS2015 libraries it fails. Support for the particular built-in that fails was added to 3.9.0, but when I attempt to compile against Clang 3.9.0 and run against the VS2015 libraries I get the following errors:

warning: unknown argument ignored in clang-cl: ‘-resource-dir=C:\MyTool\Debug..\lib\clang\4.0.0’

C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(776,28): error: invalid token in macro
parameter list
#define _mm256_loadu2_m128(/* float const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(780,29): error: invalid token in macro
parameter list
#define _mm256_loadu2_m128d(/
double const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(784,29): error: invalid token in macro
parameter list
#define _mm256_loadu2_m128i(/
__m128i const* / hiaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(794,29): error: invalid token in macro
parameter list
#define _mm256_storeu2_m128(/
float* / hiaddr, / float* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(802,30): error: invalid token in macro
parameter list
#define _mm256_storeu2_m128d(/
double* / hiaddr, / double* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(810,30): error: invalid token in macro
parameter list
#define _mm256_storeu2_m128i(/
__m128i* / hiaddr, / __m128i* / loaddr,
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1129,25): error: invalid token in macro
parameter list
#define _mm256_set_m128(/
__m128 / hi, / __m128 / lo)
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1132,26): error: invalid token in macro
parameter list
#define _mm256_set_m128d(/
__m128d / hi, / __m128d / lo)
^
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\immintrin.h(1135,26): error: invalid token in macro
parameter list
#define _mm256_set_m128i(/
__m128i / hi, / __m128i */ lo)
^
9 errors generated.

Note that the unknown argument is added by Clang, and it correctly points to the directory structure that is created by the clang-headers project. When I got these errors in the past (compiling against 3.8.0 or 3.7.0) it was because I hadn’t built the clang-headers project, which copies the replacement headers to the lib directory. I am currently building that project, and I can confirm that the files do exist in the directory indicated by resource-dir.

Any ideas how to get this to work so that I can build and run my tool against VS2015?