mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-04 14:55:41 +02:00
Fix potential NPE.
This commit is contained in:
parent
da0b0d3b57
commit
47a208f1d4
3 changed files with 17 additions and 10 deletions
|
@ -70,8 +70,9 @@ public abstract class ASTAmbiguousNode extends ASTNode {
|
||||||
|
|
||||||
int minIssues = Integer.MAX_VALUE;
|
int minIssues = Integer.MAX_VALUE;
|
||||||
for (IASTNode alternative : alternatives) {
|
for (IASTNode alternative : alternatives) {
|
||||||
// flush scope, if this is not the first alternative
|
// flush scope, even if this is the first alternative. The ambiguous node may have contributed an
|
||||||
if (nodeToReplace != this && scope instanceof IASTInternalScope) {
|
// invalid binding to the scope during the resolution of other ambiguous nodes.
|
||||||
|
if (scope instanceof IASTInternalScope) {
|
||||||
try {
|
try {
|
||||||
((IASTInternalScope) scope).flushCache();
|
((IASTInternalScope) scope).flushCache();
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
|
|
|
@ -31,9 +31,9 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPTemplates;
|
||||||
*/
|
*/
|
||||||
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
|
public class CPPDeferredClassInstance extends CPPUnknownClass implements ICPPDeferredClassInstance {
|
||||||
|
|
||||||
private IType[] fArguments;
|
private final IType[] fArguments;
|
||||||
private ObjectMap fArgmap;
|
private final ObjectMap fArgmap;
|
||||||
private ICPPClassTemplate fClassTemplate;
|
private final ICPPClassTemplate fClassTemplate;
|
||||||
|
|
||||||
public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) {
|
public CPPDeferredClassInstance(ICPPClassTemplate orig, ObjectMap argMap, IType[] arguments) {
|
||||||
super(orig);
|
super(orig);
|
||||||
|
|
|
@ -1086,15 +1086,21 @@ public class CPPTemplates {
|
||||||
|
|
||||||
IType[] result = new IType[params.length];
|
IType[] result = new IType[params.length];
|
||||||
for (int i = 0; i < params.length; i++) {
|
for (int i = 0; i < params.length; i++) {
|
||||||
if (params[i] instanceof IASTNode) {
|
IType type= null;
|
||||||
result[i] = CPPVisitor.createType((IASTNode) params[i]);
|
final Object param = params[i];
|
||||||
} else if (params[i] instanceof IParameter) {
|
if (param instanceof IASTNode) {
|
||||||
|
type= CPPVisitor.createType((IASTNode) param);
|
||||||
|
} else if (param instanceof IParameter) {
|
||||||
try {
|
try {
|
||||||
result[i] = ((IParameter) params[i]).getType();
|
type= ((IParameter) param).getType();
|
||||||
} catch (DOMException e) {
|
} catch (DOMException e) {
|
||||||
result[i] = e.getProblem();
|
type= e.getProblem();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// prevent null pointer exception when the type cannot be determined
|
||||||
|
// happens when templates with still ambiguous template-ids are accessed during
|
||||||
|
// resolution of other ambiguities.
|
||||||
|
result[i]= type == null ? new CPPBasicType(-1, 0) : type;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue