diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java index be5fcebaa0e..cf84e29ebfb 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/c/GCCScannerExtensionConfiguration.java @@ -56,6 +56,7 @@ public class GCCScannerExtensionConfiguration extends GNUScannerExtensionConfigu String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ if (mscVer != null && Integer.valueOf(mscVer) > 0) { + // Note: this is also used for clang-cl. return CONFIG_MSVC; } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java index 99dcd0a0adf..08c71bf393a 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/parser/cpp/GPPScannerExtensionConfiguration.java @@ -32,7 +32,7 @@ import org.eclipse.cdt.core.parser.Keywords; */ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfiguration { private static enum CompilerType { - GCC, Clang, MSVC + GCC, Clang, ClangCl, MSVC } private static final int VERSION_4_2 = version(4, 2); @@ -54,6 +54,8 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu private static GPPScannerExtensionConfiguration CONFIG_10_0 = new GPPScannerExtensionConfiguration(VERSION_10_0); private static GPPScannerExtensionConfiguration CONFIG_CLANG = new GPPScannerExtensionConfiguration( CompilerType.Clang, 0 /* version is ignored for now */); + private static GPPScannerExtensionConfiguration CONFIG_CLANG_CL = new GPPScannerExtensionConfiguration( + CompilerType.ClangCl, 0 /* version is ignored for now */); private static GPPScannerExtensionConfiguration CONFIG_MSVC = new GPPScannerExtensionConfiguration( CompilerType.MSVC, 0 /* version is ignored for now */); @@ -69,14 +71,17 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu try { final Map definedSymbols = info.getDefinedSymbols(); - // Clang. Needs to be checked first since it pretends to be GCC too. + // Clang. Needs to be checked first since it pretends to be GCC and MSVC too. String clang = definedSymbols.get("__clang__"); //$NON-NLS-1$ + String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ + boolean hasMsc = mscVer != null && Integer.valueOf(mscVer) > 0; if (clang != null && Integer.valueOf(clang) > 0) { + if (hasMsc) + return CONFIG_CLANG_CL; return CONFIG_CLANG; } - String mscVer = definedSymbols.get("_MSC_VER"); //$NON-NLS-1$ - if (mscVer != null && Integer.valueOf(mscVer) > 0) { + if (hasMsc) { return CONFIG_MSVC; } @@ -137,7 +142,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu addKeyword(Keywords.c_COMPLEX, IToken.t__Complex); addKeyword(Keywords.c_IMAGINARY, IToken.t__Imaginary); - if (compiler != CompilerType.MSVC) { + if (!(compiler == CompilerType.MSVC || compiler == CompilerType.ClangCl)) { // MSVC only defines this when compiling in C mode and /Za is used. addMacro("__STDC__", "1"); } @@ -193,7 +198,7 @@ public class GPPScannerExtensionConfiguration extends GNUScannerExtensionConfigu if (version >= VERSION_10_0) { addKeyword(GCCKeywords.cp__is_same, IGCCToken.tTT_is_same); } - } else if (compiler == CompilerType.Clang) { + } else if (compiler == CompilerType.Clang || compiler == CompilerType.ClangCl) { // As documented at // http://clang.llvm.org/docs/LanguageExtensions.html#checks-for-type-trait-primitives. // For now we don't make it dependent on the version.