mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45: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
|
||||
{
|
||||
bufferDelta[0] += bufferDelta[bufferStackPos + 1] + ((CodeReader) result).buffer.length;
|
||||
locationMap.endInclusion( getGlobalCounter(0) );
|
||||
locationMap.endInclusion( ((CodeReader) result), getGlobalCounter(0) );
|
||||
}
|
||||
|
||||
} else if (result instanceof InclusionData) {
|
||||
|
@ -262,7 +262,7 @@ public class DOMScanner extends BaseScanner {
|
|||
}
|
||||
|
||||
int value = getGlobalCounter(bufferStackPos + 1) + delta_pos;
|
||||
locationMap.endInclusion(value);
|
||||
locationMap.endInclusion(codeReader, value);
|
||||
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
||||
+ codeReader.buffer.length;
|
||||
} else if (result instanceof MacroData) {
|
||||
|
@ -270,7 +270,7 @@ public class DOMScanner extends BaseScanner {
|
|||
if (data.macro instanceof FunctionStyleMacro && fsmCount == 0) {
|
||||
|
||||
locationMap
|
||||
.endFunctionStyleExpansion(getGlobalCounter(bufferStackPos + 1)
|
||||
.endFunctionStyleExpansion(((FunctionStyleMacro)data.macro).attachment, getGlobalCounter(bufferStackPos + 1)
|
||||
+ delta_pos + 1); // functionstyle
|
||||
// macro)
|
||||
// ;
|
||||
|
@ -278,7 +278,7 @@ public class DOMScanner extends BaseScanner {
|
|||
+ delta_pos + 1;
|
||||
} else if (data.macro instanceof ObjectStyleMacro && fsmCount == 0) {
|
||||
locationMap
|
||||
.endObjectStyleMacroExpansion(getGlobalCounter(bufferStackPos + 1)
|
||||
.endObjectStyleMacroExpansion(((ObjectStyleMacro)data.macro).attachment, getGlobalCounter(bufferStackPos + 1)
|
||||
+ delta_pos );
|
||||
bufferDelta[bufferStackPos] += bufferDelta[bufferStackPos + 1]
|
||||
+ delta_pos;
|
||||
|
|
|
@ -25,18 +25,18 @@ public interface IScannerPreprocessorLog {
|
|||
|
||||
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,
|
||||
int startOffset, int endOffset);
|
||||
|
||||
public void endObjectStyleMacroExpansion(int offset);
|
||||
public void endObjectStyleMacroExpansion(IMacroDefinition macro, int offset);
|
||||
|
||||
|
||||
public void startFunctionStyleExpansion(IMacroDefinition macro,
|
||||
char[][] parameters, int startOffset, int endOffset);
|
||||
|
||||
public void endFunctionStyleExpansion(int offset);
|
||||
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset);
|
||||
|
||||
public interface IMacroDefinition {
|
||||
public char[] getName();
|
||||
|
|
|
@ -1862,9 +1862,27 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
* @see org.eclipse.cdt.internal.core.parser.scanner2.IScannerPreprocessorLog#endInclusion(char[],
|
||||
* int)
|
||||
*/
|
||||
public void endInclusion(int offset) {
|
||||
public void endInclusion(CodeReader reader, int offset) {
|
||||
if( currentContext instanceof _Inclusion &&
|
||||
((_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[],
|
||||
* int)
|
||||
*/
|
||||
public void endObjectStyleMacroExpansion(int offset) {
|
||||
public void endObjectStyleMacroExpansion(IMacroDefinition macro, int offset) {
|
||||
if( currentContext instanceof _MacroExpansion && ((_MacroExpansion)currentContext).definition == macro )
|
||||
{
|
||||
((_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[],
|
||||
* int)
|
||||
*/
|
||||
public void endFunctionStyleExpansion(int offset) {
|
||||
public void endFunctionStyleExpansion(IMacroDefinition macro, int offset) {
|
||||
if( currentContext instanceof _MacroExpansion && ((_MacroExpansion)currentContext).definition == macro )
|
||||
{
|
||||
((_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