1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Bug 553761 - NPE at GNUCSourceParser.identifier

- add null node check in GNUSourceParser.identifier()
- same for GNUCPPSourceParser.buildName()

Change-Id: Ic170d0220d179947af5b9c0d7dc50f1ed9e5965d
This commit is contained in:
Jeff Johnston 2019-12-04 15:59:36 -05:00
parent 9d897fcc04
commit 45585fcbbf
2 changed files with 9 additions and 4 deletions

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2005, 2015 IBM Corporation and others. * Copyright (c) 2005, 2019 IBM Corporation and others.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -24,6 +24,7 @@ import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.eclipse.cdt.core.dom.ast.ASTCompletionNode;
import org.eclipse.cdt.core.dom.ast.ASTVisitor; import org.eclipse.cdt.core.dom.ast.ASTVisitor;
import org.eclipse.cdt.core.dom.ast.DOMException; import org.eclipse.cdt.core.dom.ast.DOMException;
import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier; import org.eclipse.cdt.core.dom.ast.IASTAlignmentSpecifier;
@ -1748,7 +1749,9 @@ public class GNUCSourceParser extends AbstractGNUSourceCodeParser {
consume(); consume();
n = getNodeFactory().newName(t.getCharImage()); n = getNodeFactory().newName(t.getCharImage());
setRange(n, t.getOffset(), t.getEndOffset()); setRange(n, t.getOffset(), t.getEndOffset());
createCompletionNode(t).addName(n); ASTCompletionNode node = createCompletionNode(t);
if (node != null)
node.addName(n);
return n; return n;
default: default:

View file

@ -1,5 +1,5 @@
/******************************************************************************* /*******************************************************************************
* Copyright (c) 2002, 2016 IBM Corporation and others. * Copyright (c) 2002, 2019 IBM Corporation and others.
* *
* This program and the accompanying materials * This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0 * are made available under the terms of the Eclipse Public License 2.0
@ -462,7 +462,9 @@ public class GNUCPPSourceParser extends AbstractGNUSourceCodeParser {
switch (nt.getType()) { switch (nt.getType()) {
case IToken.tEOC: case IToken.tEOC:
case IToken.tCOMPLETION: case IToken.tCOMPLETION:
createCompletionNode(nt).addName(name); ASTCompletionNode node = createCompletionNode(nt);
if (node != null)
node.addName(name);
break; break;
} }
return name; return name;