1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

Cosmetics.

This commit is contained in:
Sergey Prigogin 2011-07-30 21:52:14 -07:00
parent 03f572e385
commit 467bbc0b52

View file

@ -79,7 +79,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
// Looking for the variables declarations. // Looking for the variables declarations.
if (declaration instanceof IASTSimpleDeclaration) { if (declaration instanceof IASTSimpleDeclaration) {
// If there is at least one non-pointer and non-reference type... // If there is at least one non-pointer and non-reference type...
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration)declaration; IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier(); IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier();
if (declSpec.getStorageClass() != IASTDeclSpecifier.sc_typedef) { if (declSpec.getStorageClass() != IASTDeclSpecifier.sc_typedef) {
for (IASTDeclarator declarator : simpleDecl.getDeclarators()) { for (IASTDeclarator declarator : simpleDecl.getDeclarators()) {
@ -111,34 +111,33 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
private void checkClass(IASTDeclSpecifier declSpec) { private void checkClass(IASTDeclSpecifier declSpec) {
if (declSpec instanceof ICPPASTNamedTypeSpecifier) { if (declSpec instanceof ICPPASTNamedTypeSpecifier) {
IASTName className = ((ICPPASTNamedTypeSpecifier)declSpec).getName(); IASTName className = ((ICPPASTNamedTypeSpecifier) declSpec).getName();
IBinding binding = className.resolveBinding(); IBinding binding = className.resolveBinding();
if (binding instanceof IType) { if (binding instanceof IType) {
// Resolve class and check whether it is abstract // Resolve class and check whether it is abstract.
reportProblemsIfAbstract((IType)binding, className); reportProblemsIfAbstract((IType) binding, className);
} }
} }
} }
public int visit(IASTExpression expression) { public int visit(IASTExpression expression) {
// Looking for the new expression
if (expression instanceof ICPPASTNewExpression) { if (expression instanceof ICPPASTNewExpression) {
ICPPASTNewExpression newExpression = (ICPPASTNewExpression)expression; // New expression.
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
if (!hasPointerOrReference(newExpression.getTypeId().getAbstractDeclarator())) { if (!hasPointerOrReference(newExpression.getTypeId().getAbstractDeclarator())) {
// Try to resolve its implicit constructor // Try to resolve its implicit constructor
IASTDeclSpecifier declSpecifier = newExpression.getTypeId().getDeclSpecifier(); IASTDeclSpecifier declSpecifier = newExpression.getTypeId().getDeclSpecifier();
if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) { if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
IASTName constructorName = ((ICPPASTNamedTypeSpecifier)declSpecifier).getName(); IASTName constructorName = ((ICPPASTNamedTypeSpecifier) declSpecifier).getName();
checkClassConstructor(constructorName); checkClassConstructor(constructorName);
} }
} }
} } else if (expression instanceof ICPPASTFunctionCallExpression) {
// Looking for direct class constructor call and check it. // Direct constructor call.
else if (expression instanceof ICPPASTFunctionCallExpression) { ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression) expression;
ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression)expression;
IASTExpression functionName = functionCall.getFunctionNameExpression(); IASTExpression functionName = functionCall.getFunctionNameExpression();
if (functionName instanceof IASTIdExpression) { if (functionName instanceof IASTIdExpression) {
IASTName constructorName = ((IASTIdExpression)functionName).getName(); IASTName constructorName = ((IASTIdExpression) functionName).getName();
checkClassConstructor(constructorName); checkClassConstructor(constructorName);
} }
} }
@ -153,10 +152,9 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
IBinding binding = constructorName.resolveBinding(); IBinding binding = constructorName.resolveBinding();
if (binding instanceof ICPPConstructor) { if (binding instanceof ICPPConstructor) {
// Resolve class and check whether it is abstract. // Resolve class and check whether it is abstract.
reportProblemsIfAbstract(((ICPPConstructor)binding).getClassOwner(), constructorName); reportProblemsIfAbstract(((ICPPConstructor) binding).getClassOwner(), constructorName);
} } else if (binding instanceof IType) {
else if (binding instanceof IType) { reportProblemsIfAbstract((IType) binding, constructorName);
reportProblemsIfAbstract((IType)binding, constructorName);
} }
} }
@ -187,7 +185,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) { private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck); IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
if (unwindedType instanceof ICPPClassType) { if (unwindedType instanceof ICPPClassType) {
ICPPClassType classType = (ICPPClassType)unwindedType; ICPPClassType classType = (ICPPClassType) unwindedType;
ICPPMethod[] pureVirtualMethods; ICPPMethod[] pureVirtualMethods;
if (pureVirtualMethodsCache.containsKey(classType)) { if (pureVirtualMethodsCache.containsKey(classType)) {
pureVirtualMethods = pureVirtualMethodsCache.get(classType); pureVirtualMethods = pureVirtualMethodsCache.get(classType);