1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-09-10 12:03:16 +02:00

Compiler warnings.

This commit is contained in:
Markus Schorn 2010-02-23 16:38:04 +00:00
parent 79ece8daa2
commit 290eeeff55
7 changed files with 84 additions and 157 deletions

View file

@ -61,8 +61,7 @@ public class CExternalSettingsDeltaProcessor {
static boolean applyDelta(ICConfigurationDescription des, ExtSettingsDelta deltas[], int kindMask){
ICResourceDescription rcDess[] = des.getResourceDescriptions();
boolean changed = false;
for(int i = 0; i < rcDess.length; i++){
ICResourceDescription rcDes = rcDess[i];
for (ICResourceDescription rcDes : rcDess) {
if(applyDelta(rcDes, deltas, kindMask))
changed = true;
}
@ -147,9 +146,9 @@ public class CExternalSettingsDeltaProcessor {
return false;
boolean changed = false;
for(int i = 0; i < deltas.length; i++){
if(isSettingCompatible(setting, deltas[i].fSetting)){
if(applyDelta(setting, deltas[i], kindMask))
for (ExtSettingsDelta delta : deltas) {
if(isSettingCompatible(setting, delta.fSetting)){
if(applyDelta(setting, delta, kindMask))
changed = true;
}
}
@ -161,10 +160,8 @@ public class CExternalSettingsDeltaProcessor {
if(settings == null || settings.length == 0)
return false;
ICLanguageSetting setting;
boolean changed = false;
for(int k = 0; k < settings.length; k++){
setting = settings[k];
for (ICLanguageSetting setting : settings) {
if(applyDelta(setting, deltas, kindMask))
changed = true;
}
@ -173,9 +170,9 @@ public class CExternalSettingsDeltaProcessor {
static boolean applyDelta(ICLanguageSetting setting, ExtSettingsDelta[] deltas, int kindMask){
boolean changed = false;
for(int i = 0; i < deltas.length; i++){
if(isSettingCompatible(setting, deltas[i].fSetting)){
if(applyDelta(setting, deltas[i], kindMask))
for (ExtSettingsDelta delta : deltas) {
if(isSettingCompatible(setting, delta.fSetting)){
if(applyDelta(setting, delta, kindMask))
changed = true;
}
}
@ -184,12 +181,10 @@ public class CExternalSettingsDeltaProcessor {
static boolean applyDelta(ICLanguageSetting setting, ExtSettingsDelta delta, int kindMask){
int kinds[] = KindBasedStore.getLanguageEntryKinds();
int kind;
ICLanguageSettingEntry entries[];
ICSettingEntry diff[][];
boolean changed = false;
for(int i = 0; i < kinds.length; i++){
kind = kinds[i];
for (int kind : kinds) {
if((kind & kindMask) == 0)
continue;
@ -225,8 +220,7 @@ public class CExternalSettingsDeltaProcessor {
}
}
if(removed != null){
for(int i = 0; i < removed.length; i++){
ICSettingEntry entry = removed[i];
for (ICSettingEntry entry : removed) {
EntryContentsKey cKey = new EntryContentsKey(entry);
ICSettingEntry cur = map.get(cKey);
if(cur != null && !cur.isBuiltIn()){
@ -235,15 +229,15 @@ public class CExternalSettingsDeltaProcessor {
}
}
}
@SuppressWarnings("unchecked")
Collection<T> values = (Collection<T>) map.values();
return changed ? new ArrayList<T>(values) : null;
}
private static boolean isSettingCompatible(ICLanguageSetting setting, CExternalSetting provider){
String ids[] = provider.getCompatibleLanguageIds();
String id;
if(ids != null && ids.length > 0){
id = setting.getLanguageId();
String id = setting.getLanguageId();
if(id != null){
if(contains(ids, id))
return true;
@ -256,8 +250,7 @@ public class CExternalSettingsDeltaProcessor {
if(ids != null && ids.length > 0){
String[] cTypeIds = setting.getSourceContentTypeIds();
if(cTypeIds.length != 0){
for(int i = 0; i < cTypeIds.length; i++){
id = cTypeIds[i];
for (String id : cTypeIds) {
if(contains(ids, id))
return true;
}
@ -270,8 +263,7 @@ public class CExternalSettingsDeltaProcessor {
if(ids != null && ids.length > 0){
String [] srcIds = setting.getSourceExtensions();
if(srcIds.length != 0){
for(int i = 0; i < srcIds.length; i++){
id = srcIds[i];
for (String id : srcIds) {
if(contains(ids, id))
return true;
}
@ -283,8 +275,8 @@ public class CExternalSettingsDeltaProcessor {
}
private static boolean contains(Object array[], Object value){
for(int i = 0; i < array.length; i++){
if(array[i].equals(value))
for (Object element : array) {
if(element.equals(value))
return true;
}
return false;

View file

@ -60,7 +60,7 @@ public class CBasicType implements ICBasicType, ISerializableType {
private static Kind getKind(ICASTSimpleDeclSpecifier sds) {
switch(sds.getType()) {
case ICASTSimpleDeclSpecifier.t_Bool:
case IASTSimpleDeclSpecifier.t_bool:
return Kind.eBoolean;
case IASTSimpleDeclSpecifier.t_char:
return Kind.eChar;

View file

@ -145,9 +145,9 @@ public class CPPASTExpressionList extends ASTNode implements ICPPASTExpressionLi
return overloads = NO_FUNCTIONS;
ASTNodeProperty prop = getPropertyInParent();
if (prop == IASTFunctionCallExpression.PARAMETERS ||
if (prop == IASTFunctionCallExpression.ARGUMENT ||
prop == ICPPASTConstructorChainInitializer.INITIALIZER ||
prop == ICPPASTConstructorInitializer.EXPRESSION ||
prop == ICPPASTConstructorInitializer.ARGUMENT ||
prop == ICPPASTNewExpression.NEW_INITIALIZER)
return overloads = NO_FUNCTIONS;

View file

@ -80,62 +80,42 @@ public class DeclSpecWriter extends NodeWriter {
}
private String getCPPSimpleDecSpecifier(ICPPASTSimpleDeclSpecifier simpDeclSpec) {
int type = simpDeclSpec.getType();
if(type <= IASTSimpleDeclSpecifier.t_last) {
return getASTSimpleDecSpecifier(type);
}
switch (type) {
case ICPPASTSimpleDeclSpecifier.t_bool:
return CPP_BOOL;
case ICPPASTSimpleDeclSpecifier.t_wchar_t:
return WCHAR_T;
default:
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
}
return getASTSimpleDecSpecifier(simpDeclSpec.getType(), true);
}
private String getCSimpleDecSpecifier(ICASTSimpleDeclSpecifier simpDeclSpec) {
int type = simpDeclSpec.getType();
if(type <= IASTSimpleDeclSpecifier.t_last) {
return getASTSimpleDecSpecifier(type);
}
switch (type) {
case ICASTSimpleDeclSpecifier.t_Bool:
return _BOOL;
default:
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
}
return getASTSimpleDecSpecifier(simpDeclSpec.getType(), false);
}
private String getASTSimpleDecSpecifier(int type) {
private String getASTSimpleDecSpecifier(int type, boolean isCpp) {
if(type <= IASTSimpleDeclSpecifier.t_last) {
switch (type) {
case IASTSimpleDeclSpecifier.t_unspecified:
return ""; //$NON-NLS-1$
case IASTSimpleDeclSpecifier.t_void:
return VOID;
case IASTSimpleDeclSpecifier.t_char:
return CHAR;
case IASTSimpleDeclSpecifier.t_int:
return INT;
switch (type) {
case IASTSimpleDeclSpecifier.t_unspecified:
return ""; //$NON-NLS-1$
case IASTSimpleDeclSpecifier.t_void:
return VOID;
case IASTSimpleDeclSpecifier.t_char:
return CHAR;
case IASTSimpleDeclSpecifier.t_int:
return INT;
case IASTSimpleDeclSpecifier.t_float:
return FLOAT;
case IASTSimpleDeclSpecifier.t_double:
return DOUBLE;
default:
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
}
case IASTSimpleDeclSpecifier.t_float:
return FLOAT;
case IASTSimpleDeclSpecifier.t_double:
return DOUBLE;
case IASTSimpleDeclSpecifier.t_bool:
return isCpp ? CPP_BOOL : _BOOL;
case IASTSimpleDeclSpecifier.t_wchar_t:
if (isCpp)
return WCHAR_T;
break;
}
System.err.println("Unknow Specifiertype: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
throw new IllegalArgumentException("Unknow Specifiertype: " + type); //$NON-NLS-1$
}
private void writeCDeclSpec(ICASTDeclSpecifier cDeclSpec) {
@ -205,7 +185,7 @@ public class DeclSpecWriter extends NodeWriter {
if(cppDelcSpec.isFriend()) {
scribe.print(FRIEND);
}
if(cppDelcSpec.getStorageClass() == ICPPASTDeclSpecifier.sc_mutable) {
if(cppDelcSpec.getStorageClass() == IASTDeclSpecifier.sc_mutable) {
scribe.print(MUTABLE);
}

View file

@ -21,6 +21,8 @@ import org.eclipse.cdt.core.dom.ast.IASTExpressionList;
import org.eclipse.cdt.core.dom.ast.IASTFieldReference;
import org.eclipse.cdt.core.dom.ast.IASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.IASTIdExpression;
import org.eclipse.cdt.core.dom.ast.IASTInitializer;
import org.eclipse.cdt.core.dom.ast.IASTInitializerClause;
import org.eclipse.cdt.core.dom.ast.IASTLiteralExpression;
import org.eclipse.cdt.core.dom.ast.IASTProblemExpression;
import org.eclipse.cdt.core.dom.ast.IASTTypeId;
@ -34,7 +36,6 @@ import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFieldReference;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNewExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTSimpleTypeConstructorExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTTypenameExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTUnaryExpression;
import org.eclipse.cdt.core.dom.ast.gnu.IGNUASTTypeIdExpression;
import org.eclipse.cdt.core.dom.ast.gnu.cpp.IGPPASTBinaryExpression;
@ -149,11 +150,7 @@ public class ExpressionWriter extends NodeWriter{
writeDeleteExpression((ICPPASTDeleteExpression) expression);
}else if (expression instanceof ICPPASTSimpleTypeConstructorExpression) {
writeSimpleTypeConstructorExpression((ICPPASTSimpleTypeConstructorExpression) expression);
}else if (expression instanceof ICPPASTTypenameExpression) {
//No example found for this Node
throw new UnsupportedOperationException("You found a example for a TypenameExpression: " + expression.getRawSignature()); //$NON-NLS-1$
}
}
private String getBinaryExpressionOperator(int operator){
@ -252,7 +249,6 @@ public class ExpressionWriter extends NodeWriter{
case ICPPASTUnaryExpression.op_throw:
case ICPPASTUnaryExpression.op_typeid:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return true;
default:
@ -268,7 +264,6 @@ public class ExpressionWriter extends NodeWriter{
case IASTUnaryExpression.op_bracketedPrimary:
case ICPPASTUnaryExpression.op_typeid:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return true;
default:
@ -307,8 +302,6 @@ public class ExpressionWriter extends NodeWriter{
return TYPEID_OP;
case IASTUnaryExpression.op_alignOf:
return ALIGNOF_OP;
case IASTUnaryExpression.op_typeof:
return TYPEOF_OP;
default:
System.err.println("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
throw new IllegalArgumentException("Unkwown unaryExpressionType: " + unaryExpressionType); //$NON-NLS-1$
@ -326,7 +319,6 @@ public class ExpressionWriter extends NodeWriter{
return CLOSING_BRACKET_OP;
case IASTUnaryExpression.op_bracketedPrimary:
case IASTUnaryExpression.op_alignOf:
case IASTUnaryExpression.op_typeof:
return CLOSING_BRACKET_OP;
default:
System.err.println("Unkwown unaryExpressionType " + unaryExpressionType); //$NON-NLS-1$
@ -352,25 +344,36 @@ public class ExpressionWriter extends NodeWriter{
scribe.print(COLON_COLON);
}
scribe.print(NEW);
IASTExpression placement = newExp.getNewPlacement();
visitNodeIfNotNull(placement);
IASTInitializerClause[] placement = newExp.getPlacementArguments();
if (placement != null) {
writeArgumentList(placement);
}
IASTTypeId typeId = newExp.getTypeId();
visitNodeIfNotNull(typeId);
IASTExpression initExp= getNewInitializer(newExp);
IASTInitializer initExp= getNewInitializer(newExp);
if (initExp != null) {
scribe.print('(');
initExp.accept(visitor);
scribe.print(')');
}
}
protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
return newExp.getNewInitializer();
protected IASTInitializer getNewInitializer(ICPPASTNewExpression newExp) {
return newExp.getInitializer();
}
private void writeArgumentList(IASTInitializerClause[] args) {
scribe.print(OPEN_BRACKET_OP);
boolean needComma= false;
for (IASTInitializerClause arg : args) {
if (needComma) {
scribe.print(COMMA_SPACE);
}
arg.accept(visitor);
needComma= true;
}
scribe.print(CLOSING_BRACKET_OP);
}
private void writeLiteralExpression(IASTLiteralExpression litExp) {
scribe.print(litExp.toString());
@ -429,11 +432,7 @@ public class ExpressionWriter extends NodeWriter{
private void writeFunctionCallExpression(IASTFunctionCallExpression funcCallExp) {
funcCallExp.getFunctionNameExpression().accept(visitor);
scribe.print('(');
IASTExpression parameterExpression = funcCallExp.getParameterExpression();
visitNodeIfNotNull(parameterExpression);
scribe.print(')');
writeArgumentList(funcCallExp.getArguments());
}
private void writeCastExpression(IASTCastExpression castExp) {
@ -523,44 +522,8 @@ public class ExpressionWriter extends NodeWriter{
}
private void writeSimpleTypeConstructorExpression(ICPPASTSimpleTypeConstructorExpression simpTypeCtorExp) {
scribe.print(getSimpleTypeString(simpTypeCtorExp.getSimpleType()));
scribe.print('(');
IASTExpression initalizer = simpTypeCtorExp.getInitialValue();
visitNodeIfNotNull(initalizer);
scribe.print(')');
simpTypeCtorExp.getDeclSpecifier().accept(visitor);
visitNodeIfNotNull(simpTypeCtorExp.getInitializer());
}
private String getSimpleTypeString(int typeId) {
switch (typeId) {
case ICPPASTSimpleTypeConstructorExpression.t_void:
return VOID;
case ICPPASTSimpleTypeConstructorExpression.t_char:
return CHAR;
case ICPPASTSimpleTypeConstructorExpression.t_int:
return INT;
case ICPPASTSimpleTypeConstructorExpression.t_float:
return FLOAT;
case ICPPASTSimpleTypeConstructorExpression.t_double:
return DOUBLE;
case ICPPASTSimpleTypeConstructorExpression.t_bool:
return CPP_BOOL;
case ICPPASTSimpleTypeConstructorExpression.t_wchar_t:
return WCHAR_T;
case ICPPASTSimpleTypeConstructorExpression.t_short:
return SHORT;
case ICPPASTSimpleTypeConstructorExpression.t_long:
return LONG;
case ICPPASTSimpleTypeConstructorExpression.t_signed:
return SIGNED;
case ICPPASTSimpleTypeConstructorExpression.t_unsigned :
return UNSIGNED;
default:
System.err.println("Unknown simpleTypeId: " + typeId); //$NON-NLS-1$
throw new IllegalArgumentException("Unknown simpleTypeId: " + typeId); //$NON-NLS-1$
}
}
}

View file

@ -43,34 +43,29 @@ public class ModifiedASTExpressionWriter extends ExpressionWriter {
}
@Override
protected IASTExpression getNewInitializer(ICPPASTNewExpression newExp) {
IASTExpression initializer = newExp.getNewInitializer();
if(initializer != null){
for(ASTModification childModification : modificationHelper.modificationsForNode(initializer)){
switch(childModification.getKind()){
protected IASTInitializer getNewInitializer(ICPPASTNewExpression newExp) {
IASTInitializer initializer = newExp.getInitializer();
if (initializer != null) {
for (ASTModification childModification : modificationHelper.modificationsForNode(initializer)) {
switch (childModification.getKind()) {
case REPLACE:
if(childModification.getNewNode() instanceof IASTInitializer){
return (IASTExpression)childModification.getNewNode();
if (childModification.getNewNode() instanceof IASTInitializer) {
return (IASTInitializer) childModification.getNewNode();
}
break;
case INSERT_BEFORE:
throw new UnhandledASTModificationException(childModification);
case APPEND_CHILD:
throw new UnhandledASTModificationException(childModification);
}
}
}
else
{
for(ASTModification parentModification : modificationHelper.modificationsForNode(newExp)){
if(parentModification.getKind() == ModificationKind.APPEND_CHILD){
} else {
for (ASTModification parentModification : modificationHelper.modificationsForNode(newExp)) {
if (parentModification.getKind() == ModificationKind.APPEND_CHILD) {
IASTNode newNode = parentModification.getNewNode();
if(newNode instanceof IASTInitializer){
return (IASTExpression) newNode;
if (newNode instanceof IASTInitializer) {
return (IASTInitializer) newNode;
}
}
}

View file

@ -33,7 +33,6 @@ import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTLinkageSpecification;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTSwitchStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTTemplateDeclaration;
import org.eclipse.cdt.internal.core.dom.parser.cpp.CPPASTWhileStatement;
import org.eclipse.cdt.internal.core.dom.parser.cpp.GPPASTExplicitTemplateInstantiation;
import org.eclipse.cdt.internal.core.dom.rewrite.util.OffsetHelper;
import org.eclipse.cdt.internal.core.resources.ResourceLookup;
import org.eclipse.core.resources.IFile;
@ -223,8 +222,6 @@ public class NodeCommenter {
return true;
}else if(node instanceof CPPASTLinkageSpecification) {
return true;
}else if(node instanceof GPPASTExplicitTemplateInstantiation) {
return true;
}else if(node instanceof CPPASTExplicitTemplateInstantiation) {
return true;
}