1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-23 17:05:26 +02:00

Bug 568224 - Support output parsing for /clang:-isystem when substituting cl for clang-cl

Add /clang:-isystem. It's handled similarly to /imsvc but interestingly it
doesn't support having spaces between the option name and it's value.

Change-Id: Ic5d61df1c7adebbf707d93a60858e942354c9ed9
Signed-off-by: Marc-Andre Laperle <malaperle@gmail.com>
This commit is contained in:
Marc-Andre Laperle 2020-10-25 22:34:10 -04:00
parent c5a53bb7fe
commit 5a2830648c
2 changed files with 17 additions and 17 deletions

View file

@ -231,7 +231,7 @@ public class MSVCBuildCommandParserTests {
}
/**
* Parse /imsvc (clang-cl)
* Parse /imsvc, /clang:isystem (clang-cl)
*/
@Test
public void testCIncludePathEntry_ClangCLSystemIncludePaths() throws Exception {
@ -252,7 +252,8 @@ public class MSVCBuildCommandParserTests {
parser.startup(cfgDescription, null);
parser.processLine("cl" + " /imsvcC:\\path0 " + " /imsvc C:\\path1 " + " /imsvc\"C:\\path with spaces\""
+ " /imsvc\"C:\\backslash at end\\\\\"" + " /imsvc\"..\\..\\relative\""
+ " /imsvc\"..\\..\\relative with spaces\"" + " file.cpp");
+ " /imsvc\"..\\..\\relative with spaces\"" + " /clang:-isystemC:\\path2 "
+ " /clang:-isystem\"C:\\path with spaces2\"" + " file.cpp");
parser.shutdown();
// check populated entries
@ -273,6 +274,8 @@ public class MSVCBuildCommandParserTests {
assertEquals(
new CIncludePathEntry(project.getLocation().removeLastSegments(2).append("relative with spaces"), 0),
entries.get(5));
assertEquals(new CIncludePathEntry("C:/path2", 0), entries.get(6));
assertEquals(new CIncludePathEntry("C:/path with spaces2", 0), entries.get(7));
}
/**

View file

@ -81,19 +81,6 @@ public class MSVCBuildCommandParser extends AbstractBuildCommandParser implement
}
}
// TODO: Should these be considered "built-in" entries (ICSettingEntry.BUILTIN)?
private static class ClangCLMSVCSystemPathOptionParser extends IncludePathOptionParser {
public ClangCLMSVCSystemPathOptionParser(String pattern, String nameExpression) {
super(pattern, nameExpression);
}
@Override
public ICLanguageSettingEntry createEntry(String name, String value, int flag) {
return super.createEntry(name, unescapeString(value), flag);
}
}
@SuppressWarnings("nls")
static final AbstractOptionParser[] includeOptionParsers = {
new MSVCIncludePathOptionParser("(-|/)I\\s*\"(.*)\"", "$2"),
@ -106,8 +93,13 @@ public class MSVCBuildCommandParser extends AbstractBuildCommandParser implement
@SuppressWarnings("nls")
static final AbstractOptionParser[] msvcIncludeOptionParsers = {
new ClangCLMSVCSystemPathOptionParser("(-|/)imsvc\\s*\"(.*)\"", "$2"),
new ClangCLMSVCSystemPathOptionParser("(-|/)imsvc\\s*([^\\s\"]*)", "$2"), };
new MSVCIncludePathOptionParser("(-|/)imsvc\\s*\"(.*)\"", "$2"),
new MSVCIncludePathOptionParser("(-|/)imsvc\\s*([^\\s\"]*)", "$2"), };
@SuppressWarnings("nls")
static final AbstractOptionParser[] clangISystemIncludeOptionParsers = {
new MSVCIncludePathOptionParser("(-|/)clang:-isystem\"(.*)\"", "$2"),
new MSVCIncludePathOptionParser("(-|/)clang:-isystem([^\\s\"]*)", "$2"), };
@SuppressWarnings("nls")
static final AbstractOptionParser[] defineOptionParsers = {
@ -136,6 +128,7 @@ public class MSVCBuildCommandParser extends AbstractBuildCommandParser implement
List<AbstractOptionParser> parsers = new ArrayList<>(Arrays.asList(includeOptionParsers));
Collections.addAll(parsers, defineOptionParsers);
Collections.addAll(parsers, msvcIncludeOptionParsers);
Collections.addAll(parsers, clangISystemIncludeOptionParsers);
Collections.addAll(parsers, forceIncludeOptionParsers);
Collections.addAll(parsers, undefineOptionParsers);
@ -197,6 +190,10 @@ public class MSVCBuildCommandParser extends AbstractBuildCommandParser implement
return msvcIncludeOptionParsers;
}
if (optionName.startsWith("clang")) {
return clangISystemIncludeOptionParsers;
}
if (optionName.startsWith("FI")) {
return forceIncludeOptionParsers;
}