mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 01:15:29 +02:00
Bug 568427 - 'alloca' not resolved when parsing in the context of clang-cl
Don't define __STDC__ for clang-cl, just like msvc. Added a new compiler type to differentiate clang-cl from clang in order to be able to add the define just for clang and not clang-cl. I initially thought that the unresolved symbol was caused by a missing built-in symbol (_alloca) so I started to implement MSVC as a separate language from GNU and not pollute GCCBuiltinSymbolProvider with a new concept of compiler type, etc. But it turns out _alloca is also in declared in the headers and was inactive because of the wrongly defined __STDC__. So this version of the fix of adding a compiler type to GPPScannerExtensionConfiguration is much less intrusive and risky, although adding a new language could have its merit in case of more substantial change. Change-Id: Ieb27b7dbcc531b8fd3fe30777cd7f343fd3ba66f Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
parent
aff9a3332d
commit
4a83dbfbdd
2 changed files with 12 additions and 6 deletions
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
@ -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<String, String> 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.
|
||||
|
|
Loading…
Add table
Reference in a new issue