1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 14:55:41 +02:00

Store macro-expansion image in index, needed for bug 23540.

This commit is contained in:
Markus Schorn 2008-01-21 15:46:10 +00:00
parent 4cc8dfd7b5
commit 63dfbb48df
3 changed files with 13 additions and 14 deletions

View file

@ -143,8 +143,8 @@ public class MacroDefinitionParser {
/**
* Parses a macro definition basically checking for var-args.
*/
public PreprocessorMacro parseMacroDefinition(final char[] name, char[][] paramList, final char[] replacement) {
fHasVarArgs= 0;
public static PreprocessorMacro parseMacroDefinition(final char[] name, char[][] paramList, final char[] replacement) {
int hasVarargs= 0;
if (paramList != null) {
final int length = paramList.length;
if (length > 0) {
@ -155,7 +155,7 @@ public class MacroDefinitionParser {
break;
case 3:
if (CharArrayUtils.equals(lastParam, Keywords.cpELLIPSIS)) {
fHasVarArgs= FunctionStyleMacro.VAARGS;
hasVarargs= FunctionStyleMacro.VAARGS;
char[][] copy= new char[length][];
System.arraycopy(paramList, 0, copy, 0, length-1);
copy[length-1]= Keywords.cVA_ARGS;
@ -164,7 +164,7 @@ public class MacroDefinitionParser {
break;
default:
if (CharArrayUtils.equals(lastParam, lpl-3, 3, Keywords.cpELLIPSIS)) {
fHasVarArgs= FunctionStyleMacro.NAMED_VAARGS;
hasVarargs= FunctionStyleMacro.NAMED_VAARGS;
char[][] copy= new char[length][];
System.arraycopy(paramList, 0, copy, 0, length-1);
copy[length-1]= CharArrayUtils.subarray(lastParam, 0, lpl-3);
@ -178,7 +178,7 @@ public class MacroDefinitionParser {
if (paramList == null) {
return new ObjectStyleMacro(name, replacement);
}
return new FunctionStyleMacro(name, paramList, fHasVarArgs, replacement);
return new FunctionStyleMacro(name, paramList, hasVarargs, replacement);
}
private Token parseName(final Lexer lexer) throws OffsetLimitReachedException, InvalidMacroDefinitionException {

View file

@ -21,10 +21,9 @@ import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.dom.ILinkage;
import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTFileLocation;
import org.eclipse.cdt.core.dom.ast.IASTFunctionStyleMacroParameter;
import org.eclipse.cdt.core.dom.ast.IASTName;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorFunctionStyleMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroDefinition;
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
import org.eclipse.cdt.core.dom.ast.IScope;
import org.eclipse.cdt.core.index.IIndexFile;
import org.eclipse.cdt.core.index.IIndexMacro;
@ -77,23 +76,23 @@ public class PDOMMacro implements IIndexMacro, IASTFileLocation {
Database db = pdom.getDB();
this.record = db.malloc(RECORD_SIZE);
IASTName name = macro.getName();
IMacroBinding binding= (IMacroBinding) name.getBinding();
db.putInt(record + NAME, db.newString(name.toCharArray()).getRecord());
db.putInt(record + FILE, file.getRecord());
IASTFileLocation fileloc = name.getFileLocation();
db.putInt(record + NAME_OFFSET, fileloc.getNodeOffset());
db.putShort(record + NAME_LENGTH, (short) fileloc.getNodeLength());
db.putInt(record + EXPANSION, db.newString(macro.getExpansion()).getRecord());
db.putInt(record + EXPANSION, db.newString(binding.getExpansionImage()).getRecord());
setNextMacro(0);
byte macroStyle= MACROSTYLE_OBJECT;
PDOMMacroParameter last = null;
if (macro instanceof IASTPreprocessorFunctionStyleMacroDefinition) {
char[][] params= binding.getParameterList();
if (params != null) {
macroStyle= MACROSTYLE_FUNCTION;
IASTPreprocessorFunctionStyleMacroDefinition func = (IASTPreprocessorFunctionStyleMacroDefinition)macro;
IASTFunctionStyleMacroParameter[] params = func.getParameters();
for (int i = params.length - 1; i >= 0; --i) {
IASTFunctionStyleMacroParameter param = params[i];
PDOMMacroParameter pdomParam = new PDOMMacroParameter(pdom, param.getParameter());
PDOMMacroParameter pdomParam = new PDOMMacroParameter(pdom, params[i]);
if (last != null)
pdomParam.setNextParameter(last);
last = pdomParam;

View file

@ -35,7 +35,7 @@ public class PDOMMacroParameter {
this.record = record;
}
public PDOMMacroParameter(PDOM pdom, String name) throws CoreException {
public PDOMMacroParameter(PDOM pdom, char[] name) throws CoreException {
Database db = pdom.getDB();
this.pdom = pdom;