1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Fix for 182889 by Emanuel Graf, additional info for preprocessor AST nodes.

This commit is contained in:
Markus Schorn 2007-04-23 07:17:51 +00:00
parent 8380e9b7cf
commit 67538ff936
12 changed files with 443 additions and 66 deletions

View file

@ -8,6 +8,7 @@
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2; package org.eclipse.cdt.core.parser.tests.ast2;
@ -45,6 +46,7 @@ public class DOMParserTestSuite extends TestCase {
suite.addTestSuite( AST2CSpecFailingTest.class ); suite.addTestSuite( AST2CSpecFailingTest.class );
suite.addTestSuite( DOMSelectionParseTest.class ); suite.addTestSuite( DOMSelectionParseTest.class );
suite.addTestSuite( GCCCompleteParseExtensionsTest.class ); suite.addTestSuite( GCCCompleteParseExtensionsTest.class );
suite.addTestSuite(DOMPreprocessorInformationTest.class);
suite.addTest( CompletionTestSuite.suite() ); suite.addTest( CompletionTestSuite.suite() );
return suite; return suite;
} }

View file

@ -0,0 +1,162 @@
/*******************************************************************************
* Copyright (c) 2007 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Emanuel Graf - initial API and implementation
******************************************************************************/
package org.eclipse.cdt.core.parser.tests.ast2;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorErrorStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorPragmaStatement;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.parser.ParserLanguage;
/**
* @author Emanuel Graf
*
*/
public class DOMPreprocessorInformationTest extends AST2BaseTest {
public void testPragma() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
StringBuffer buffer = new StringBuffer( "#pragma " + msg + "\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
public void testElIf() throws Exception {
String cond = "2 == 2";
StringBuffer buffer = new StringBuffer( "#if 1 == 2\n#elif " + cond + "\n#else\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIf() throws Exception {
String cond = "2 == 2";
StringBuffer buffer = new StringBuffer( "#if " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIfDef() throws Exception{
String cond = "SYMBOL";
StringBuffer buffer = new StringBuffer( "#ifdef " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIfnDef() throws Exception{
String cond = "SYMBOL";
StringBuffer buffer = new StringBuffer( "#ifndef " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testError() throws Exception{
String msg = "Message";
StringBuffer buffer = new StringBuffer( "#error " + msg + "\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP, false, false );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
public void testPragmaWithSpaces() throws Exception {
String msg = "GCC poison printf sprintf fprintf";
StringBuffer buffer = new StringBuffer( "# pragma " + msg + "\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorPragmaStatement);
IASTPreprocessorPragmaStatement pragma = (IASTPreprocessorPragmaStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
public void testElIfWithSpaces() throws Exception {
String cond = "2 == 2";
StringBuffer buffer = new StringBuffer( "#if 1 == 2\n# elif " + cond + "\n#else\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(4, st.length);
assertTrue(st[1] instanceof IASTPreprocessorElifStatement);
IASTPreprocessorElifStatement pragma = (IASTPreprocessorElifStatement) st[1];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIfWithSpaces() throws Exception {
String cond = "2 == 2";
StringBuffer buffer = new StringBuffer( "# if " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfStatement);
IASTPreprocessorIfStatement pragma = (IASTPreprocessorIfStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIfDefWithSpaces() throws Exception{
String cond = "SYMBOL";
StringBuffer buffer = new StringBuffer( "# ifdef " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfdefStatement);
IASTPreprocessorIfdefStatement pragma = (IASTPreprocessorIfdefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testIfnDefWithSpaces() throws Exception{
String cond = "SYMBOL";
StringBuffer buffer = new StringBuffer( "# ifndef " + cond + "\n#endif\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(2, st.length);
assertTrue(st[0] instanceof IASTPreprocessorIfndefStatement);
IASTPreprocessorIfndefStatement pragma = (IASTPreprocessorIfndefStatement) st[0];
assertEquals(cond, new String(pragma.getCondition()));
}
public void testErrorWithSpaces() throws Exception{
String msg = "Message";
StringBuffer buffer = new StringBuffer( "# error " + msg + "\n" ); //$NON-NLS-1$
IASTTranslationUnit tu = parse( buffer.toString(), ParserLanguage.CPP, false, false );
IASTPreprocessorStatement[] st = tu.getAllPreprocessorStatements();
assertEquals(1, st.length);
assertTrue(st[0] instanceof IASTPreprocessorErrorStatement);
IASTPreprocessorErrorStatement pragma = (IASTPreprocessorErrorStatement) st[0];
assertEquals(msg, new String(pragma.getMessage()));
}
}

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -24,5 +25,12 @@ public interface IASTPreprocessorElifStatement extends
* @return boolean * @return boolean
*/ */
public boolean taken(); public boolean taken();
/**
* The condition of the elif.
*
* @return the Condition
*/
public char[] getCondition();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -17,5 +18,11 @@ package org.eclipse.cdt.core.dom.ast;
*/ */
public interface IASTPreprocessorErrorStatement extends public interface IASTPreprocessorErrorStatement extends
IASTPreprocessorStatement { IASTPreprocessorStatement {
/**
* The Error Message.
*
* @return the Message
*/
public char[] getMessage();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -23,4 +24,11 @@ public interface IASTPreprocessorIfStatement extends IASTPreprocessorStatement {
* @return boolean * @return boolean
*/ */
public boolean taken(); public boolean taken();
/**
* The condition of the if.
*
* @return the Condition
*/
public char[] getCondition();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -24,4 +25,11 @@ public interface IASTPreprocessorIfdefStatement extends
* @return * @return
*/ */
public boolean taken(); public boolean taken();
/**
* The condition of the ifdef.
*
* @return the Condition
*/
public char[] getCondition();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -24,4 +25,10 @@ public interface IASTPreprocessorIfndefStatement extends
* @return * @return
*/ */
public boolean taken(); public boolean taken();
/**
* The condition of the ifndef.
*
* @return the Condition
*/
public char[] getCondition();
} }

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2004, 2005 IBM Corporation and others. * Copyright (c) 2004, 2007 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0 * are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at * which accompanies this distribution, and is available at
@ -7,6 +7,7 @@
* *
* Contributors: * Contributors:
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.core.dom.ast; package org.eclipse.cdt.core.dom.ast;
@ -17,5 +18,11 @@ package org.eclipse.cdt.core.dom.ast;
*/ */
public interface IASTPreprocessorPragmaStatement extends public interface IASTPreprocessorPragmaStatement extends
IASTPreprocessorStatement { IASTPreprocessorStatement {
/**
* Returns the pragma message.
* @return
*/
public char[] getMessage();
} }

View file

@ -10,6 +10,7 @@
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207 * Bryan Wilkinson (QNX) - https://bugs.eclipse.org/bugs/show_bug.cgi?id=151207
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2; package org.eclipse.cdt.internal.core.parser.scanner2;
@ -115,6 +116,18 @@ abstract class BaseScanner implements IScanner {
return endOffset-startOffset; return endOffset-startOffset;
} }
} }
protected static class FunctionMacroData extends MacroData{
private CharArrayObjectMap arguments;
public FunctionMacroData(int start, int end, IMacro macro, CharArrayObjectMap argmap) {
super(start,end, macro);
arguments = argmap;
}
public CharArrayObjectMap getActualArgs() {
return arguments;
}
}
protected ParserLanguage language; protected ParserLanguage language;
@ -3269,7 +3282,8 @@ abstract class BaseScanner implements IScanner {
} }
if (pushContext) if (pushContext)
{ {
pushContext(result, new MacroData(start, bufferPos[bufferStackPos]+1, macro)); pushContext(result, new FunctionMacroData(start, bufferPos[bufferStackPos] + 1,
macro, argmap));
} }
return result; return result;
} }

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2; package org.eclipse.cdt.internal.core.parser.scanner2;
@ -208,6 +209,7 @@ public class DOMScanner extends BaseScanner {
if (data instanceof InclusionData) { if (data instanceof InclusionData) {
InclusionData inclusionData = ((InclusionData) data);
if (log.isTracing()) { if (log.isTracing()) {
StringBuffer b = new StringBuffer("Entering inclusion "); //$NON-NLS-1$ StringBuffer b = new StringBuffer("Entering inclusion "); //$NON-NLS-1$
b.append(((InclusionData) data).reader.filename); b.append(((InclusionData) data).reader.filename);
@ -215,7 +217,7 @@ public class DOMScanner extends BaseScanner {
} }
if( ! isCircularInclusion( (InclusionData) data )) if( ! isCircularInclusion( (InclusionData) data ))
{ {
DOMInclusion inc = ((DOMInclusion) ((InclusionData) data).inclusion); DOMInclusion inc = ((DOMInclusion) inclusionData.inclusion);
locationMap.startInclusion(((InclusionData) data).reader, inc.o, getGlobalOffset(getCurrentOffset())+1, locationMap.startInclusion(((InclusionData) data).reader, inc.o, getGlobalOffset(getCurrentOffset())+1,
inc.nameOffset, inc.nameEndoffset, inc.name, inc.systemInclude); inc.nameOffset, inc.nameEndoffset, inc.name, inc.systemInclude);
bufferDelta[bufferStackPos + 1] = 0; bufferDelta[bufferStackPos + 1] = 0;
@ -225,11 +227,11 @@ public class DOMScanner extends BaseScanner {
else if (data instanceof MacroData) { else if (data instanceof MacroData) {
MacroData d = (MacroData) data; MacroData d = (MacroData) data;
if (d.macro instanceof FunctionStyleMacro && fsmCount == 0) { if (d.macro instanceof FunctionStyleMacro && fsmCount == 0) {
FunctionMacroData fd = (FunctionMacroData)d;
FunctionStyleMacro fsm = (FunctionStyleMacro) d.macro; FunctionStyleMacro fsm = (FunctionStyleMacro) d.macro;
int startOffset= getGlobalOffset(d.getStartOffset());
int endOffset= startOffset+d.getLength();
locationMap.startFunctionStyleExpansion(fsm.attachment, locationMap.startFunctionStyleExpansion(fsm.attachment,
fsm.arglist, startOffset, endOffset); fsm.arglist, getGlobalOffset(d.getStartOffset()),
getGlobalOffset(d.getStartOffset() + d.getLength()),fd.getActualArgs().valueArray() );
bufferDelta[bufferStackPos + 1] = 0; bufferDelta[bufferStackPos + 1] = 0;
} else if (d.macro instanceof ObjectStyleMacro && fsmCount == 0) { } else if (d.macro instanceof ObjectStyleMacro && fsmCount == 0) {
ObjectStyleMacro osm = (ObjectStyleMacro) d.macro; ObjectStyleMacro osm = (ObjectStyleMacro) d.macro;
@ -395,12 +397,18 @@ public class DOMScanner extends BaseScanner {
*/ */
protected void processIfdef(int startPos, int endPos, boolean positive, protected void processIfdef(int startPos, int endPos, boolean positive,
boolean taken) { boolean taken) {
if (positive) if (positive){
int startCond = startPos + 7 + countSpaces(startPos);
char[] condition = CharArrayUtils.extract(bufferStack[bufferStackPos], startCond, endPos - startCond);
locationMap.encounterPoundIfdef(getGlobalOffset(startPos), locationMap.encounterPoundIfdef(getGlobalOffset(startPos),
getGlobalOffset(endPos), taken); getGlobalOffset(endPos), taken, condition);
else }
else{
int startCond = startPos + 8 + countSpaces(startPos);
char[] condition = CharArrayUtils.extract(bufferStack[bufferStackPos], startCond, endPos - startCond);
locationMap.encounterPoundIfndef(getGlobalOffset(startPos), locationMap.encounterPoundIfndef(getGlobalOffset(startPos),
getGlobalOffset(endPos), taken); getGlobalOffset(endPos), taken, condition);
}
} }
@ -411,8 +419,10 @@ public class DOMScanner extends BaseScanner {
* int, boolean) * int, boolean)
*/ */
protected void processIf(int startPos, int endPos, boolean taken) { protected void processIf(int startPos, int endPos, boolean taken) {
int startCond = startPos + 4 + countSpaces(startPos);
char[] condition = CharArrayUtils.extract(bufferStack[bufferStackPos], startCond, endPos - startCond);
locationMap.encounterPoundIf(getGlobalOffset(startPos), locationMap.encounterPoundIf(getGlobalOffset(startPos),
getGlobalOffset(endPos), taken); getGlobalOffset(endPos), taken, condition);
} }
/* /*
@ -422,8 +432,10 @@ public class DOMScanner extends BaseScanner {
* int, boolean) * int, boolean)
*/ */
protected void processElsif(int startPos, int endPos, boolean taken) { protected void processElsif(int startPos, int endPos, boolean taken) {
int startCond = startPos + 6 + countSpaces(startPos);
char[] condition = CharArrayUtils.extract(bufferStack[bufferStackPos], startCond, endPos - startCond);
locationMap.encounterPoundElif(getGlobalOffset(startPos), locationMap.encounterPoundElif(getGlobalOffset(startPos),
getGlobalOffset(endPos), taken); getGlobalOffset(endPos), taken, condition);
} }
/* /*
@ -458,16 +470,28 @@ public class DOMScanner extends BaseScanner {
* int) * int)
*/ */
protected void processError(int startPos, int endPos) { protected void processError(int startPos, int endPos) {
int start = startPos+7 + countSpaces(startPos);
char[] msg = CharArrayUtils.extract(bufferStack[bufferStackPos], start, endPos- start);
locationMap.encounterPoundError(getGlobalOffset(startPos), locationMap.encounterPoundError(getGlobalOffset(startPos),
getGlobalOffset(endPos)); getGlobalOffset(endPos), msg);
} }
/* /*
* @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processWarning(int, int) * @see org.eclipse.cdt.internal.core.parser.scanner2.BaseScanner#processWarning(int, int)
*/ */
protected void processWarning(int startPos, int endPos) { protected void processWarning(int startPos, int endPos) {
int start = startPos+9 + countSpaces(startPos);
char[] msg = CharArrayUtils.extract(bufferStack[bufferStackPos], start, endPos - start);
locationMap.encounterPoundWarning(getGlobalOffset(startPos), locationMap.encounterPoundWarning(getGlobalOffset(startPos),
getGlobalOffset(endPos)); getGlobalOffset(endPos), msg);
}
private int countSpaces(int startPos) {
int spaces = 0;
while(bufferStack[bufferStackPos][startPos + spaces + 1] == ' ' || bufferStack[bufferStackPos][startPos + spaces + 1] == '\t' ) {
++spaces;
}
return spaces;
} }
/* /*
@ -487,7 +511,9 @@ public class DOMScanner extends BaseScanner {
* int) * int)
*/ */
protected void processPragma(int startPos, int endPos) { protected void processPragma(int startPos, int endPos) {
locationMap.encounterPoundPragma(getGlobalOffset(startPos), getGlobalOffset(endPos)); int startCond = startPos + 8 + countSpaces(startPos);
char[] msg = CharArrayUtils.extract(bufferStack[bufferStackPos], startCond, endPos - (startCond));
locationMap.encounterPoundPragma(getGlobalOffset(startPos), getGlobalOffset(endPos), msg);
} }
protected void beforeReplaceAllMacros() { protected void beforeReplaceAllMacros() {

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2; package org.eclipse.cdt.internal.core.parser.scanner2;
@ -36,7 +37,7 @@ public interface IScannerPreprocessorLog {
public void startFunctionStyleExpansion(IMacroDefinition macro, public void startFunctionStyleExpansion(IMacroDefinition macro,
char[][] parameters, int startOffset, int endOffset); char[][] parameters, int startOffset, int endOffset, Object[] objects);
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset); public void endFunctionStyleExpansion(IMacroDefinition macro, int offset);
@ -54,25 +55,25 @@ public interface IScannerPreprocessorLog {
public IMacroDefinition defineFunctionStyleMacro(FunctionStyleMacro m, public IMacroDefinition defineFunctionStyleMacro(FunctionStyleMacro m,
int startOffset, int nameOffset, int nameEndOffset, int endOffset); int startOffset, int nameOffset, int nameEndOffset, int endOffset);
public void encounterPoundIf(int startOffset, int endOffset, boolean taken); public void encounterPoundIf(int startOffset, int endOffset, boolean taken, char[] condition);
public void encounterPoundIfdef(int startOffset, int endOffset, public void encounterPoundIfdef(int startOffset, int endOffset,
boolean taken); boolean taken, char[] condition);
public void encounterPoundIfndef(int startOffset, int endOffset, public void encounterPoundIfndef(int startOffset, int endOffset,
boolean taken); boolean taken, char[] condition);
public void encounterPoundElse(int startOffset, int endOffset, boolean taken); public void encounterPoundElse(int startOffset, int endOffset, boolean taken);
public void encounterPoundElif(int startOffset, int endOffset, boolean taken); public void encounterPoundElif(int startOffset, int endOffset, boolean taken, char[] condition);
public void encounterPoundEndIf(int startOffset, int endOffset); public void encounterPoundEndIf(int startOffset, int endOffset);
public void encounterPoundPragma(int startOffset, int endOffset); public void encounterPoundPragma(int startOffset, int endOffset, char[] msg);
public void encounterPoundError(int startOffset, int endOffset); public void encounterPoundError(int startOffset, int endOffset, char[] msg);
public void encounterPoundWarning(int startOffset, int endOffset); public void encounterPoundWarning(int startOffset, int endOffset, char[] msg);
public void encounterPoundUndef(int startOffset, int endOffset, public void encounterPoundUndef(int startOffset, int endOffset,
char[] symbol, int nameOffset, IMacroDefinition macroDefinition); char[] symbol, int nameOffset, IMacroDefinition macroDefinition);

View file

@ -9,6 +9,7 @@
* IBM - Initial API and implementation * IBM - Initial API and implementation
* Markus Schorn (Wind River Systems) * Markus Schorn (Wind River Systems)
* Anton Leherbauer (Wind River Systems) * Anton Leherbauer (Wind River Systems)
* Emanuel Graf (IFS)
*******************************************************************************/ *******************************************************************************/
package org.eclipse.cdt.internal.core.parser.scanner2; package org.eclipse.cdt.internal.core.parser.scanner2;
@ -106,6 +107,27 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
} }
} }
public class FunctionMacroExpansionLocation extends MacroExpansionLocation{
private Object[] actParams;
/**
* @param macroDefinition
* @param locations
* @param offset
* @param length
*/
public FunctionMacroExpansionLocation(IASTPreprocessorMacroDefinition macroDefinition, IASTNodeLocation[] locations, int offset, int length, Object[] actParameters) {
super(macroDefinition, locations, offset, length);
this.actParams = actParameters;
}
public Object[] getActualParameters() {
return actParams;
}
}
private static final String NOT_VALID_MACRO = "Not a valid macro selection"; //$NON-NLS-1$ private static final String NOT_VALID_MACRO = "Not a valid macro selection"; //$NON-NLS-1$
@ -126,6 +148,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
IASTPreprocessorElifStatement { IASTPreprocessorElifStatement {
private final boolean taken; private final boolean taken;
private char[] condition;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -139,10 +162,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
/** /**
* @param taken * @param taken
*/ */
public ASTElif(boolean taken) { public ASTElif(boolean taken, char[] condition) {
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorElifStatement#getCondition()
*/
public char[] getCondition() {
return condition;
}
} }
/** /**
@ -177,6 +208,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
IASTPreprocessorIfndefStatement { IASTPreprocessorIfndefStatement {
private final boolean taken; private final boolean taken;
private char[] condition;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -190,10 +222,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
/** /**
* @param taken * @param taken
*/ */
public ASTIfndef(boolean taken) { public ASTIfndef(boolean taken, char[] condition) {
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfndefStatement#getCondition()
*/
public char[] getCondition() {
return condition;
}
} }
/** /**
@ -203,6 +243,8 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
IASTPreprocessorIfdefStatement { IASTPreprocessorIfdefStatement {
private final boolean taken; private final boolean taken;
private char[] condition;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -216,10 +258,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
/** /**
* @param taken * @param taken
*/ */
public ASTIfdef(boolean taken) { public ASTIfdef(boolean taken, char[] condition) {
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfdefStatement#getCondition()
*/
public char[] getCondition() {
return condition;
}
} }
/** /**
@ -229,6 +279,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
IASTPreprocessorIfStatement { IASTPreprocessorIfStatement {
private final boolean taken; private final boolean taken;
private char[] condition;
/* /*
* (non-Javadoc) * (non-Javadoc)
@ -242,10 +293,18 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
/** /**
* @param taken * @param taken
*/ */
public ASTIf(boolean taken) { public ASTIf(boolean taken, char[] condition) {
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorIfStatement#getCondition()
*/
public char[] getCondition() {
return condition;
}
} }
/** /**
@ -253,11 +312,35 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
*/ */
public static class ASTError extends ASTNode implements public static class ASTError extends ASTNode implements
IASTPreprocessorErrorStatement { IASTPreprocessorErrorStatement {
private char[] msg;
public ASTError(char[] msg) {
super();
this.msg = msg;
}
public char[] getMessage() {
return msg;
}
} }
public static class ASTWarning extends ASTNode implements public static class ASTWarning extends ASTNode implements
IASTPreprocessorErrorStatement { IASTPreprocessorErrorStatement {
private char[] msg;
public ASTWarning(char[] msg) {
super();
this.msg = msg;
}
public char[] getMessage() {
return msg;
}
} }
/** /**
@ -265,6 +348,24 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
*/ */
public static class ASTPragma extends ASTNode implements public static class ASTPragma extends ASTNode implements
IASTPreprocessorPragmaStatement { IASTPreprocessorPragmaStatement {
private char[] msg;
public ASTPragma(char[] msg) {
super();
this.msg = msg;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.core.dom.ast.IASTPreprocessorPragmaStatement#getMessage()
*/
public char[] getMessage() {
return msg;
}
} }
@ -314,6 +415,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
_IPreprocessorDirective { _IPreprocessorDirective {
public final boolean taken; public final boolean taken;
public char[] condition;
/** /**
* @param parent * @param parent
@ -321,9 +423,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @param endOffset * @param endOffset
*/ */
public _Elif(_CompositeContext parent, int startOffset, int endOffset, public _Elif(_CompositeContext parent, int startOffset, int endOffset,
boolean taken) { boolean taken, char[] condition) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
} }
@ -335,6 +438,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
_IPreprocessorDirective { _IPreprocessorDirective {
public final boolean taken; public final boolean taken;
public char[] condition;
/** /**
* @param parent * @param parent
@ -342,9 +446,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @param endOffset * @param endOffset
*/ */
public _Ifdef(_CompositeContext parent, int startOffset, int endOffset, public _Ifdef(_CompositeContext parent, int startOffset, int endOffset,
boolean taken) { boolean taken, char[] condition) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
} }
@ -356,6 +461,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
_IPreprocessorDirective { _IPreprocessorDirective {
public final boolean taken; public final boolean taken;
public char[] condition;
/** /**
* @param parent * @param parent
@ -363,9 +469,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @param endOffset * @param endOffset
*/ */
public _Ifndef(_CompositeContext parent, int startOffset, public _Ifndef(_CompositeContext parent, int startOffset,
int endOffset, boolean taken) { int endOffset, boolean taken, char[] condition) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
} }
@ -375,22 +482,27 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
*/ */
protected static class _Error extends _Context implements protected static class _Error extends _Context implements
_IPreprocessorDirective { _IPreprocessorDirective {
char[] msg;
/** /**
* @param parent * @param parent
* @param startOffset * @param startOffset
* @param endOffset * @param endOffset
* @param msg
*/ */
public _Error(_CompositeContext parent, int startOffset, int endOffset) { public _Error(_CompositeContext parent, int startOffset, int endOffset, char[] msg) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
// TODO Auto-generated constructor stub this.msg = msg;
} }
} }
protected static class _Warning extends _Context implements _IPreprocessorDirective { protected static class _Warning extends _Context implements _IPreprocessorDirective {
public _Warning(_CompositeContext parent, int startOffset, int endOffset) { char[] msg;
public _Warning(_CompositeContext parent, int startOffset, int endOffset, char[] msg) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.msg = msg;
} }
} }
@ -399,15 +511,19 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
*/ */
protected static class _Pragma extends _Context implements protected static class _Pragma extends _Context implements
_IPreprocessorDirective { _IPreprocessorDirective {
char[] msg;
/** /**
* @param parent * @param parent
* @param startOffset * @param startOffset
* @param endOffset * @param endOffset
*/ */
public _Pragma(_CompositeContext parent, int startOffset, int endOffset) { public _Pragma(_CompositeContext parent, int startOffset, int endOffset, char[] msg) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.msg = msg;
} }
} }
@ -417,6 +533,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
protected class _If extends _Context implements _IPreprocessorDirective { protected class _If extends _Context implements _IPreprocessorDirective {
public final boolean taken; public final boolean taken;
public char[] condition;
/** /**
* @param parent * @param parent
@ -424,9 +541,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @param endOffset * @param endOffset
*/ */
public _If(_CompositeContext parent, int startOffset, int endOffset, public _If(_CompositeContext parent, int startOffset, int endOffset,
boolean taken) { boolean taken, char[] condition) {
super(parent, startOffset, endOffset); super(parent, startOffset, endOffset);
this.taken = taken; this.taken = taken;
this.condition = condition;
} }
} }
@ -1461,13 +1579,15 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
protected class _FunctionMacroExpansion extends _MacroExpansion { protected class _FunctionMacroExpansion extends _MacroExpansion {
public final char[][] args; public final char[][] args;
public final Object[] actArgs;
public _FunctionMacroExpansion(_CompositeContext parent, public _FunctionMacroExpansion(_CompositeContext parent,
int startOffset, int endOffset, IMacroDefinition definition, int startOffset, int endOffset, IMacroDefinition definition,
char[][] args) { char[][] args, Object[] actParameters) {
super(parent, startOffset, endOffset, definition); super(parent, startOffset, endOffset, definition);
this.args = args; this.args = args;
this.actArgs = actParameters;
} }
} }
@ -1703,7 +1823,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTElif(_Elif elif) { private IASTPreprocessorStatement createASTElif(_Elif elif) {
IASTPreprocessorElifStatement result = new ASTElif(elif.taken); IASTPreprocessorElifStatement result = new ASTElif(elif.taken, elif.condition);
((ASTNode) result).setOffsetAndLength(elif.context_directive_start, elif.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(elif.context_directive_start, elif.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1727,7 +1847,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTIfndef(_Ifndef ifndef) { private IASTPreprocessorStatement createASTIfndef(_Ifndef ifndef) {
IASTPreprocessorIfndefStatement result = new ASTIfndef(ifndef.taken); IASTPreprocessorIfndefStatement result = new ASTIfndef(ifndef.taken, ifndef.condition);
((ASTNode) result).setOffsetAndLength(ifndef.context_directive_start, ifndef.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(ifndef.context_directive_start, ifndef.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1739,7 +1859,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTIfdef(_Ifdef ifdef) { private IASTPreprocessorStatement createASTIfdef(_Ifdef ifdef) {
IASTPreprocessorIfdefStatement result = new ASTIfdef(ifdef.taken); IASTPreprocessorIfdefStatement result = new ASTIfdef(ifdef.taken, ifdef.condition);
((ASTNode) result).setOffsetAndLength(ifdef.context_directive_start, ifdef.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(ifdef.context_directive_start, ifdef.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1751,7 +1871,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTIf(_If i) { private IASTPreprocessorStatement createASTIf(_If i) {
IASTPreprocessorIfStatement result = new ASTIf(i.taken); IASTPreprocessorIfStatement result = new ASTIf(i.taken, i.condition);
((ASTNode) result).setOffsetAndLength(i.context_directive_start, i.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(i.context_directive_start, i.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1763,7 +1883,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTError(_Error error) { private IASTPreprocessorStatement createASTError(_Error error) {
IASTPreprocessorErrorStatement result = new ASTError(); IASTPreprocessorErrorStatement result = new ASTError(error.msg);
((ASTNode) result).setOffsetAndLength(error.context_directive_start, error.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(error.context_directive_start, error.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1775,7 +1895,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTWarning(_Warning warning) { private IASTPreprocessorStatement createASTWarning(_Warning warning) {
IASTPreprocessorErrorStatement result = new ASTWarning(); IASTPreprocessorErrorStatement result = new ASTWarning(warning.msg);
((ASTNode) result).setOffsetAndLength(warning.context_directive_start, warning.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(warning.context_directive_start, warning.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1787,7 +1907,7 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @return * @return
*/ */
private IASTPreprocessorStatement createASTPragma(_Pragma pragma) { private IASTPreprocessorStatement createASTPragma(_Pragma pragma) {
IASTPreprocessorPragmaStatement result = new ASTPragma(); IASTPreprocessorPragmaStatement result = new ASTPragma(pragma.msg);
((ASTNode) result).setOffsetAndLength(pragma.getDirectiveStart(), pragma.getDirectiveLength()); ((ASTNode) result).setOffsetAndLength(pragma.getDirectiveStart(), pragma.getDirectiveLength());
result.setParent(rootNode); result.setParent(rootNode);
result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT); result.setPropertyInParent(IASTTranslationUnit.PREPROCESSOR_STATEMENT);
@ -1952,7 +2072,14 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
definition = astNode; definition = astNode;
} }
return new MacroExpansionLocation(definition, locations, expansion.getOffsetInContext(offset), length); if (c instanceof _FunctionMacroExpansion) {
_FunctionMacroExpansion fe = (_FunctionMacroExpansion) c;
return new FunctionMacroExpansionLocation(definition, locations, fe.getOffsetInContext(offset), length, fe.actArgs);
}else {
_MacroExpansion me = (_MacroExpansion) c;
return new MacroExpansionLocation(definition, locations,
me.getOffsetInContext(offset), length);
}
} }
return null; return null;
} }
@ -2085,9 +2212,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* char[][], char[], int) * char[][], char[], int)
*/ */
public void startFunctionStyleExpansion(IMacroDefinition macro, public void startFunctionStyleExpansion(IMacroDefinition macro,
char[][] parameters, int startOffset, int endOffset) { char[][] parameters, int startOffset, int endOffset, Object[] actParameters) {
_FunctionMacroExpansion context = new _FunctionMacroExpansion( _FunctionMacroExpansion context = new _FunctionMacroExpansion(
currentContext, startOffset, endOffset, macro, parameters); currentContext, startOffset, endOffset, macro, parameters, actParameters);
currentContext.addSubContext(context); currentContext.addSubContext(context);
currentContext = context; currentContext = context;
} }
@ -2174,9 +2301,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundIf(int, * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundIf(int,
* int) * int)
*/ */
public void encounterPoundIf(int startOffset, int endOffset, boolean taken) { public void encounterPoundIf(int startOffset, int endOffset, boolean taken, char[] condtion) {
currentContext.addSubContext(new _If(currentContext, startOffset, currentContext.addSubContext(new _If(currentContext, startOffset,
endOffset, taken)); endOffset, taken, condtion));
} }
@ -2186,9 +2313,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundPragma(int, * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundPragma(int,
* int) * int)
*/ */
public void encounterPoundPragma(int startOffset, int endOffset) { public void encounterPoundPragma(int startOffset, int endOffset, char[] msg) {
currentContext.addSubContext(new _Pragma(currentContext, startOffset, currentContext.addSubContext(new _Pragma(currentContext, startOffset,
endOffset)); endOffset, msg));
} }
/* /*
@ -2197,17 +2324,17 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundError(int, * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundError(int,
* int) * int)
*/ */
public void encounterPoundError(int startOffset, int endOffset) { public void encounterPoundError(int startOffset, int endOffset, char[] msg) {
currentContext.addSubContext(new _Error(currentContext, startOffset, currentContext.addSubContext(new _Error(currentContext, startOffset,
endOffset)); endOffset, msg));
} }
/* /*
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundWarning(int, int) * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundWarning(int, int)
*/ */
public void encounterPoundWarning(int startOffset, int endOffset) { public void encounterPoundWarning(int startOffset, int endOffset, char[] msg) {
currentContext.addSubContext(new _Warning(currentContext, startOffset, currentContext.addSubContext(new _Warning(currentContext, startOffset,
endOffset)); endOffset, msg));
} }
/* /*
@ -2217,9 +2344,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* int) * int)
*/ */
public void encounterPoundIfdef(int startOffset, int endOffset, public void encounterPoundIfdef(int startOffset, int endOffset,
boolean taken) { boolean taken, char[] condition) {
currentContext.addSubContext(new _Ifdef(currentContext, startOffset, currentContext.addSubContext(new _Ifdef(currentContext, startOffset,
endOffset, taken)); endOffset, taken, condition));
} }
/* /*
@ -2251,9 +2378,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundElif(int, * @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#encounterPoundElif(int,
* int) * int)
*/ */
public void encounterPoundElif(int startOffset, int endOffset, boolean taken) { public void encounterPoundElif(int startOffset, int endOffset, boolean taken, char[] condition) {
currentContext.addSubContext(new _Elif(currentContext, startOffset, currentContext.addSubContext(new _Elif(currentContext, startOffset,
endOffset, taken)); endOffset, taken, condition));
} }
/* /*
@ -2470,9 +2597,9 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
* int, boolean) * int, boolean)
*/ */
public void encounterPoundIfndef(int startOffset, int endOffset, public void encounterPoundIfndef(int startOffset, int endOffset,
boolean taken) { boolean taken, char[] condition) {
currentContext.addSubContext(new _Ifndef(currentContext, startOffset, currentContext.addSubContext(new _Ifndef(currentContext, startOffset,
endOffset, taken)); endOffset, taken, condition));
} }
_Inclusion findInclusion(_CompositeContext context, String path) { _Inclusion findInclusion(_CompositeContext context, String path) {