Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2008-03-09 00:10:06 +0000
committerSergey Prigogin2008-03-09 00:10:06 +0000
commitd5f6bfc0bd425709c5054e0c81a1c8e3a9a9daf0 (patch)
tree2f7dde02a00a1951a5c417986ed8fd5a971073c5 /core/org.eclipse.cdt.core/parser
parent3798d2f015907e79ecc7d580ba399645406abeee (diff)
downloadorg.eclipse.cdt-d5f6bfc0bd425709c5054e0c81a1c8e3a9a9daf0.tar.gz
org.eclipse.cdt-d5f6bfc0bd425709c5054e0c81a1c8e3a9a9daf0.tar.xz
org.eclipse.cdt-d5f6bfc0bd425709c5054e0c81a1c8e3a9a9daf0.zip
Protect against NPE in toString method.
Diffstat (limited to 'core/org.eclipse.cdt.core/parser')
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java6
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java4
2 files changed, 8 insertions, 2 deletions
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
index ae013888c56..1f121e773d1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java
@@ -583,6 +583,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
@Override
public String toString() {
- return getName() + ASTTypeUtil.getParameterTypeString(getType()); //$NON-NLS-1$
+ StringBuilder result = new StringBuilder();
+ result.append(getName());
+ IFunctionType t = getType();
+ result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
+ return result.toString();
}
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
index 6c0573e70d8..c32304e6d6e 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java
@@ -261,7 +261,9 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
@Override
public String toString() {
StringBuilder result = new StringBuilder();
- result.append(getName() + ASTTypeUtil.getParameterTypeString(getType()));
+ result.append(getName());
+ IFunctionType t = getType();
+ result.append(t != null ? ASTTypeUtil.getParameterTypeString(t) : "()"); //$NON-NLS-1$
try {
result.append(" " + getConstantNameForValue(getLinkageImpl(), getNodeType())); //$NON-NLS-1$
} catch (CoreException e) {

Back to the top