mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-09 02:36:01 +02:00
Fixed Bug 103560 ClassCastException in LocationMap.endInclusion
This commit is contained in:
parent
da7592b337
commit
dc22806259
3 changed files with 66 additions and 16 deletions
|
@ -250,7 +250,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
bufferDelta[0] += bufferDelta[bufferStackPos + 1] + ((CodeReader) result).buffer.length;
|
bufferDelta[0] += bufferDelta[bufferStackPos + 1] + ((CodeReader) result).buffer.length;
|
||||||
locationMap.endInclusion( getGlobalCounter(0) );
|
locationMap.endInclusion( ((CodeReader) result), getGlobalCounter(0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
} else if (result instanceof InclusionData) {
|
} else if (result instanceof InclusionData) {
|
||||||
|
@ -262,7 +262,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
}
|
}
|
||||||
|
|
||||||
int value = getGlobalCounter(bufferStackPos + 1) + delta_pos;
|
int value = getGlobalCounter(bufferStackPos + 1) + delta_pos;
|
||||||
locationMap.endInclusion(value);
|
locationMap.endInclusion(codeReader, value);
|
||||||
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
||||||
+ codeReader.buffer.length;
|
+ codeReader.buffer.length;
|
||||||
} else if (result instanceof MacroData) {
|
} else if (result instanceof MacroData) {
|
||||||
|
@ -270,7 +270,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
if (data.macro instanceof FunctionStyleMacro && fsmCount == 0) {
|
if (data.macro instanceof FunctionStyleMacro && fsmCount == 0) {
|
||||||
|
|
||||||
locationMap
|
locationMap
|
||||||
.endFunctionStyleExpansion(getGlobalCounter(bufferStackPos + 1)
|
.endFunctionStyleExpansion(((FunctionStyleMacro)data.macro).attachment, getGlobalCounter(bufferStackPos + 1)
|
||||||
+ delta_pos + 1); // functionstyle
|
+ delta_pos + 1); // functionstyle
|
||||||
// macro)
|
// macro)
|
||||||
// ;
|
// ;
|
||||||
|
@ -278,7 +278,7 @@ public class DOMScanner extends BaseScanner {
|
||||||
+ delta_pos + 1;
|
+ delta_pos + 1;
|
||||||
} else if (data.macro instanceof ObjectStyleMacro && fsmCount == 0) {
|
} else if (data.macro instanceof ObjectStyleMacro && fsmCount == 0) {
|
||||||
locationMap
|
locationMap
|
||||||
.endObjectStyleMacroExpansion(getGlobalCounter(bufferStackPos + 1)
|
.endObjectStyleMacroExpansion(((ObjectStyleMacro)data.macro).attachment, getGlobalCounter(bufferStackPos + 1)
|
||||||
+ delta_pos );
|
+ delta_pos );
|
||||||
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
||||||
+ delta_pos;
|
+ delta_pos;
|
||||||
|
|
|
@ -25,18 +25,18 @@ public interface IScannerPreprocessorLog {
|
||||||
|
|
||||||
public void startInclusion(CodeReader reader, int offset, int endOffset);
|
public void startInclusion(CodeReader reader, int offset, int endOffset);
|
||||||
|
|
||||||
public void endInclusion(int offset);
|
public void endInclusion(CodeReader reader, int offset);
|
||||||
|
|
||||||
public void startObjectStyleMacroExpansion(IMacroDefinition macro,
|
public void startObjectStyleMacroExpansion(IMacroDefinition macro,
|
||||||
int startOffset, int endOffset);
|
int startOffset, int endOffset);
|
||||||
|
|
||||||
public void endObjectStyleMacroExpansion(int offset);
|
public void endObjectStyleMacroExpansion(IMacroDefinition macro, int offset);
|
||||||
|
|
||||||
|
|
||||||
public void startFunctionStyleExpansion(IMacroDefinition macro,
|
public void startFunctionStyleExpansion(IMacroDefinition macro,
|
||||||
char[][] parameters, int startOffset, int endOffset);
|
char[][] parameters, int startOffset, int endOffset);
|
||||||
|
|
||||||
public void endFunctionStyleExpansion(int offset);
|
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset);
|
||||||
|
|
||||||
public interface IMacroDefinition {
|
public interface IMacroDefinition {
|
||||||
public char[] getName();
|
public char[] getName();
|
||||||
|
|
|
@ -1862,9 +1862,27 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#endInclusion(char[],
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#endInclusion(char[],
|
||||||
* int)
|
* int)
|
||||||
*/
|
*/
|
||||||
public void endInclusion(int offset) {
|
public void endInclusion(CodeReader reader, int offset) {
|
||||||
((_Inclusion) currentContext).context_ends = offset;
|
if( currentContext instanceof _Inclusion &&
|
||||||
currentContext = currentContext.getParent();
|
((_Inclusion)currentContext).reader == reader )
|
||||||
|
{
|
||||||
|
((_Inclusion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_CompositeContext test = currentContext;
|
||||||
|
while( ( test = test.getParent() ) != tu )
|
||||||
|
{
|
||||||
|
if( test instanceof _Inclusion &&
|
||||||
|
((_Inclusion)test).reader == reader )
|
||||||
|
{
|
||||||
|
currentContext = test;
|
||||||
|
((_Inclusion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1887,9 +1905,25 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#exitObjectStyleMacroExpansion(char[],
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#exitObjectStyleMacroExpansion(char[],
|
||||||
* int)
|
* int)
|
||||||
*/
|
*/
|
||||||
public void endObjectStyleMacroExpansion(int offset) {
|
public void endObjectStyleMacroExpansion(IMacroDefinition macro, int offset) {
|
||||||
((_ObjectMacroExpansion) currentContext).context_ends = offset;
|
if( currentContext instanceof _MacroExpansion && ((_MacroExpansion)currentContext).definition == macro )
|
||||||
currentContext = currentContext.getParent();
|
{
|
||||||
|
((_ObjectMacroExpansion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_CompositeContext test = currentContext;
|
||||||
|
while( ( test = test.getParent() ) != tu )
|
||||||
|
{
|
||||||
|
if( test instanceof _MacroExpansion && ((_MacroExpansion)test).definition == macro )
|
||||||
|
{
|
||||||
|
currentContext = test;
|
||||||
|
((_ObjectMacroExpansion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1912,9 +1946,25 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
||||||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#exitFunctionStyleExpansion(char[],
|
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#exitFunctionStyleExpansion(char[],
|
||||||
* int)
|
* int)
|
||||||
*/
|
*/
|
||||||
public void endFunctionStyleExpansion(int offset) {
|
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset) {
|
||||||
((_FunctionMacroExpansion) currentContext).context_ends = offset;
|
if( currentContext instanceof _MacroExpansion && ((_MacroExpansion)currentContext).definition == macro )
|
||||||
currentContext = currentContext.getParent();
|
{
|
||||||
|
((_FunctionMacroExpansion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_CompositeContext test = currentContext;
|
||||||
|
while( ( test = test.getParent() ) != tu )
|
||||||
|
{
|
||||||
|
if( test instanceof _MacroExpansion && ((_MacroExpansion)test).definition == macro )
|
||||||
|
{
|
||||||
|
currentContext = test;
|
||||||
|
((_FunctionMacroExpansion) currentContext).context_ends = offset;
|
||||||
|
currentContext = currentContext.getParent();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Reference in a new issue