[libc++] #if defined(_MSC_VER) && !defined(__clang__)

The line 14 of include/__config has the following code: #if defined(_MSC_VER) && !defined(__clang__) . I know that the compiler clang defines __clang__ and Visual Studio defines _MSC_VER, however, why should it test the __clang__ if it would only be tested if it is being compiled on Visual Studio, which doesn't have __clang__ anyway?

Clang can operate in Visual Studio compatibility mode, in which case it will define both _MSC_VER and clang. The check you posted ensures that the compiler is actually MSVC and not clang in MSVC compatibility mode. https://clang.llvm.org/docs/MSVCCompatibility.html has more information on the MSVC compatibility.