mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Cosmetics.
This commit is contained in:
parent
03f572e385
commit
467bbc0b52
1 changed files with 15 additions and 17 deletions
|
@ -79,7 +79,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
// Looking for the variables declarations.
|
||||
if (declaration instanceof IASTSimpleDeclaration) {
|
||||
// If there is at least one non-pointer and non-reference type...
|
||||
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration)declaration;
|
||||
IASTSimpleDeclaration simpleDecl = (IASTSimpleDeclaration) declaration;
|
||||
IASTDeclSpecifier declSpec = simpleDecl.getDeclSpecifier();
|
||||
if (declSpec.getStorageClass() != IASTDeclSpecifier.sc_typedef) {
|
||||
for (IASTDeclarator declarator : simpleDecl.getDeclarators()) {
|
||||
|
@ -111,34 +111,33 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
|
||||
private void checkClass(IASTDeclSpecifier declSpec) {
|
||||
if (declSpec instanceof ICPPASTNamedTypeSpecifier) {
|
||||
IASTName className = ((ICPPASTNamedTypeSpecifier)declSpec).getName();
|
||||
IASTName className = ((ICPPASTNamedTypeSpecifier) declSpec).getName();
|
||||
IBinding binding = className.resolveBinding();
|
||||
if (binding instanceof IType) {
|
||||
// Resolve class and check whether it is abstract
|
||||
reportProblemsIfAbstract((IType)binding, className);
|
||||
// Resolve class and check whether it is abstract.
|
||||
reportProblemsIfAbstract((IType) binding, className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public int visit(IASTExpression expression) {
|
||||
// Looking for the new expression
|
||||
if (expression instanceof ICPPASTNewExpression) {
|
||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression)expression;
|
||||
// New expression.
|
||||
ICPPASTNewExpression newExpression = (ICPPASTNewExpression) expression;
|
||||
if (!hasPointerOrReference(newExpression.getTypeId().getAbstractDeclarator())) {
|
||||
// Try to resolve its implicit constructor
|
||||
IASTDeclSpecifier declSpecifier = newExpression.getTypeId().getDeclSpecifier();
|
||||
if (declSpecifier instanceof ICPPASTNamedTypeSpecifier) {
|
||||
IASTName constructorName = ((ICPPASTNamedTypeSpecifier)declSpecifier).getName();
|
||||
IASTName constructorName = ((ICPPASTNamedTypeSpecifier) declSpecifier).getName();
|
||||
checkClassConstructor(constructorName);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Looking for direct class constructor call and check it.
|
||||
else if (expression instanceof ICPPASTFunctionCallExpression) {
|
||||
ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression)expression;
|
||||
} else if (expression instanceof ICPPASTFunctionCallExpression) {
|
||||
// Direct constructor call.
|
||||
ICPPASTFunctionCallExpression functionCall = (ICPPASTFunctionCallExpression) expression;
|
||||
IASTExpression functionName = functionCall.getFunctionNameExpression();
|
||||
if (functionName instanceof IASTIdExpression) {
|
||||
IASTName constructorName = ((IASTIdExpression)functionName).getName();
|
||||
IASTName constructorName = ((IASTIdExpression) functionName).getName();
|
||||
checkClassConstructor(constructorName);
|
||||
}
|
||||
}
|
||||
|
@ -153,10 +152,9 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
IBinding binding = constructorName.resolveBinding();
|
||||
if (binding instanceof ICPPConstructor) {
|
||||
// Resolve class and check whether it is abstract.
|
||||
reportProblemsIfAbstract(((ICPPConstructor)binding).getClassOwner(), constructorName);
|
||||
}
|
||||
else if (binding instanceof IType) {
|
||||
reportProblemsIfAbstract((IType)binding, constructorName);
|
||||
reportProblemsIfAbstract(((ICPPConstructor) binding).getClassOwner(), constructorName);
|
||||
} else if (binding instanceof IType) {
|
||||
reportProblemsIfAbstract((IType) binding, constructorName);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,7 +185,7 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
|
|||
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
|
||||
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
|
||||
if (unwindedType instanceof ICPPClassType) {
|
||||
ICPPClassType classType = (ICPPClassType)unwindedType;
|
||||
ICPPClassType classType = (ICPPClassType) unwindedType;
|
||||
ICPPMethod[] pureVirtualMethods;
|
||||
if (pureVirtualMethodsCache.containsKey(classType)) {
|
||||
pureVirtualMethods = pureVirtualMethodsCache.get(classType);
|
||||
|
|
Loading…
Add table
Reference in a new issue