mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Fixed Bug 94933 - IASTTranslationUnit.flattenLocationsToFile does not work correctly
This commit is contained in:
parent
15b620d7f0
commit
f19c9e9061
2 changed files with 17 additions and 1 deletions
|
@ -12,6 +12,7 @@ package org.eclipse.cdt.core.parser.tests.ast2;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ast.IASTDeclarator;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTFunctionDefinition;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansion;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
|
@ -322,4 +323,17 @@ public class DOMLocationMacroTests extends AST2BaseTest {
|
|||
assertEquals( "MACRO".length(), loc.getNodeLength() ); //$NON-NLS-1$
|
||||
}
|
||||
}
|
||||
|
||||
public void testBug94933() throws Exception {
|
||||
StringBuffer buffer = new StringBuffer( "#define API extern\n" );
|
||||
buffer.append( "#define MYAPI API\n");
|
||||
buffer.append( "MYAPI void func() {}" );
|
||||
String code = buffer.toString();
|
||||
for (ParserLanguage p = ParserLanguage.C; p != null; p = (p == ParserLanguage.C) ? ParserLanguage.CPP
|
||||
: null) {
|
||||
IASTTranslationUnit tu = parse(code, p);
|
||||
IASTFunctionDefinition f = (IASTFunctionDefinition) tu.getDeclarations()[0];
|
||||
assertNotNull( f.getFileLocation() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2395,8 +2395,10 @@ public class LocationMap implements ILocationResolver, IScannerPreprocessorLog {
|
|||
} else {
|
||||
if( result[i] != null && !result[i].getFileName().equals( filename ) )
|
||||
return null;
|
||||
if( result[i].getNodeOffset() == result[i-1].getNodeOffset() )
|
||||
continue;
|
||||
if (result[i] != null
|
||||
&& result[i].getNodeOffset() != (offset + length))
|
||||
&& result[i].getNodeOffset() != (offset + length) )
|
||||
return null;
|
||||
if (result[i] != null)
|
||||
length += result[i].getNodeLength();
|
||||
|
|
Loading…
Add table
Reference in a new issue