Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSergey Prigogin2012-04-10 22:14:09 +0000
committerSergey Prigogin2012-04-13 18:49:12 +0000
commit20ea7546f85ed277b38116bc7a99334c57e317f8 (patch)
tree3a579378ccafea85c5c7e7ba06c940dbf7306fd7
parent33374d0a517f3c40e03352b63ec4edc8885fb633 (diff)
downloadorg.eclipse.cdt-20ea7546f85ed277b38116bc7a99334c57e317f8.tar.gz
org.eclipse.cdt-20ea7546f85ed277b38116bc7a99334c57e317f8.tar.xz
org.eclipse.cdt-20ea7546f85ed277b38116bc7a99334c57e317f8.zip
Bug 316076. Added IFunction.isNoReturn() method.
Change-Id: Idfa2aa067e9c956b9a990980797a41277a84cc58 Reviewed-on: https://git.eclipse.org/r/5584 Reviewed-by: Sergey Prigogin <eclipse.sprigogin@gmail.com> IP-Clean: Sergey Prigogin <eclipse.sprigogin@gmail.com> Tested-by: Sergey Prigogin <eclipse.sprigogin@gmail.com>
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java9
-rw-r--r--core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java14
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.c1
-rw-r--r--core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp1
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java31
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunction.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java11
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java4
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java7
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java5
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java10
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java3
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java25
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java12
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunction.java8
-rw-r--r--core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java8
-rw-r--r--core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java12
-rw-r--r--lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java12
22 files changed, 171 insertions, 47 deletions
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
index fdc381a323a..d868d66ef6a 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CFunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation.
+ * Copyright (c) 2006, 2012 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@@ -74,6 +75,12 @@ public class CFunctionTests extends PDOMTestBase {
assertTrue(((IFunction) bindings[0]).takesVarArgs());
}
+ public void testNoReturnCFunction() throws Exception {
+ IBinding[] bindings = findQualifiedName(pdom, "noReturnCFunction");
+ assertEquals(1, bindings.length);
+ assertTrue(((IFunction) bindings[0]).isNoReturn());
+ }
+
public void testKnRStyleFunctionWithProblemParameters() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "KnRfunctionWithProblemParameters");
assertEquals(1, bindings.length);
diff --git a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
index b834b1b654f..b01af4b8144 100644
--- a/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
+++ b/core/org.eclipse.cdt.core.tests/parser/org/eclipse/cdt/internal/pdom/tests/CPPFunctionTests.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation.
+ * Copyright (c) 2006, 2012 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.pdom.tests;
@@ -38,7 +39,6 @@ import org.eclipse.core.runtime.CoreException;
*/
public class CPPFunctionTests extends PDOMTestBase {
protected ICProject project;
-
protected PDOM pdom;
public static Test suite() {
@@ -137,13 +137,19 @@ public class CPPFunctionTests extends PDOMTestBase {
assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).isInline());
}
-
+
public void testVarArgsCPPFunction() throws Exception {
IBinding[] bindings = findQualifiedName(pdom, "varArgsCPPFunction");
assertEquals(1, bindings.length);
assertTrue(((ICPPFunction) bindings[0]).takesVarArgs());
}
-
+
+ public void testNoReturnCPPFunction() throws Exception {
+ IBinding[] bindings = findQualifiedName(pdom, "noReturnCPPFunction");
+ assertEquals(1, bindings.length);
+ assertTrue(((ICPPFunction) bindings[0]).isNoReturn());
+ }
+
public void testForwardDeclarationType() throws Exception {
assertType(pdom, "forwardDeclaration", ICPPFunction.class);
}
diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.c b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.c
index 8ee78772ddc..763cd95e91f 100644
--- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.c
+++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.c
@@ -6,6 +6,7 @@ void varArgsCFunction(int p1, ...);
const void constCFunction();
volatile void volatileCFunction();
void storageClassCFunction(register int p1, int p2);
+void noReturnCFunction() __attribute__((noreturn));
void voidCFunction();
int intCFunction();
diff --git a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
index bd5ef3c900e..3f9d5b91370 100644
--- a/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
+++ b/core/org.eclipse.cdt.core.tests/resources/pdomtests/functionTests/modifiers.cpp
@@ -4,6 +4,7 @@ static int staticCPPFunction(double p1);
extern float externCPPFunction(int p1);
inline void inlineCPPFunction(long p1);
void varArgsCPPFunction(int p1, ...);
+void noReturnCPPFunction() __attribute__((noreturn));
void voidCPPFunction();
int intCPPFunction();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
index ebafdabd6f9..92c7b3260d9 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/core/dom/ast/IFunction.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Doug Schaefer (IBM) - Initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.core.dom.ast;
@@ -51,4 +52,11 @@ public interface IFunction extends IBinding {
* Returns {@code true} if this function takes variable arguments.
*/
public boolean takesVarArgs();
+
+ /**
+ * Returns {@code true} if this function never returns. Based on 'noreturn' attribute in
+ * the function declaration.
+ * @since 5.4
+ */
+ public boolean isNoReturn();
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
index 7ce3ae5d948..2b0c8403a37 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CASTName.java
@@ -23,6 +23,7 @@ import org.eclipse.cdt.core.dom.ast.IASTNode;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.ICompositeType;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
@@ -33,8 +34,7 @@ import org.eclipse.cdt.internal.core.dom.parser.IASTInternalNameOwner;
public class CASTName extends ASTNode implements IASTName, IASTCompletionContext {
private final char[] name;
- private static final char[] EMPTY_CHAR_ARRAY = {};
- private static final String EMPTY_STRING = ""; //$NON-NLS-1$
+ private static final String EMPTY_STRING = ""; //$NON-NLS-1$
private IBinding binding;
@@ -43,7 +43,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
}
public CASTName() {
- name = EMPTY_CHAR_ARRAY;
+ name = CharArrayUtils.EMPTY_CHAR_ARRAY;
}
@Override
@@ -107,7 +107,7 @@ public class CASTName extends ASTNode implements IASTName, IASTCompletionContext
@Override
public String toString() {
- if (name == EMPTY_CHAR_ARRAY)
+ if (name == CharArrayUtils.EMPTY_CHAR_ARRAY)
return EMPTY_STRING;
return new String(name);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
index 564ab70660f..937a2dd0c6d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/c/CFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Rational Software - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.c;
@@ -34,6 +35,7 @@ import org.eclipse.cdt.core.dom.ast.gnu.c.ICASTKnRFunctionDeclarator;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.core.runtime.PlatformObject;
@@ -48,7 +50,7 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
private static final int RESOLUTION_IN_PROGRESS = 1 << 1;
private int bits = 0;
- protected IFunctionType type = null;
+ protected IFunctionType type;
public CFunction(IASTDeclarator declarator) {
storeDeclarator(declarator);
@@ -469,12 +471,12 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
}
@Override
- public IASTNode[] getDeclarations() {
+ public IASTDeclarator[] getDeclarations() {
return declarators;
}
@Override
- public IASTNode getDefinition() {
+ public IASTFunctionDeclarator getDefinition() {
return definition;
}
@@ -482,4 +484,25 @@ public class CFunction extends PlatformObject implements IFunction, ICInternalFu
public IBinding getOwner() {
return null;
}
+
+ @Override
+ public boolean isNoReturn() {
+ IASTFunctionDeclarator dtor = getPreferredDtor();
+ return dtor != null && ASTAttribute.hasNoreturnAttribute(dtor);
+ }
+
+ protected IASTFunctionDeclarator getPreferredDtor() {
+ IASTFunctionDeclarator dtor = getDefinition();
+ if (dtor != null)
+ return dtor;
+
+ IASTDeclarator[] dtors = getDeclarations();
+ if (dtors != null) {
+ for (IASTDeclarator declarator : dtors) {
+ if (declarator instanceof IASTFunctionDeclarator)
+ return (IASTFunctionDeclarator) declarator;
+ }
+ }
+ return null;
+ }
}
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 071bb01590b..eee15bb797e 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2010 IBM Corporation and others.
+ * Copyright (c) 2004, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Andrew Niefer (IBM Corporation) - initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -45,6 +46,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
import org.eclipse.cdt.core.parser.util.ArrayUtil;
import org.eclipse.cdt.internal.core.dom.Linkage;
+import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTNode;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
@@ -593,4 +595,10 @@ public class CPPFunction extends PlatformObject implements ICPPFunction, ICPPInt
ICPPParameter[] pars= getParameters();
return pars.length > 0 && pars[pars.length - 1].isParameterPack();
}
+
+ @Override
+ public boolean isNoReturn() {
+ ICPPASTFunctionDeclarator dtor = getPreferredDtor();
+ return dtor != null && ASTAttribute.hasNoreturnAttribute(dtor);
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
index cf13fb67c95..74b9893f88a 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2010 IBM Corporation and others.
+ * Copyright (c) 2005, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* Andrew Niefer (IBM) - Initial API and implementation
* Bryan Wilkinson (QNX)
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -210,6 +211,14 @@ public class CPPFunctionSpecialization extends CPPSpecialization implements ICPP
return false;
}
+ @Override
+ public boolean isNoReturn() {
+ ICPPFunction f = (ICPPFunction) getSpecializedBinding();
+ if (f != null)
+ return f.isNoReturn();
+ return false;
+ }
+
@Override
public IBinding resolveParameter(CPPParameter param) {
int pos= param.getParameterPosition();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
index 24842f53ffe..13bfb745b53 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPFunctionTemplate.java
@@ -8,6 +8,7 @@
* Contributors:
* Andrew Niefer (IBM) - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.parser.cpp;
@@ -35,6 +36,7 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionDeclarator;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionTemplate;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPFunctionType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPParameter;
+import org.eclipse.cdt.internal.core.dom.parser.ASTAttribute;
import org.eclipse.cdt.internal.core.dom.parser.ASTInternal;
import org.eclipse.cdt.internal.core.dom.parser.ASTQueries;
import org.eclipse.cdt.internal.core.dom.parser.ProblemFunctionType;
@@ -338,6 +340,15 @@ public class CPPFunctionTemplate extends CPPTemplateDefinition
return false;
}
+ @Override
+ public boolean isNoReturn() {
+ ICPPASTFunctionDeclarator fdecl= getFirstFunctionDtor();
+ if (fdecl != null) {
+ return ASTAttribute.hasNoreturnAttribute(fdecl);
+ }
+ return false;
+ }
+
private IASTDeclarator getDeclaratorByName(IASTNode node) {
// Skip qualified names and nested declarators.
while (node != null) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
index 9e800ac6d99..5b4e4a4ef40 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPNamespace.java
@@ -69,8 +69,6 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
}
}
- private static final char[] EMPTY_CHAR_ARRAY = {};
-
IASTName[] namespaceDefinitions;
ICPPNamespaceScope scope;
ICPPASTTranslationUnit tu;
@@ -251,7 +249,7 @@ public class CPPNamespace extends PlatformObject implements ICPPNamespace, ICPPI
*/
@Override
public char[] getNameCharArray() {
- return tu != null ? EMPTY_CHAR_ARRAY : namespaceDefinitions[0].getSimpleID();
+ return tu != null ? CharArrayUtils.EMPTY_CHAR_ARRAY : namespaceDefinitions[0].getSimpleID();
}
/* (non-Javadoc)
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
index d0e65667ad8..f6245270563 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/CPPUnknownFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2008, 2010 Wind River Systems, Inc. and others.
+ * Copyright (c) 2008, 2012 Wind River Systems, Inc. and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -108,6 +108,11 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio
}
@Override
+ public boolean isNoReturn() {
+ return false;
+ }
+
+ @Override
public int getRequiredArgumentCount() {
return 0;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
index bcda5244bcd..1a4a168efef 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/dom/parser/cpp/semantics/AutoTypeResolver.java
@@ -167,4 +167,9 @@ class AutoTypeResolver implements ICPPFunctionTemplate {
public boolean isGloballyQualified() throws DOMException {
throw new UnsupportedOperationException(UNEXPECTED_CALL);
}
+
+ @Override
+ public boolean isNoReturn() {
+ throw new UnsupportedOperationException(UNEXPECTED_CALL);
+ }
} \ No newline at end of file
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
index b787d420395..195f786288d 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/c/CompositeCFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.c;
@@ -74,4 +75,9 @@ class CompositeCFunction extends CompositeCBinding implements IFunction {
public boolean takesVarArgs() {
return ((IFunction) rbinding).takesVarArgs();
}
+
+ @Override
+ public boolean isNoReturn() {
+ return ((IFunction) rbinding).isNoReturn();
+ }
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
index 5149f44ffb5..2e5a3d68f34 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/index/composite/cpp/CompositeCPPFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2010 Symbian Software Systems and others.
+ * Copyright (c) 2007, 2012 Symbian Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Andrew Ferguson (Symbian) - Initial implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.index.composite.cpp;
@@ -90,7 +91,12 @@ class CompositeCPPFunction extends CompositeCPPBinding implements ICPPFunction {
public boolean takesVarArgs() {
return ((ICPPFunction) rbinding).takesVarArgs();
}
-
+
+ @Override
+ public boolean isNoReturn() {
+ return ((ICPPFunction) rbinding).isNoReturn();
+ }
+
@Override
public int getRequiredArgumentCount() {
return ((ICPPFunction) rbinding).getRequiredArgumentCount();
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
index 89a574118af..88d87b9cde1 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/parser/scanner/CPreprocessor.java
@@ -84,7 +84,6 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
private static final int ORIGIN_PREPROCESSOR_DIRECTIVE = OffsetLimitReachedException.ORIGIN_PREPROCESSOR_DIRECTIVE;
private static final int ORIGIN_INACTIVE_CODE = OffsetLimitReachedException.ORIGIN_INACTIVE_CODE;
- private static final char[] EMPTY_CHAR_ARRAY = new char[0];
private static final char[] ONE = "1".toCharArray(); //$NON-NLS-1$
@@ -392,7 +391,7 @@ public class CPreprocessor implements ILexerLog, IScanner, IAdaptable {
}
private char[] nonNull(char[] array) {
- return array == null ? EMPTY_CHAR_ARRAY : array;
+ return array == null ? CharArrayUtils.EMPTY_CHAR_ARRAY : array;
}
private void configureIncludeSearchPath(File directory, IScannerInfo info) {
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java
index 7143e4bc806..0a86b7d0317 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCAnnotation.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 IBM Corporation.
+ * Copyright (c) 2006, 2012 IBM Corporation.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* IBM Corporation - initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@@ -30,6 +31,7 @@ public class PDOMCAnnotation {
public static final int REGISTER_OFFSET = 3;
public static final int STATIC_OFFSET = 4;
public static final int VARARGS_OFFSET = 5;
+ public static final int NO_RETURN = 6;
// CV qualifiers
public static final int CONST_OFFSET = 0;
@@ -46,19 +48,20 @@ public class PDOMCAnnotation {
byte modifiers = 0;
if (binding instanceof IVariable) {
IVariable variable = (IVariable) binding;
- modifiers |= (variable.isAuto() ? 1 : 0) << PDOMCAnnotation.AUTO_OFFSET;
- modifiers |= (variable.isExtern() ? 1 : 0) << PDOMCAnnotation.EXTERN_OFFSET;
- modifiers |= (variable.isRegister() ? 1 : 0) << PDOMCAnnotation.REGISTER_OFFSET;
- modifiers |= (variable.isStatic() ? 1 : 0) << PDOMCAnnotation.STATIC_OFFSET;
+ modifiers |= (variable.isAuto() ? 1 : 0) << AUTO_OFFSET;
+ modifiers |= (variable.isExtern() ? 1 : 0) << EXTERN_OFFSET;
+ modifiers |= (variable.isRegister() ? 1 : 0) << REGISTER_OFFSET;
+ modifiers |= (variable.isStatic() ? 1 : 0) << STATIC_OFFSET;
}
if (binding instanceof IFunction) {
IFunction function = (IFunction) binding;
- modifiers |= (function.isAuto() ? 1 : 0) << PDOMCAnnotation.AUTO_OFFSET;
- modifiers |= (function.isExtern() ? 1 : 0) << PDOMCAnnotation.EXTERN_OFFSET;
- modifiers |= (function.isRegister() ? 1 : 0) << PDOMCAnnotation.REGISTER_OFFSET;
- modifiers |= (ASTInternal.isStatic(function, false) ? 1 : 0) << PDOMCAnnotation.STATIC_OFFSET;
- modifiers |= (function.isInline() ? 1 : 0) << PDOMCAnnotation.INLINE_OFFSET;
- modifiers |= (function.takesVarArgs() ? 1 : 0) << PDOMCAnnotation.VARARGS_OFFSET;
+ modifiers |= (function.isAuto() ? 1 : 0) << AUTO_OFFSET;
+ modifiers |= (function.isExtern() ? 1 : 0) << EXTERN_OFFSET;
+ modifiers |= (function.isRegister() ? 1 : 0) << REGISTER_OFFSET;
+ modifiers |= (ASTInternal.isStatic(function, false) ? 1 : 0) << STATIC_OFFSET;
+ modifiers |= (function.isInline() ? 1 : 0) << INLINE_OFFSET;
+ modifiers |= (function.takesVarArgs() ? 1 : 0) << VARARGS_OFFSET;
+ modifiers |= (function.isNoReturn() ? 1 : 0) << NO_RETURN;
}
return modifiers;
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
index f2fc259eb97..a579fc6449f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/c/PDOMCFunction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2010 QNX Software Systems and others.
+ * Copyright (c) 2006, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -10,6 +10,7 @@
* IBM Corporation
* Andrew Ferguson (Symbian)
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.c;
@@ -58,7 +59,7 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
*/
@SuppressWarnings("hiding")
public static final int RECORD_SIZE = ANNOTATIONS + 1;
-
+
public PDOMCFunction(PDOMLinkage linkage, long record) {
super(linkage, record);
}
@@ -195,7 +196,12 @@ class PDOMCFunction extends PDOMBinding implements IFunction {
public boolean takesVarArgs() {
return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.VARARGS_OFFSET);
}
-
+
+ @Override
+ public boolean isNoReturn() {
+ return getBit(getByte(record + ANNOTATIONS), PDOMCAnnotation.NO_RETURN);
+ }
+
@Override
public IScope getFunctionScope() {
return null;
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 4d5c9f4a0cb..ab6d0333544 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
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2005, 2011 QNX Software Systems and others.
+ * Copyright (c) 2005, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -9,6 +9,7 @@
* Doug Schaefer (QNX) - Initial API and implementation
* IBM Corporation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -348,6 +349,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
}
@Override
+ public boolean isNoReturn() {
+ return getBit(getAnnotation(), PDOMCAnnotation.NO_RETURN);
+ }
+
+ @Override
public boolean hasParameterPack() {
return getBit(getAnnotation(), ANNOT_PARAMETER_PACK);
}
diff --git a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
index 9097d5c6197..7a7becba71f 100644
--- a/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
+++ b/core/org.eclipse.cdt.core/parser/org/eclipse/cdt/internal/core/pdom/dom/cpp/PDOMCPPFunctionSpecialization.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2007, 2011 QNX Software Systems and others.
+ * Copyright (c) 2007, 2012 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -8,6 +8,7 @@
* Contributors:
* Bryan Wilkinson (QNX) - Initial API and implementation
* Markus Schorn (Wind River Systems)
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.pdom.dom.cpp;
@@ -245,6 +246,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
}
@Override
+ public boolean isNoReturn() {
+ return getBit(readAnnotation(), PDOMCAnnotation.NO_RETURN);
+ }
+
+ @Override
public int getRequiredArgumentCount() {
if (fRequiredArgCount == -1) {
try {
diff --git a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java
index 1cb1d0ffee2..aaf0db2d342 100644
--- a/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java
+++ b/core/org.eclipse.cdt.core/src/org/eclipse/cdt/internal/formatter/Scribe.java
@@ -19,6 +19,7 @@ import java.util.List;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterConstants;
import org.eclipse.cdt.core.formatter.DefaultCodeFormatterOptions;
+import org.eclipse.cdt.core.parser.util.CharArrayUtils;
import org.eclipse.cdt.internal.formatter.align.Alignment;
import org.eclipse.cdt.internal.formatter.align.AlignmentException;
import org.eclipse.cdt.internal.formatter.scanner.Scanner;
@@ -35,7 +36,6 @@ import org.eclipse.text.edits.TextEdit;
*/
public class Scribe {
private static final String EMPTY_STRING= ""; //$NON-NLS-1$
- private static final char[] EMPTY_CHAR_ARRAY= {};
private static final String SPACE= " "; //$NON-NLS-1$
private static final int INITIAL_SIZE= 100;
@@ -105,7 +105,7 @@ public class Scribe {
int currentIndentation;
int indentation;
int lines;
- char[] leadingSpaces = EMPTY_CHAR_ARRAY;
+ char[] leadingSpaces = CharArrayUtils.EMPTY_CHAR_ARRAY;
}
final LineComment lastLineComment = new LineComment();
@@ -1082,7 +1082,7 @@ public class Scribe {
boolean hasComment= false;
boolean hasLineComment= false;
boolean hasWhitespace= false;
- char[] whiteSpaces= EMPTY_CHAR_ARRAY;
+ char[] whiteSpaces= CharArrayUtils.EMPTY_CHAR_ARRAY;
int lines= 0;
while ((currentToken= scanner.nextToken()) != null) {
if (skipOverInactive) {
@@ -1243,7 +1243,7 @@ public class Scribe {
lastLineComment.leadingSpaces = whiteSpaces;
lastLineComment.lines = lines;
}
- whiteSpaces= EMPTY_CHAR_ARRAY;
+ whiteSpaces= CharArrayUtils.EMPTY_CHAR_ARRAY;
hasWhitespace= false;
printLineComment();
currentTokenStartPosition= scanner.getCurrentPosition();
@@ -1260,7 +1260,7 @@ public class Scribe {
} else if (hasWhitespace) {
space();
}
- whiteSpaces= EMPTY_CHAR_ARRAY;
+ whiteSpaces= CharArrayUtils.EMPTY_CHAR_ARRAY;
hasWhitespace= false;
printBlockComment(false);
currentTokenStartPosition= scanner.getCurrentPosition();
@@ -1280,7 +1280,7 @@ public class Scribe {
// printNewLine(scanner.getCurrentTokenStartPosition());
}
}
- whiteSpaces= EMPTY_CHAR_ARRAY;
+ whiteSpaces= CharArrayUtils.EMPTY_CHAR_ARRAY;
hasWhitespace= false;
printPreprocessorDirective();
printNewLine();
diff --git a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java
index d6f0d88bc71..662da9896a3 100644
--- a/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java
+++ b/lrparser/org.eclipse.cdt.core.lrparser/old/org/eclipse/cdt/internal/core/dom/lrparser/c99/bindings/C99Function.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006, 2008 IBM Corporation and others.
+ * Copyright (c) 2006, 2012 IBM Corporation and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.internal.core.dom.lrparser.c99.bindings;
@@ -34,6 +35,7 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio
private boolean isRegister;
private boolean isStatic;
private boolean isVarArgs;
+ private boolean isNoReturn;
// the scope that the function is in (must be the global scope, no?)
private IScope scope;
@@ -117,6 +119,14 @@ public class C99Function extends PlatformObject implements IC99Binding, IFunctio
this.isVarArgs = isVarArgs;
}
+ public boolean isNoReturn() {
+ return isNoReturn;
+ }
+
+ public void setNoReturn(boolean isNoReturn) {
+ this.isNoReturn = isNoReturn;
+ }
+
public ILinkage getLinkage() {
return Linkage.C_LINKAGE;
}

Back to the top