mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 08:55:25 +02:00
Fix for 197930, Scanner Discovery handling if-statements.
This commit is contained in:
parent
8d99eb9b20
commit
dc537c5cd0
3 changed files with 18 additions and 5 deletions
|
@ -10,13 +10,17 @@
|
|||
*******************************************************************************/
|
||||
package org.eclipse.cdt.make.scannerdiscovery;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import junit.framework.TestSuite;
|
||||
|
||||
import org.eclipse.cdt.core.IMarkerGenerator;
|
||||
import org.eclipse.cdt.core.ProblemMarkerInfo;
|
||||
import org.eclipse.cdt.core.model.ICProject;
|
||||
import org.eclipse.cdt.core.testplugin.CProjectHelper;
|
||||
import org.eclipse.cdt.make.core.scannerconfig.ScannerInfoTypes;
|
||||
import org.eclipse.cdt.make.internal.core.scannerconfig.gnu.GCCPerFileBOPConsoleParser;
|
||||
import org.eclipse.cdt.make.internal.core.scannerconfig.util.CCommandDSC;
|
||||
import org.eclipse.core.resources.IProject;
|
||||
import org.eclipse.core.resources.IResource;
|
||||
|
||||
|
@ -55,4 +59,13 @@ public class GCCPerFileBOPConsoleParserTests extends BaseBOPConsoleParserTests {
|
|||
CProjectHelper.delete(fCProject);
|
||||
}
|
||||
}
|
||||
|
||||
public void testParsingIfStatement_bug197930() throws Exception {
|
||||
fOutputParser.processLine("if gcc -g -O0 -I\"include abc\" -c impl/testmath.c; then ; fi"); //$NON-NLS-1$
|
||||
|
||||
List cmds = fCollector.getCollectedScannerInfo(null, ScannerInfoTypes.COMPILER_COMMAND);
|
||||
assertEquals(1, cmds.size());
|
||||
CCommandDSC command= (CCommandDSC) cmds.get(0);
|
||||
assertEquals("gcc", command.getCompilerName());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ public class GCCPerFileBOPConsoleParser extends AbstractGCCBOPConsoleParser {
|
|||
}
|
||||
}
|
||||
|
||||
CCommandDSC cmd = fUtil.getNewCCommandDSC(tokens, extensionsIndex > 0);
|
||||
CCommandDSC cmd = fUtil.getNewCCommandDSC(tokens, compilerInvocationIndex, extensionsIndex > 0);
|
||||
IPath baseDirectory = fUtil.getBaseDirectory();
|
||||
if (baseDirectory.isPrefixOf(pFilePath)) {
|
||||
List cmdList = new ArrayList();
|
||||
|
|
|
@ -114,7 +114,7 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
|||
compiledFileList.add(longFileName);
|
||||
|
||||
String[] tokens = genericLine.split("\\s+"); //$NON-NLS-1$
|
||||
CCommandDSC command = getNewCCommandDSC(tokens, false); // assume .c file type
|
||||
CCommandDSC command = getNewCCommandDSC(tokens, 0, false); // assume .c file type
|
||||
int index = commandsList2.indexOf(command);
|
||||
if (index == -1) {
|
||||
commandsList2.add(command);
|
||||
|
@ -133,12 +133,12 @@ public class GCCPerFileBOPConsoleParserUtility extends AbstractGCCBOPConsolePars
|
|||
* @param cppFileType
|
||||
* @return CCommandDSC compile command description
|
||||
*/
|
||||
public CCommandDSC getNewCCommandDSC(String[] tokens, boolean cppFileType) {
|
||||
public CCommandDSC getNewCCommandDSC(String[] tokens, final int idxOfCompilerCommand, boolean cppFileType) {
|
||||
ArrayList dirafter = new ArrayList();
|
||||
ArrayList includes = new ArrayList();
|
||||
CCommandDSC command = new CCommandDSC(cppFileType, getProject());
|
||||
command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[0]));
|
||||
for (int i = 1; i < tokens.length; ++i) {
|
||||
command.addSCOption(new KVStringPair(SCDOptionsEnum.COMMAND.toString(), tokens[idxOfCompilerCommand]));
|
||||
for (int i = idxOfCompilerCommand+1; i < tokens.length; ++i) {
|
||||
String token = tokens[i];
|
||||
//Target specific options: see GccScannerInfoConsoleParser
|
||||
if (token.startsWith("-m") || //$NON-NLS-1$
|
||||
|
|
Loading…
Add table
Reference in a new issue