diff options
2 files changed, 27 insertions, 10 deletions
diff --git a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java index 6d6dabc5cbc..07c1a168b32 100644 --- a/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java +++ b/core/org.eclipse.cdt.core/index/org/eclipse/cdt/internal/core/index/domsourceindexer/IndexVisitorUtil.java @@ -17,9 +17,10 @@ import org.eclipse.cdt.core.dom.ast.ASTSignatureUtil; import org.eclipse.cdt.core.dom.ast.ASTTypeUtil; import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.IASTDeclSpecifier; -import org.eclipse.cdt.core.dom.ast.IASTDeclarator; +import org.eclipse.cdt.core.dom.ast.IASTFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IASTName; import org.eclipse.cdt.core.dom.ast.IASTNode; +import org.eclipse.cdt.core.dom.ast.IASTStandardFunctionDeclarator; import org.eclipse.cdt.core.dom.ast.IBinding; import org.eclipse.cdt.core.dom.ast.ICompositeType; import org.eclipse.cdt.core.dom.ast.IEnumeration; @@ -192,13 +193,21 @@ public class IndexVisitorUtil { if (parent instanceof ICPPASTQualifiedName) { parent = parent.getParent(); } - if (parent instanceof IASTDeclarator) { - IASTDeclarator declarator = (IASTDeclarator) parent; - String[] parameters = ASTSignatureUtil.getParameterSignatureArray(declarator); - if (parameters.length == 0) { + if (parent instanceof IASTFunctionDeclarator) { + IASTFunctionDeclarator fDecl = (IASTFunctionDeclarator) parent; + String[] parameters = ASTSignatureUtil.getParameterSignatureArray(fDecl); + char[][] rv; + if (fDecl instanceof IASTStandardFunctionDeclarator && + ((IASTStandardFunctionDeclarator) fDecl).takesVarArgs()) { + rv = new char[parameters.length + 1][]; + rv[parameters.length] = "...".toCharArray(); //$NON-NLS-1$ + } + else { + rv = new char[parameters.length][]; + } + if (rv.length == 0) { return new char[][] { "void".toCharArray() }; //$NON-NLS-1$ } - char[][] rv = new char[parameters.length][]; for (int k = 0; k < parameters.length; k++) { rv[k] = parameters[k].toCharArray(); } @@ -219,10 +228,12 @@ public class IndexVisitorUtil { IType paramType = parameters[i].getType(); parameterList.add(ASTTypeUtil.getType(paramType).toCharArray()); } - if (function.takesVarArgs()) + if (function.takesVarArgs()) { parameterList.add("...".toCharArray()); //$NON-NLS-1$ - else if (parameters.length == 0) - parameterList.add("void".toCharArray()); //$NON-NLS-1$ + } + if (parameterList.isEmpty()) { + parameterList.add("void".toCharArray()); //$NON-NLS-1$ + } } catch (DOMException e) { } diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java index c344545845f..d7c64d10a27 100644 --- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java +++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/ASTSignatureUtil.java @@ -144,7 +144,13 @@ public class ASTSignatureUtil { IASTParameterDeclaration[] parms = null; parms = ((IASTStandardFunctionDeclarator)decltor).getParameters(); - result = new String[parms.length]; + if (((IASTStandardFunctionDeclarator) decltor).takesVarArgs()) { + result = new String[parms.length + 1]; + result[parms.length] = "..."; //$NON-NLS-1$ + } + else { + result = new String[parms.length]; + } for(int i=0; i<parms.length; i++) { if (parms[i] != null) { |