mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Bug 362464: Sizeof computation for plain C.
This commit is contained in:
parent
058e14d32c
commit
5a62f3280d
7 changed files with 112 additions and 18 deletions
|
@ -100,12 +100,19 @@ public class AST2BaseTest extends BaseTestCase {
|
|||
protected static boolean sValidateCopy;
|
||||
|
||||
private static final ScannerInfo GNU_SCANNER_INFO = new ScannerInfo(getGnuMap());
|
||||
private static final ScannerInfo SCANNER_INFO = new ScannerInfo();
|
||||
private static final ScannerInfo SCANNER_INFO = new ScannerInfo(getStdMap());
|
||||
|
||||
private static Map<String, String> getGnuMap() {
|
||||
Map<String, String> map= new HashMap<String, String>();
|
||||
map.put("__GNUC__", "4");
|
||||
map.put("__GNUC_MINOR__", "5");
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
return map;
|
||||
}
|
||||
|
||||
private static Map<String, String> getStdMap() {
|
||||
Map<String, String> map= new HashMap<String, String>();
|
||||
map.put("__SIZEOF_INT__", "4");
|
||||
return map;
|
||||
}
|
||||
|
||||
|
|
|
@ -7375,4 +7375,16 @@ public class AST2Tests extends AST2BaseTest {
|
|||
parseAndCheckBindings();
|
||||
}
|
||||
|
||||
// typedef int T[sizeof(int)];
|
||||
public void testSizeofExpression_Bug362464() throws Exception {
|
||||
String code= getAboveComment();
|
||||
for (ParserLanguage l : ParserLanguage.values()) {
|
||||
IASTTranslationUnit tu= parseAndCheckBindings(code, l);
|
||||
IASTSimpleDeclaration sdecl= getDeclaration(tu, 0);
|
||||
ITypedef tdef= (ITypedef) sdecl.getDeclarators()[0].getName().resolveBinding();
|
||||
IArrayType at= (IArrayType) tdef.getType();
|
||||
IValue v= at.getSize();
|
||||
assertTrue(v.numericalValue() == 4);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,9 +31,11 @@ import org.eclipse.cdt.core.dom.ast.IASTPreprocessorMacroExpansion;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTPreprocessorStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTProblem;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.INodeFactory;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.index.IIndex;
|
||||
import org.eclipse.cdt.core.index.IIndexFile;
|
||||
import org.eclipse.cdt.core.index.IIndexFileSet;
|
||||
|
@ -84,6 +86,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void addDeclaration(IASTDeclaration d) {
|
||||
if (d != null) {
|
||||
d.setParent(this);
|
||||
|
@ -94,6 +97,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTDeclaration[] getDeclarations() {
|
||||
IASTDeclaration[] active= fActiveDeclarations;
|
||||
if (active == null) {
|
||||
|
@ -103,6 +107,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return active;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTDeclaration[] getDeclarations(boolean includeInactive) {
|
||||
if (includeInactive) {
|
||||
fAllDeclarations= (IASTDeclaration[]) ArrayUtil.removeNullsAfter(IASTDeclaration.class,
|
||||
|
@ -130,6 +135,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDeclarations(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public final IName[] getDeclarations(IBinding binding) {
|
||||
IName[] names= getDeclarationsInAST(binding);
|
||||
if (names.length == 0 && fIndex != null) {
|
||||
|
@ -161,7 +167,8 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getDefinitions(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
public final IName[] getDefinitions(IBinding binding) {
|
||||
@Override
|
||||
public final IName[] getDefinitions(IBinding binding) {
|
||||
IName[] names= getDefinitionsInAST(binding);
|
||||
if (names.length == 0 && fIndex != null) {
|
||||
try {
|
||||
|
@ -179,6 +186,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
|
||||
|
@ -188,6 +196,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getMacroExpansions()
|
||||
*/
|
||||
@Override
|
||||
public IASTPreprocessorMacroExpansion[] getMacroExpansions() {
|
||||
if (fLocationResolver == null)
|
||||
return IASTPreprocessorMacroExpansion.EMPTY_ARRAY;
|
||||
|
@ -199,6 +208,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getBuiltinMacroDefinitions()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorMacroDefinition[] getBuiltinMacroDefinitions() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_MACRODEF_ARRAY;
|
||||
|
@ -210,6 +220,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getIncludeDirectives()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorIncludeStatement[] getIncludeDirectives() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_INCLUSION_ARRAY;
|
||||
|
@ -221,6 +232,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getAllPreprocessorStatements()
|
||||
*/
|
||||
@Override
|
||||
public final IASTPreprocessorStatement[] getAllPreprocessorStatements() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PREPROCESSOR_STATEMENT_ARRAY;
|
||||
|
@ -242,6 +254,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getPreprocesorProblems()
|
||||
*/
|
||||
@Override
|
||||
public final IASTProblem[] getPreprocessorProblems() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_PROBLEM_ARRAY;
|
||||
|
@ -255,6 +268,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public final int getPreprocessorProblemsCount() {
|
||||
return fLocationResolver == null ? 0 : fLocationResolver.getScannerProblemsCount();
|
||||
}
|
||||
|
@ -264,6 +278,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getFilePath()
|
||||
*/
|
||||
@Override
|
||||
public final String getFilePath() {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
|
@ -290,29 +305,34 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTFileLocation flattenLocationsToFile(IASTNodeLocation[] nodeLocations) {
|
||||
if (fLocationResolver == null)
|
||||
return null;
|
||||
return fLocationResolver.flattenLocations(nodeLocations);
|
||||
}
|
||||
|
||||
public final IDependencyTree getDependencyTree() {
|
||||
@Override
|
||||
public final IDependencyTree getDependencyTree() {
|
||||
if (fLocationResolver == null)
|
||||
return null;
|
||||
return fLocationResolver.getDependencyTree();
|
||||
}
|
||||
|
||||
@Override
|
||||
public final String getContainingFilename(int offset) {
|
||||
if (fLocationResolver == null)
|
||||
return EMPTY_STRING;
|
||||
return fLocationResolver.getContainingFilePath(offset);
|
||||
}
|
||||
|
||||
public final IIndex getIndex() {
|
||||
@Override
|
||||
public final IIndex getIndex() {
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
public final void setIndex(IIndex index) {
|
||||
@Override
|
||||
public final void setIndex(IIndex index) {
|
||||
this.fIndex = index;
|
||||
if (index != null) {
|
||||
fIndexFileSet= index.createFileSet();
|
||||
|
@ -320,7 +340,8 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
public final INodeFactory getASTNodeFactory() {
|
||||
@Override
|
||||
public final INodeFactory getASTNodeFactory() {
|
||||
return fNodeFactory;
|
||||
}
|
||||
|
||||
|
@ -328,6 +349,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
this.fNodeFactory = nodeFactory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTComment[] getComments() {
|
||||
if (fLocationResolver != null) {
|
||||
return fLocationResolver.getComments();
|
||||
|
@ -335,6 +357,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return new IASTComment[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings({ "unchecked", "rawtypes" })
|
||||
public final Object getAdapter(Class adapter) {
|
||||
if (adapter.isAssignableFrom(fLocationResolver.getClass())) {
|
||||
|
@ -349,10 +372,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final boolean isHeaderUnit() {
|
||||
return fIsHeader;
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void setIsHeaderUnit(boolean headerUnit) {
|
||||
fIsHeader= headerUnit;
|
||||
}
|
||||
|
@ -368,6 +393,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.internal.core.parser.scanner.ISkippedIndexedFilesListener#skippedFile(org.eclipse.cdt.internal.core.parser.scanner.IncludeFileContent)
|
||||
*/
|
||||
@Override
|
||||
public void skippedFile(int offset, InternalFileContent fileContent) {
|
||||
if (fIndexFileSet != null) {
|
||||
List<IIndexFile> files= fileContent.getFilesIncluded();
|
||||
|
@ -378,10 +404,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IIndexFileSet getIndexFileSet() {
|
||||
return fIndexFileSet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parsingFile(InternalFileContentProvider provider, InternalFileContent fc) {
|
||||
if (fASTFileSet != null) {
|
||||
if (provider instanceof IndexBasedFileContentProvider) {
|
||||
|
@ -398,6 +426,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IIndexFileSet getASTFileSet() {
|
||||
return fASTFileSet;
|
||||
}
|
||||
|
@ -407,10 +436,12 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getNodeForLocation(org.eclipse.cdt.core.dom.ast.IASTNodeLocation)
|
||||
*/
|
||||
@Override
|
||||
public final IASTNode selectNodeForLocation(String path, int realOffset, int realLength) {
|
||||
return getNodeSelector(path).findNode(realOffset, realLength);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IASTNodeSelector getNodeSelector(String filePath) {
|
||||
return new ASTNodeSelector(this, fLocationResolver, filePath);
|
||||
}
|
||||
|
@ -420,6 +451,11 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*/
|
||||
public abstract void resolveAmbiguities();
|
||||
|
||||
/**
|
||||
* Can be called to create a type for a type-id.
|
||||
*/
|
||||
abstract protected IType createType(IASTTypeId typeid);
|
||||
|
||||
protected void copyAbstractTU(ASTTranslationUnit copy, CopyStyle style) {
|
||||
copy.setIndex(fIndex);
|
||||
copy.fIsHeader = fIsHeader;
|
||||
|
@ -434,6 +470,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
copy.setOffsetAndLength(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final void freeze() {
|
||||
accept(new ASTGenericVisitor(true) {
|
||||
@Override
|
||||
|
@ -449,6 +486,7 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getOriginatingTranslationUnit()
|
||||
*/
|
||||
@Override
|
||||
public ITranslationUnit getOriginatingTranslationUnit() {
|
||||
return fOriginatingTranslationUnit;
|
||||
}
|
||||
|
@ -457,20 +495,24 @@ public abstract class ASTTranslationUnit extends ASTNode implements IASTTranslat
|
|||
this.fOriginatingTranslationUnit = tu;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ISignificantMacros getSignificantMacros() {
|
||||
return fSignificantMacros;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSignificantMacros(ISignificantMacros sigMacros) {
|
||||
assertNotFrozen();
|
||||
if (sigMacros != null)
|
||||
fSignificantMacros= sigMacros;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPragmaOnceSemantics() {
|
||||
return fPragmaOnceSemantics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPragmaOnceSemantics(boolean value) {
|
||||
assertNotFrozen();
|
||||
fPragmaOnceSemantics= value;
|
||||
|
|
|
@ -26,7 +26,6 @@ import org.eclipse.cdt.core.dom.ast.IPointerType;
|
|||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.dom.ast.IValue;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBase;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPClassType;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPEnumeration;
|
||||
import org.eclipse.cdt.core.dom.ast.cpp.ICPPMethod;
|
||||
|
@ -111,7 +110,7 @@ public class SizeofCalculator {
|
|||
public SizeAndAlignment sizeAndAlignment(IType type) {
|
||||
type = SemanticUtil.getNestedType(type, SemanticUtil.CVTYPE | SemanticUtil.TDEF);
|
||||
|
||||
if (type instanceof ICPPBasicType) {
|
||||
if (type instanceof IBasicType) {
|
||||
return sizeAndAlignment((IBasicType) type);
|
||||
}
|
||||
if (type instanceof IPointerType || type instanceof ICPPReferenceType) {
|
||||
|
|
|
@ -37,7 +37,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPTemplateParameterMap;
|
|||
import org.eclipse.cdt.core.parser.util.CharArrayUtils;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.SizeofCalculator.SizeAndAlignment;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.ICPPUnknownBinding;
|
||||
import org.eclipse.cdt.internal.core.dom.parser.cpp.semantics.CPPVisitor;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator;
|
||||
import org.eclipse.cdt.internal.core.parser.scanner.ExpressionEvaluator.EvalException;
|
||||
import org.eclipse.cdt.internal.core.pdom.db.TypeMarshalBuffer;
|
||||
|
@ -118,14 +117,17 @@ public class Value implements IValue {
|
|||
fUnknownBindings= unknown;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getInternalExpression() {
|
||||
return fExpression;
|
||||
}
|
||||
|
||||
@Override
|
||||
public IBinding[] getUnknownBindings() {
|
||||
return fUnknownBindings;
|
||||
}
|
||||
|
||||
@Override
|
||||
public char[] getSignature() {
|
||||
if (fSignature == null) {
|
||||
if (fUnknownBindings.length == 0) {
|
||||
|
@ -148,6 +150,7 @@ public class Value implements IValue {
|
|||
return fSignature;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Long numericalValue() {
|
||||
return parseLong(fExpression);
|
||||
}
|
||||
|
@ -468,8 +471,9 @@ public class Value implements IValue {
|
|||
IASTTypeIdExpression typeIdEx = (IASTTypeIdExpression) e;
|
||||
switch (typeIdEx.getOperator()) {
|
||||
case IASTTypeIdExpression.op_sizeof:
|
||||
IType type = CPPVisitor.createType(typeIdEx.getTypeId());
|
||||
final IType type;
|
||||
ASTTranslationUnit ast = (ASTTranslationUnit) typeIdEx.getTranslationUnit();
|
||||
type = ast.createType(typeIdEx.getTypeId());
|
||||
SizeofCalculator calculator = ast.getSizeofCalculator();
|
||||
SizeAndAlignment info = calculator.sizeAndAlignment(type);
|
||||
if (info == null)
|
||||
|
|
|
@ -16,10 +16,12 @@ import org.eclipse.cdt.core.dom.ILinkage;
|
|||
import org.eclipse.cdt.core.dom.IName;
|
||||
import org.eclipse.cdt.core.dom.ast.EScopeKind;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.ICompositeType;
|
||||
import org.eclipse.cdt.core.dom.ast.IMacroBinding;
|
||||
import org.eclipse.cdt.core.dom.ast.IScope;
|
||||
import org.eclipse.cdt.core.dom.ast.IType;
|
||||
import org.eclipse.cdt.core.parser.ParserLanguage;
|
||||
import org.eclipse.cdt.core.parser.util.ArrayUtil;
|
||||
import org.eclipse.cdt.internal.core.dom.Linkage;
|
||||
|
@ -37,10 +39,12 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
fStructMapper= new CStructMapper(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CASTTranslationUnit copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CASTTranslationUnit copy(CopyStyle style) {
|
||||
CASTTranslationUnit copy = new CASTTranslationUnit();
|
||||
copyAbstractTU(copy, style);
|
||||
|
@ -55,6 +59,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getScope()
|
||||
*/
|
||||
@Override
|
||||
public IScope getScope() {
|
||||
if (compilationUnit == null)
|
||||
compilationUnit = new CScope(this, EScopeKind.eGlobal);
|
||||
|
@ -62,6 +67,7 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
}
|
||||
|
||||
|
||||
@Override
|
||||
public IASTName[] getDeclarationsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
|
@ -69,7 +75,8 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
return CVisitor.getDeclarations(this, binding);
|
||||
}
|
||||
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
@Override
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
}
|
||||
|
@ -87,17 +94,20 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
*
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getReferences(org.eclipse.cdt.core.dom.ast.IBinding)
|
||||
*/
|
||||
@Override
|
||||
public IASTName[] getReferences(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding)
|
||||
return getMacroReferencesInAST((IMacroBinding) binding);
|
||||
return CVisitor.getReferences(this, binding);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
return ParserLanguage.C;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.C_LINKAGE;
|
||||
}
|
||||
|
@ -113,4 +123,9 @@ public class CASTTranslationUnit extends ASTTranslationUnit implements IASTAmbig
|
|||
public ICompositeType mapToASTType(ICompositeType type) {
|
||||
return fStructMapper.mapToAST(type);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IType createType(IASTTypeId typeid) {
|
||||
return CVisitor.createType(typeid.getAbstractDeclarator());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -13,6 +13,7 @@ package org.eclipse.cdt.internal.core.dom.parser.cpp;
|
|||
|
||||
import org.eclipse.cdt.core.dom.ILinkage;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTName;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType;
|
||||
import org.eclipse.cdt.core.dom.ast.IBasicType.Kind;
|
||||
import org.eclipse.cdt.core.dom.ast.IBinding;
|
||||
|
@ -45,10 +46,12 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
public CPPASTTranslationUnit() {
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTTranslationUnit copy() {
|
||||
return copy(CopyStyle.withoutLocations);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CPPASTTranslationUnit copy(CopyStyle style) {
|
||||
CPPASTTranslationUnit copy = new CPPASTTranslationUnit();
|
||||
copyAbstractTU(copy, style);
|
||||
|
@ -58,7 +61,8 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return copy;
|
||||
}
|
||||
|
||||
public CPPNamespaceScope getScope() {
|
||||
@Override
|
||||
public CPPNamespaceScope getScope() {
|
||||
if (fScope == null) {
|
||||
fScope = new CPPNamespaceScope(this);
|
||||
addBuiltinOperators(fScope);
|
||||
|
@ -105,14 +109,16 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
theScope.addBinding(temp);
|
||||
}
|
||||
|
||||
public IASTName[] getDeclarationsInAST(IBinding binding) {
|
||||
@Override
|
||||
public IASTName[] getDeclarationsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
}
|
||||
return CPPVisitor.getDeclarations(this, binding);
|
||||
}
|
||||
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
@Override
|
||||
public IASTName[] getDefinitionsInAST(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroDefinitionsInAST((IMacroBinding) binding);
|
||||
}
|
||||
|
@ -125,20 +131,23 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
return (IASTName[]) ArrayUtil.removeNulls(IASTName.class, names);
|
||||
}
|
||||
|
||||
public IASTName[] getReferences(IBinding binding) {
|
||||
@Override
|
||||
public IASTName[] getReferences(IBinding binding) {
|
||||
if (binding instanceof IMacroBinding) {
|
||||
return getMacroReferencesInAST((IMacroBinding) binding);
|
||||
}
|
||||
return CPPVisitor.getReferences(this, binding);
|
||||
}
|
||||
|
||||
public IBinding resolveBinding() {
|
||||
@Override
|
||||
public IBinding resolveBinding() {
|
||||
if (fBinding == null)
|
||||
fBinding = new CPPNamespace(this);
|
||||
return fBinding;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@Override
|
||||
@Deprecated
|
||||
public ParserLanguage getParserLanguage() {
|
||||
return ParserLanguage.CPP;
|
||||
}
|
||||
|
@ -146,6 +155,7 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.core.dom.ast.IASTTranslationUnit#getLinkage()
|
||||
*/
|
||||
@Override
|
||||
public ILinkage getLinkage() {
|
||||
return Linkage.CPP_LINKAGE;
|
||||
}
|
||||
|
@ -180,4 +190,9 @@ public class CPPASTTranslationUnit extends ASTTranslationUnit implements ICPPAST
|
|||
public void resolveAmbiguities() {
|
||||
accept(new CPPASTAmbiguityResolver());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IType createType(IASTTypeId typeid) {
|
||||
return CPPVisitor.createType(typeid);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue