mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-23 17:05:26 +02:00
some GCC builtins : 73954 [Parser] GCC built_in symbols
This commit is contained in:
parent
f56efbce47
commit
da4608ec2c
3 changed files with 567 additions and 6 deletions
|
@ -671,6 +671,35 @@ public class CompletionParseTest extends CompletionParseBaseTest {
|
|||
{
|
||||
results.add( "NMS"); //$NON-NLS-1$
|
||||
results.add( "__builtin_va_list "); //$NON-NLS-1$
|
||||
results.add("__builtin_expect"); //$NON-NLS-1$
|
||||
results.add("__builtin_prefetch"); //$NON-NLS-1$
|
||||
results.add("__builtin_huge_val"); //$NON-NLS-1$
|
||||
results.add("__builtin_huge_valf"); //$NON-NLS-1$
|
||||
results.add("__builtin_huge_vall"); //$NON-NLS-1$
|
||||
results.add("__builtin_inf"); //$NON-NLS-1$
|
||||
results.add("__builtin_inff"); //$NON-NLS-1$
|
||||
results.add("__builtin_infl"); //$NON-NLS-1$
|
||||
results.add("__builtin_nan"); //$NON-NLS-1$
|
||||
results.add("__builtin_nanf"); //$NON-NLS-1$
|
||||
results.add("__builtin_nanl"); //$NON-NLS-1$
|
||||
results.add("__builtin_nans"); //$NON-NLS-1$
|
||||
results.add("__builtin_nansf"); //$NON-NLS-1$
|
||||
results.add("__builtin_nansl"); //$NON-NLS-1$
|
||||
results.add("__builtin_ffs"); //$NON-NLS-1$
|
||||
results.add("__builtin_clz"); //$NON-NLS-1$
|
||||
results.add("__builtin_ctz"); //$NON-NLS-1$
|
||||
results.add("__builtin_popcount"); //$NON-NLS-1$
|
||||
results.add("__builtin_parity"); //$NON-NLS-1$
|
||||
results.add("__builtin_ffsl"); //$NON-NLS-1$
|
||||
results.add("__builtin_clzl"); //$NON-NLS-1$
|
||||
results.add("__builtin_ctzl"); //$NON-NLS-1$
|
||||
results.add("__builtin_popcountl"); //$NON-NLS-1$
|
||||
results.add("__builtin_parityl"); //$NON-NLS-1$
|
||||
results.add("__builtin_ffsll"); //$NON-NLS-1$
|
||||
results.add("__builtin_clzll"); //$NON-NLS-1$
|
||||
results.add("__builtin_ctzll"); //$NON-NLS-1$
|
||||
results.add("__builtin_popcountll"); //$NON-NLS-1$
|
||||
results.add("__builtin_parityll"); //$NON-NLS-1$
|
||||
}
|
||||
validateLookupResult(result, results );
|
||||
}
|
||||
|
|
|
@ -129,4 +129,40 @@ public class GCCCompleteParseExtensionsTest extends CompleteParseBaseTest {
|
|||
}
|
||||
}
|
||||
|
||||
public void testBug73954A() throws Exception{
|
||||
StringWriter writer = new StringWriter();
|
||||
writer.write("void f(){ \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_expect( 23, 2); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_prefetch( (const void *)0, 1, 2); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_huge_val(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_huge_valf(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_huge_vall(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_inf(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_inff(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_infl(); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nan(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nanf(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nanl(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nans(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nansf(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_nansl(\"\"); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ffs (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_clz (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ctz (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_popcount (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_parity (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ffsl (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_clzl (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ctzl (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_popcountl (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_parityl (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ffsll (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_clzll (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_ctzll (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_popcountll (0); \n");//$NON-NLS-1$
|
||||
writer.write(" __builtin_parityll (0); \n");//$NON-NLS-1$
|
||||
writer.write("} \n"); //$NON-NLS-1$
|
||||
|
||||
parse( writer.toString() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,6 +18,7 @@ import java.util.ArrayList;
|
|||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import org.eclipse.cdt.core.parser.BacktrackException;
|
||||
import org.eclipse.cdt.core.parser.GCCKeywords;
|
||||
import org.eclipse.cdt.core.parser.IToken;
|
||||
import org.eclipse.cdt.core.parser.ITokenDuple;
|
||||
|
@ -35,11 +36,14 @@ import org.eclipse.cdt.core.parser.ast.IASTTypeId;
|
|||
import org.eclipse.cdt.core.parser.ast.IASTExpression.IASTNewExpressionDescriptor;
|
||||
import org.eclipse.cdt.core.parser.ast.IASTExpression.Kind;
|
||||
import org.eclipse.cdt.core.parser.ast.gcc.IASTGCCExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.DeclarationWrapper;
|
||||
import org.eclipse.cdt.internal.core.parser.Declarator;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.GCCASTExtension;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTBinaryExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTTypeIdExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ASTUnaryExpression;
|
||||
import org.eclipse.cdt.internal.core.parser.ast.complete.ExpressionFactory;
|
||||
import org.eclipse.cdt.internal.core.parser.token.ImagedToken;
|
||||
import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
||||
|
||||
/**
|
||||
|
@ -48,6 +52,36 @@ import org.eclipse.cdt.internal.core.parser.token.SimpleToken;
|
|||
public class GCCASTCompleteExtension extends GCCASTExtension {
|
||||
|
||||
private static final char [] __BUILTIN_VA_LIST = "__builtin_va_list".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_EXPECT = "__builtin_expect".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_PREFETCH = "__builtin_prefetch".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_HUGE_VAL = "__builtin_huge_val".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_HUGE_VALF = "__builtin_huge_valf".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_HUGE_VALL = "__builtin_huge_vall".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_INF = "__builtin_inf".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_INFF = "__builtin_inff".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_INFL = "__builtin_infl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NAN = "__builtin_nan".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NANF = "__builtin_nanf".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NANL = "__builtin_nanl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NANS = "__builtin_nans".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NANSF = "__builtin_nansf".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_NANSL = "__builtin_nansl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_FFS = "__builtin_ffs".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CLZ = "__builtin_clz".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CTZ = "__builtin_ctz".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_POPCOUNT = "__builtin_popcount".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_PARITY = "__builtin_parity".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_FFSL = "__builtin_ffsl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CLZL = "__builtin_clzl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CTZL = "__builtin_ctzl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_POPCOUNTL = "__builtin_popcountl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_PARITYL = "__builtin_parityl".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_FFSLL = "__builtin_ffsll".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CLZLL = "__builtin_clzll".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_CTZLL = "__builtin_ctzll".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_POPCOUNTLL = "__builtin_popcountll".toCharArray(); //$NON-NLS-1$
|
||||
private static final char [] __BUILTIN_PARITYLL = "__builtin_parityll".toCharArray(); //$NON-NLS-1$
|
||||
|
||||
/**
|
||||
* @param mode
|
||||
*/
|
||||
|
@ -135,17 +169,479 @@ public class GCCASTCompleteExtension extends GCCASTExtension {
|
|||
* @see org.eclipse.cdt.core.parser.extension.IASTFactoryExtension#initialize(org.eclipse.cdt.internal.core.parser.pst.ParserSymbolTable)
|
||||
*/
|
||||
public void initialize(IASTFactory factory, IASTCompilationUnit compilationUnit) {
|
||||
try
|
||||
__builtin_va_list( factory, compilationUnit );
|
||||
__builtin_expect( factory, compilationUnit );
|
||||
__builtin_prefetch( factory, compilationUnit );
|
||||
__builtin_huge_val( factory, compilationUnit );
|
||||
__builtin_inf( factory, compilationUnit );
|
||||
__builtin_nan( factory, compilationUnit );
|
||||
__builtin_unsigned_int( factory, compilationUnit );
|
||||
__builtin_unsigned_long( factory, compilationUnit );
|
||||
__builtin_unsigned_long_long( factory, compilationUnit );
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param compilationUnit
|
||||
*/
|
||||
private void __builtin_inf( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
try {
|
||||
//double __builtin_inf (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_INF, __BUILTIN_INF.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//float __builtin_inff (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.FLOAT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_INFF, __BUILTIN_INFF.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//long double __builtin_infl (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_INFL, __BUILTIN_INFL.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param compilationUnit
|
||||
*/
|
||||
private void __builtin_huge_val( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
try {
|
||||
//double __builtin_huge_val (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_HUGE_VAL, __BUILTIN_HUGE_VAL.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//float __builtin_huge_valf (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.FLOAT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_HUGE_VALF, __BUILTIN_HUGE_VALF.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//long double __builtin_huge_vall (void)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_HUGE_VALL, __BUILTIN_HUGE_VALL.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param compilationUnit
|
||||
*/
|
||||
private void __builtin_prefetch( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
try {
|
||||
//void __builtin_prefetch (const void *addr, ...)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.VOID, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_PREFETCH, __BUILTIN_PREFETCH.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( typeSpec );
|
||||
param.setConst( true );
|
||||
Declarator declarator = new Declarator( param );
|
||||
declarator.addPointerOperator(ASTPointerOperator.POINTER);
|
||||
param.addDeclarator( declarator );
|
||||
d.addParameter( param );
|
||||
d.setIsVarArgs( true );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param compilationUnit
|
||||
*/
|
||||
private void __builtin_expect( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
try {
|
||||
//long __buildin_expect( long exp, long c )
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_long, -1, EMPTY_STRING, -1 ), false, true, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_EXPECT, __BUILTIN_EXPECT.length, EMPTY_STRING, 0 ) );
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
param.setTypeSpecifier( typeSpec );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
d.addParameter( param );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @param factory
|
||||
* @param compilationUnit
|
||||
*/
|
||||
private void __builtin_va_list( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
try
|
||||
{
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.CHAR, new SimpleToken( IToken.t_char, -1, EMPTY_STRING, -1), false, false, false, false, false, false, false, true, Collections.EMPTY_MAP );
|
||||
List pointers = new ArrayList( 1 );
|
||||
pointers.add( ASTPointerOperator.POINTER );
|
||||
IASTAbstractDeclaration abs = factory.createAbstractDeclaration( false, false, typeSpec, pointers, Collections.EMPTY_LIST, Collections.EMPTY_LIST, null );
|
||||
factory.createTypedef( compilationUnit, __BUILTIN_VA_LIST, abs, -1, -1, -1, -1, -1, EMPTY_STRING );
|
||||
} catch( ASTSemanticException ase ) { //nothing
|
||||
}
|
||||
catch( ASTSemanticException ase )
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void __builtin_nan( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
//const char *
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
try {
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.CHAR, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
} catch ( ASTSemanticException e1 ) {//nothing
|
||||
}
|
||||
Declarator paramDecl = new Declarator( param );
|
||||
paramDecl.addPointerOperator( ASTPointerOperator.POINTER );
|
||||
paramDecl.setConst(true);
|
||||
param.addDeclarator( paramDecl );
|
||||
|
||||
try {
|
||||
//double __builtin_nan (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NAN, __BUILTIN_NAN.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//float __builtin_nanf (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.FLOAT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NANF, __BUILTIN_NANF.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//long double __builtin_nanl (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NANL, __BUILTIN_NANL.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//double __builtin_nans (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NANS, __BUILTIN_NANS.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//float __builtin_nansf (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.FLOAT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NANSF, __BUILTIN_NANSF.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
|
||||
try {
|
||||
//long double __builtin_nansl (const char * str)
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.DOUBLE, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_NANSL, __BUILTIN_NANSL.length, EMPTY_STRING, 0 ) );
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
} catch ( BacktrackException e ) { //nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void __builtin_unsigned_int( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
//unsigned int
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
try {
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, true, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
} catch ( ASTSemanticException e1 ) {//nothing
|
||||
}
|
||||
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
|
||||
try {
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ffs(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_FFS, __BUILTIN_FFS.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) { //nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_cls(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CLZ, __BUILTIN_CLZ.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ctz(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CTZ, __BUILTIN_CTZ.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_popcount(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_POPCOUNT, __BUILTIN_POPCOUNT.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
try {//int __builtin_parity(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_PARITY, __BUILTIN_PARITY.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void __builtin_unsigned_long( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
//unsigned long
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
try {
|
||||
param.setTypeSpecifier( factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, true, false, false, false, false, Collections.EMPTY_MAP ) );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
} catch ( ASTSemanticException e1 ) {//nothing
|
||||
}
|
||||
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
|
||||
try {
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ffsl(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_FFSL, __BUILTIN_FFSL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) { //nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_clsl(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CLZL, __BUILTIN_CLZL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ctzl(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CTZL, __BUILTIN_CTZL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_popcountl(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_POPCOUNTL, __BUILTIN_POPCOUNTL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
try {//int __builtin_parityl(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_PARITYL, __BUILTIN_PARITYL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
}
|
||||
|
||||
private void __builtin_unsigned_long_long( IASTFactory factory, IASTCompilationUnit compilationUnit ) {
|
||||
//unsigned long long
|
||||
DeclarationWrapper param = new DeclarationWrapper( compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
try {
|
||||
//TODO: this is just a long, we need to make it long long]
|
||||
IASTSimpleTypeSpecifier spec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, true, false, true, false, false, false, false, Collections.EMPTY_MAP );
|
||||
param.setTypeSpecifier( spec );
|
||||
param.addDeclarator( new Declarator( param ) );
|
||||
} catch ( ASTSemanticException e1 ) {//nothing
|
||||
}
|
||||
|
||||
DeclarationWrapper sdw = new DeclarationWrapper(compilationUnit, 0, 0, null, EMPTY_STRING );
|
||||
Declarator d = new Declarator(sdw);
|
||||
d.setIsFunction( true );
|
||||
|
||||
d.addParameter( param );
|
||||
sdw.addDeclarator( d );
|
||||
|
||||
try {
|
||||
IASTSimpleTypeSpecifier typeSpec = factory.createSimpleTypeSpecifier( compilationUnit, IASTSimpleTypeSpecifier.Type.INT, new SimpleToken( IToken.t_void, -1, EMPTY_STRING, -1 ), false, false, false, false, false, false, false, false, Collections.EMPTY_MAP );
|
||||
sdw.setTypeSpecifier( typeSpec );
|
||||
} catch ( ASTSemanticException e ) { //nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ffsll(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_FFSLL, __BUILTIN_FFSLL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) { //nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_clsll(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CLZLL, __BUILTIN_CLZLL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_ctzll(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_CTZLL, __BUILTIN_CTZLL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
|
||||
try {//int __builtin_popcountll(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_POPCOUNTLL, __BUILTIN_POPCOUNTLL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
try {//int __builtin_parityll(unsigned int x)
|
||||
d.setName( new ImagedToken( IToken.tIDENTIFIER, __BUILTIN_PARITYLL, __BUILTIN_PARITYLL.length, EMPTY_STRING, 0 ) );
|
||||
sdw.createASTNodes( factory );
|
||||
} catch ( ASTSemanticException e2 ) {//nothing
|
||||
} catch ( BacktrackException e2 ) {//nothing
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue