mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-06 09:16:02 +02:00
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>
This commit is contained in:
parent
33374d0a51
commit
20ea7546f8
22 changed files with 171 additions and 47 deletions
|
@ -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);
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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
|
||||
|
@ -107,6 +107,11 @@ public class CPPUnknownFunction extends CPPUnknownBinding implements ICPPFunctio
|
|||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredArgumentCount() {
|
||||
return 0;
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
}
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -347,6 +348,11 @@ class PDOMCPPFunction extends PDOMCPPBinding implements ICPPFunction, IPDOMOverl
|
|||
return getBit(getAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
return getBit(getAnnotation(), PDOMCAnnotation.NO_RETURN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasParameterPack() {
|
||||
return getBit(getAnnotation(), ANNOT_PARAMETER_PACK);
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -244,6 +245,11 @@ class PDOMCPPFunctionSpecialization extends PDOMCPPSpecialization implements ICP
|
|||
return getBit(readAnnotation(), PDOMCAnnotation.VARARGS_OFFSET);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNoReturn() {
|
||||
return getBit(readAnnotation(), PDOMCAnnotation.NO_RETURN);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRequiredArgumentCount() {
|
||||
if (fRequiredArgCount == -1) {
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue