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

Merge branch 'cdt_8_0' of ssh://rarohrba@git.eclipse.org/gitroot/cdt/org.eclipse.cdt.git into cdt_8_0

This commit is contained in:
Randy Rohrbach 2011-08-31 13:44:51 -04:00
commit decd827478
62 changed files with 405 additions and 213 deletions

View file

@ -11,6 +11,6 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gnu.build-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.build</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.gnu.build.source-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.pde.FeatureBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.pde.FeatureNature</nature>
</natures>
</projectDescription>

View file

@ -11,6 +11,6 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gnu.build.source-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.build.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -52,7 +52,7 @@ problem.name.FormatString = Format String Vulnerability
checker.name.AssignmentToItself = Assignment to itself
problem.messagePattern.AssignmentToItself = Assignment to itself ''{0}''
problem.name.AssignmentToItself = Assignment to itself
problem.description.AssignmentToItself = Finds expression where left and right side of the assignment is the same, i.e. 'var = var'
problem.description.AssignmentToItself = Finds expression where left and right sides of the assignment are the same, i.e. 'var = var'
checker.name.ReturnStyle = Return with parenthesis
problem.name.ReturnStyle = Return with parenthesis
problem.messagePattern.ReturnStyle = Return statement has invalid style. Return value should be surrounded by parenthesis
@ -60,10 +60,10 @@ problem.description.ReturnStyle = Checks for return statements that do no return
checker.name.SuspiciousSemicolon = Suspicious semicolon
problem.name.SuspiciousSemicolon = Suspicious semicolon
problem.messagePattern.SuspiciousSemicolon = Suspicious semicolon
problem.description.SuspiciousSemicolon = A semicolon is used as a null statement in a condition. For example, 'if(expression);'
problem.description.SuspiciousSemicolon = A semicolon is used as a null statement in a condition. For example, 'if (expression);'
checker.name.CaseBreak = No break at end of case
problem.description.CaseBreak = Looks for "case" statements which end without a "break" statement
problem.messagePattern.CaseBreak = No break at the end of this case
problem.messagePattern.CaseBreak = No break at the end of case
binding.checker.name = Problem Binding Checker
problem.description.G = Name resolution problem found by the indexer
problem.messagePattern.G = Symbol ''{0}'' could not be resolved

View file

@ -7,6 +7,7 @@
*
* Contributors:
* Anton Gorenkov - initial implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers;
@ -30,6 +31,7 @@ import org.eclipse.cdt.core.dom.ast.IASTParameterDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTSimpleDeclaration;
import org.eclipse.cdt.core.dom.ast.IASTTranslationUnit;
import org.eclipse.cdt.core.dom.ast.IBinding;
import org.eclipse.cdt.core.dom.ast.IProblemBinding;
import org.eclipse.cdt.core.dom.ast.IType;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTFunctionCallExpression;
import org.eclipse.cdt.core.dom.ast.cpp.ICPPASTNamedTypeSpecifier;
@ -179,22 +181,23 @@ public class AbstractClassInstantiationChecker extends AbstractIndexAstChecker {
}
/**
* Checks whether specified type (class or typedef to the class) is abstract class.
* If it is - reports violations on each pure virtual method
* Checks whether specified type (class or typedef to the class) is an abstract class.
* If it is, reports violations on each pure virtual method
*/
private void reportProblemsIfAbstract(IType typeToCheck, IASTNode problemNode ) {
IType unwindedType = CxxAstUtils.getInstance().unwindTypedef(typeToCheck);
if (unwindedType instanceof ICPPClassType) {
ICPPClassType classType = (ICPPClassType) unwindedType;
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
if (pureVirtualMethods == null) {
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
}
for (ICPPMethod method : pureVirtualMethods) {
reportProblem(ER_ID, problemNode, resolveName(classType), resolveName(method));
}
if (!(unwindedType instanceof ICPPClassType) || unwindedType instanceof IProblemBinding) {
return;
}
ICPPClassType classType = (ICPPClassType) unwindedType;
ICPPMethod[] pureVirtualMethods = pureVirtualMethodsCache.get(classType);
if (pureVirtualMethods == null) {
pureVirtualMethods = ClassTypeHelper.getPureVirtualMethods(classType);
pureVirtualMethodsCache.put(classType, pureVirtualMethods);
}
for (ICPPMethod method : pureVirtualMethods) {
reportProblem(ER_ID, problemNode, resolveName(classType), resolveName(method));
}
}
}

View file

@ -1,13 +1,14 @@
/*******************************************************************************
* Copyright (c) 2010,2011 Gil Barash
* Copyright (c) 2010, 2011 Gil Barash
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Gil Barash - Initial implementation
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
* Gil Barash - Initial implementation
* Elena laskavaia - Rewrote checker to reduce false positives in complex cases
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers;
@ -50,8 +51,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
}
/**
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on
* them.
* This visitor looks for "switch" statements and invokes "SwitchVisitor" on them.
*/
class SwitchFindingVisitor extends ASTVisitor {
SwitchFindingVisitor() {
@ -67,7 +67,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
* - "continue"
* - "goto" (does not check that the goto actually exists the
* switch)
* - "thorw"
* - "throw"
* - "exit"
*/
protected boolean isBreakOrExitStatement(IASTStatement statement) {
@ -83,7 +83,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
IASTSwitchStatement switchStmt = (IASTSwitchStatement) statement;
IASTStatement body = switchStmt.getBody();
if (body instanceof IASTCompoundStatement) {
// if not it is not really a switch
// If not it is not really a switch
IASTStatement[] statements = ((IASTCompoundStatement) body).getStatements();
IASTStatement prevCase = null;
for (int i = 0; i < statements.length; i++) {
@ -97,16 +97,16 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
if (isCaseStatement(curr)) {
prevCase = curr;
}
// next is case or end of switch - means this one is the last
// Next is case or end of switch - means this one is the last
if (prevCase != null && (isCaseStatement(next) || next == null)) {
// check that current statement end with break or any other exit statement
// Check that current statement end with break or any other exit statement
if (!_checkEmptyCase && isCaseStatement(curr) && next != null) {
continue; // empty case & we don't care
continue; // Empty case and we don't care
}
if (!_checkLastCase && next == null) {
continue; // last case and we don't care
continue; // Last case and we don't care
}
if (isFallThroughStamement(curr)) {
if (!isProducedByMacroExpansion(prevCase) && isFallThroughStamement(curr)) {
IASTComment comment = null;
if (next != null) {
comment = getLeadingComment(next);
@ -139,7 +139,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
}
/**
* @param nextstatement
* @param body
* @return
*/
public boolean isFallThroughStamement(IASTStatement body) {
@ -171,13 +171,11 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
IASTFileLocation astLocation = astNode.getFileLocation();
int line = astLocation.getEndingLineNumber();
IProblemLocationFactory locFactory = getRuntime().getProblemLocationFactory();
return locFactory.createProblemLocation(getFile(), -1,
-1, line);
return locFactory.createProblemLocation(getFile(), -1, -1, line);
}
/**
* Checks if the given statement is a result of macro expansion with a
* possible
* Checks if the given statement is a result of macro expansion with a possible
* exception for the trailing semicolon.
*
* @param statement the statement to check.

View file

@ -9,17 +9,17 @@
# Alena Laskavaia - initial API and implementation
###############################################################################
CaseBreakChecker_DefaultNoBreakCommentDescription=Comment text to suppress the problem:
CaseBreakChecker_EmptyCaseDescription=Check also empty case statement (except if last)
CaseBreakChecker_LastCaseDescription=Check also the last case statement
CaseBreakChecker_EmptyCaseDescription=Check also empty 'case' statement (except if last)
CaseBreakChecker_LastCaseDescription=Check also the last 'case' statement
CatchByReference_ReportForUnknownType=Report a problem if type cannot be resolved
NamingConventionFunctionChecker_LabelNamePattern=Name Pattern
NamingConventionFunctionChecker_ParameterMethods=Also check C++ method names
ReturnChecker_Param0=Also check functions with implicit return value
GenericParameter_ParameterExceptions=Exceptions (value of the problem argument)
GenericParameter_ParameterExceptionsItem=Value of the argument
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that comes from macro expansion
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around not operator
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after else statement
StatementHasNoEffectChecker_ParameterMacro=Report problem in statements that come from macro expansion
SuggestedParenthesisChecker_SuggestParanthesesAroundNot=Suggest parenthesis around 'not' operator
SuspiciousSemicolonChecker_ParamAfterElse=Report an error if semicolon is right after 'else' statement
SuspiciousSemicolonChecker_ParamElse=Do not report an error after 'if' when 'else' exists
ProblemBindingChecker_Candidates=Candidates are:

View file

@ -57,9 +57,7 @@ public class StatementHasNoEffectChecker extends AbstractIndexAstChecker {
if (stmt instanceof IASTExpressionStatement) {
IASTExpression expression = ((IASTExpressionStatement) stmt).getExpression();
if (hasNoEffect(expression)) {
boolean inMacro = CxxAstUtils.getInstance().isInMacro(expression);
boolean shouldReportInMacro = shouldReportInMacro();
if (inMacro && !shouldReportInMacro)
if (!shouldReportInMacro() && CxxAstUtils.isInMacro(expression))
return PROCESS_SKIP;
String arg = expression.getRawSignature();
if (!isFilteredArg(arg))

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev - initial API and implementation
* Andrew Gvozdev - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.internal.checkers;
@ -18,6 +19,7 @@ import java.util.Map;
import java.util.Map.Entry;
import org.eclipse.cdt.codan.checkers.CodanCheckersActivator;
import org.eclipse.cdt.codan.core.cxx.CxxAstUtils;
import org.eclipse.cdt.codan.core.cxx.model.AbstractIndexAstChecker;
import org.eclipse.cdt.codan.core.model.IProblem;
import org.eclipse.cdt.codan.core.model.IProblemWorkingCopy;
@ -54,6 +56,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
public static final String ER_UNUSED_VARIABLE_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedVariableDeclarationProblem"; //$NON-NLS-1$
public static final String ER_UNUSED_FUNCTION_DECLARATION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedFunctionDeclarationProblem"; //$NON-NLS-1$
public static final String ER_UNUSED_STATIC_FUNCTION_ID = "org.eclipse.cdt.codan.internal.checkers.UnusedStaticFunctionProblem"; //$NON-NLS-1$
public static final String PARAM_MACRO_ID = "macro"; //$NON-NLS-1$
public static final String PARAM_EXCEPT_ARG_LIST = "exceptions"; //$NON-NLS-1$
private Map<IBinding, IASTDeclarator> externFunctionDeclarations = new HashMap<IBinding, IASTDeclarator>();
@ -71,6 +74,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
@Override
public void initPreferences(IProblemWorkingCopy problem) {
super.initPreferences(problem);
addPreference(problem, PARAM_MACRO_ID, CheckersMessages.StatementHasNoEffectChecker_ParameterMacro, Boolean.TRUE);
if (problem.getId().equals(ER_UNUSED_VARIABLE_DECLARATION_ID)) {
unusedVariableProblem = problem;
ListProblemPreference pref = addListPreference(problem, PARAM_EXCEPT_ARG_LIST,
@ -90,11 +94,11 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
}
private boolean isAnyCandidate() {
return externFunctionDeclarations.size() > 0 ||
staticFunctionDeclarations.size() > 0 ||
staticFunctionDefinitions.size() > 0 ||
externVariableDeclarations.size() > 0 ||
staticVariableDeclarations.size() > 0;
return !externFunctionDeclarations.isEmpty() ||
!staticFunctionDeclarations.isEmpty() ||
!staticFunctionDefinitions.isEmpty() ||
!externVariableDeclarations.isEmpty() ||
!staticVariableDeclarations.isEmpty();
}
public void processAst(IASTTranslationUnit ast) {
@ -131,42 +135,51 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
int storageClass = simpleDeclaration.getDeclSpecifier().getStorageClass();
if (binding instanceof IFunction) {
if (storageClass == IASTDeclSpecifier.sc_extern || storageClass == IASTDeclSpecifier.sc_unspecified) {
externFunctionDeclarations.put(binding, decl);
} else if (storageClass == IASTDeclSpecifier.sc_static) {
staticFunctionDeclarations.put(binding, decl);
}
} else if (binding instanceof IVariable) {
if (storageClass == IASTDeclSpecifier.sc_extern) {
IASTInitializer initializer = decl.getInitializer();
// initializer makes "extern" declaration to become definition do not count these
if (initializer==null) {
externVariableDeclarations.put(binding, decl);
if (storageClass == IASTDeclSpecifier.sc_extern ||
storageClass == IASTDeclSpecifier.sc_unspecified) {
if (shouldReportInMacro(ER_UNUSED_FUNCTION_DECLARATION_ID) ||
!CxxAstUtils.isInMacro(astName)) {
externFunctionDeclarations.put(binding, decl);
}
} else if (storageClass == IASTDeclSpecifier.sc_static) {
IType type = ((IVariable) binding).getType();
// account for class constructor and avoid possible false positive
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
// check if initializer disqualifies it
IASTInitializer initializer = decl.getInitializer();
IASTInitializerClause clause = null;
if (initializer instanceof IASTEqualsInitializer) {
IASTEqualsInitializer equalsInitializer = (IASTEqualsInitializer) initializer;
clause = equalsInitializer.getInitializerClause();
} else if (initializer instanceof ICPPASTConstructorInitializer) {
ICPPASTConstructorInitializer constructorInitializer = (ICPPASTConstructorInitializer) initializer;
IASTInitializerClause[] args = constructorInitializer.getArguments();
if (args.length==1)
clause = args[0];
if (shouldReportInMacro(ER_UNUSED_STATIC_FUNCTION_ID) ||
!CxxAstUtils.isInMacro(astName)) {
staticFunctionDeclarations.put(binding, decl);
}
}
} else if (binding instanceof IVariable) {
if (shouldReportInMacro(ER_UNUSED_VARIABLE_DECLARATION_ID) ||
!CxxAstUtils.isInMacro(astName)) {
if (storageClass == IASTDeclSpecifier.sc_extern) {
// Initializer makes "extern" declaration to become definition do not count these
if (decl.getInitializer() == null) {
externVariableDeclarations.put(binding, decl);
}
if (clause instanceof IASTLiteralExpression) {
IASTLiteralExpression literalExpression = (IASTLiteralExpression) clause;
String literal = literalExpression.toString();
if (isFilteredOut(literal, unusedVariableProblem, PARAM_EXCEPT_ARG_LIST))
continue;
} else if (storageClass == IASTDeclSpecifier.sc_static) {
IType type = ((IVariable) binding).getType();
// Account for class constructor and avoid possible false positive
if (!(type instanceof ICPPClassType) && !(type instanceof IProblemType)) {
// Check if initializer disqualifies it
IASTInitializer initializer = decl.getInitializer();
IASTInitializerClause clause = null;
if (initializer instanceof IASTEqualsInitializer) {
IASTEqualsInitializer equalsInitializer = (IASTEqualsInitializer) initializer;
clause = equalsInitializer.getInitializerClause();
} else if (initializer instanceof ICPPASTConstructorInitializer) {
ICPPASTConstructorInitializer constructorInitializer = (ICPPASTConstructorInitializer) initializer;
IASTInitializerClause[] args = constructorInitializer.getArguments();
if (args.length == 1)
clause = args[0];
}
if (clause instanceof IASTLiteralExpression) {
IASTLiteralExpression literalExpression = (IASTLiteralExpression) clause;
String literal = literalExpression.toString();
if (isFilteredOut(literal, unusedVariableProblem, PARAM_EXCEPT_ARG_LIST))
continue;
}
staticVariableDeclarations.put(binding, decl);
}
staticVariableDeclarations.put(binding, decl);
}
}
}
@ -232,7 +245,12 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
staticFunctionDefinitions.remove(binding);
}
if (!(parentNode instanceof IASTDeclarator)) {
if (parentNode instanceof IASTDeclarator) {
// Initializer makes "extern" declaration to become definition.
if (((IASTDeclarator) parentNode).getInitializer() != null) {
externVariableDeclarations.remove(binding);
}
} else {
externVariableDeclarations.remove(binding);
staticVariableDeclarations.remove(binding);
}
@ -310,7 +328,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
clearCandidates(); // release memory
}
public boolean isFilteredOut(String arg, IProblem problem, String exceptionListParamId) {
private boolean isFilteredOut(String arg, IProblem problem, String exceptionListParamId) {
Object[] arr = (Object[]) getPreference(problem, exceptionListParamId);
for (int i = 0; i < arr.length; i++) {
String str = (String) arr[i];
@ -320,4 +338,7 @@ public class UnusedSymbolInFileScopeChecker extends AbstractIndexAstChecker {
return false;
}
private boolean shouldReportInMacro(String errorId) {
return (Boolean) getPreference(getProblemById(errorId, getFile()), PARAM_MACRO_ID);
}
}

View file

@ -121,7 +121,7 @@ public final class CxxAstUtils {
return (IType) typeName;
}
public boolean isInMacro(IASTNode node) {
public static boolean isInMacro(IASTNode node) {
IASTNodeSelector nodeSelector = node.getTranslationUnit().getNodeSelector(node.getTranslationUnit().getFilePath());
IASTFileLocation fileLocation = node.getFileLocation();
IASTPreprocessorMacroExpansion macro = nodeSelector.findEnclosingMacroExpansion(fileLocation.getNodeOffset(),

View file

@ -12,7 +12,7 @@
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.codan.core.tests</artifactId>
<artifactId>org.eclipse.cdt.codan.core.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<build>

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Gil Barash - Initial implementation
* Gil Barash - Initial implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.core.internal.checkers;
@ -383,11 +384,11 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
}
// void foo(void) {
// int a, b;
// switch( a ) {
// case 1:
// b = 2;
// }
// int a, b;
// switch( a ) {
// case 1:
// b = 2;
// }
// }
public void testLastCaseIgnore() {
setLast(false);
@ -474,12 +475,12 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
}
// void foo(void) {
// int a;
// switch( a ) {
// case 2:
// int a;
// switch( a ) {
// case 2:
// break;
// case 1:
// }
// case 1:
// }
// }
public void testEmptyLastCaseError() {
String code = getAboveComment();
@ -493,31 +494,32 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
}
// void foo(int a) {
// switch( a ) {
// case 2:
// switch( a ) {
// case 2:
// if (a*2<10)
// return;
// return;
// else
// break;
// case 1:
// break;
// }
// break;
// case 1:
// break;
// }
// }
public void testIf() {
String code = getAboveComment();
loadCodeAndRun(code);
checkNoErrors();
}
// void foo(int a) {
// switch( a ) {
// case 2:
// switch(a) {
// case 2:
// if (a*2<10)
// return;
// return;
// else
// a++;
// case 1:
// break;
// }
// a++;
// case 1:
// break;
// }
// }
public void testIfErr() {
String code = getAboveComment();
@ -525,53 +527,43 @@ public class CaseBreakCheckerTest extends CheckerTestCase {
checkErrorLine(7);
}
// #define DEFINE_BREAK {break;}
// void foo ( int a )
// {
// switch ( a )
// {
// case 1:
// DEFINE_BREAK // <-- Warning: No break at the end of this case
// }
// }
// #define DEFINE_BREAK {break;}
// void foo(int a) {
// switch (a) {
// case 1:
// DEFINE_BREAK // No warning here
// }
// }
public void testBreakInBraces() {
String code = getAboveComment();
loadCodeAndRun(code);
checkNoErrors();
}
// #define MY_MACRO(i) \
// case i: \
// { \
// break; \
// }
//
// void f()
// {
// int x;
// switch (x)
// {
// MY_MACRO(1) // WARNING HERE
// }
// }
// #define MY_MACRO(i) \
// case i: { \
// }
//
// void f() {
// int x;
// switch (x) {
// MY_MACRO(1) // No warning here
// }
// }
public void testInMacro() {
String code = getAboveComment();
loadCodeAndRun(code);
checkNoErrors();
}
//void foo()
//{
//switch(0)
//default:
//{
//}
//}
public void testEmptyCompoundStatement() {
String code = getAboveComment();
loadCodeAndRun(code);
checkErrorLine(6);
}
// void foo() {
// switch (0)
// default: {
// }
// }
public void testEmptyCompoundStatement() {
String code = getAboveComment();
loadCodeAndRun(code);
checkErrorLine(4);
}
}

View file

@ -6,7 +6,8 @@
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* Andrew Gvozdev - initial API and implementation
* Andrew Gvozdev - initial API and implementation
* Sergey Prigogin (Google)
*******************************************************************************/
package org.eclipse.cdt.codan.core.internal.checkers;
@ -17,7 +18,6 @@ import org.eclipse.cdt.codan.internal.checkers.UnusedSymbolInFileScopeChecker;
/**
* Test for {@see UnusedSymbolInFileScopeChecker} class
*
*/
public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
@Override
@ -222,8 +222,15 @@ public class UnusedSymbolInFileScopeCheckerTest extends CheckerTestCase {
checkNoErrors();
}
// extern int test_var=0; // not quite legal but some compilers allow that
public void testExternVariable_Definition() throws IOException {
// extern const int test_var=0; // not quite legal but some compilers allow that
public void testExternVariable_Definition1() throws IOException {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}
// extern const int test_var;
// const int test_var = 0;
public void testExternVariable_Definition2() throws IOException {
loadCodeAndRun(getAboveComment());
checkNoErrors();
}

View file

@ -8,9 +8,9 @@
# Contributors:
# IBM Corporation - initial API and implementation
###############################################################################
source.cdtaix.jar = src/
source.. = src/
bin.includes = fragment.xml,\
cdtaix.jar,\
.,\
about.html,\
META-INF/,\
os/

View file

@ -10,8 +10,8 @@
###############################################################################
bin.includes = fragment.xml,\
about.html,\
cdt_linux.jar,\
.,\
META-INF/
src.includes = about.html,\
library/
source.cdt_linux.jar = src/
source.. = src/

View file

@ -10,9 +10,9 @@
###############################################################################
bin.includes = fragment.xml,\
about.html,\
cdt_macosx.jar,\
.,\
os/,\
META-INF/
src.includes = about.html,\
library/
source.cdt_macosx.jar = src/
source.. = src/

View file

@ -11,8 +11,8 @@
bin.includes = fragment.xml,\
about.html,\
os/,\
cdt_solaris.jar,\
.,\
META-INF/
src.includes = about.html,\
library/
source.cdt_solaris.jar = src/
source.. = src/

View file

@ -15,6 +15,14 @@
<artifactId>org.eclipse.cdt.core.tests</artifactId>
<packaging>eclipse-test-plugin</packaging>
<repositories>
<repository>
<id>cdt.repo</id>
<url>file:/${basedir}/../../releng/org.eclipse.cdt.repo/target/repository</url>
<layout>p2</layout>
</repository>
</repositories>
<build>
<plugins>
<plugin>
@ -28,6 +36,13 @@
<include>**/AutomatedIntegrationSuite.*</include>
</includes>
<testFailureIgnore>true</testFailureIgnore>
<dependencies>
<dependency>
<artifactId>org.eclipse.cdt.feature.group</artifactId>
<version>8.0.0.${buildQualifier}</version>
<type>p2-installable-unit</type>
</dependency>
</dependencies>
</configuration>
</plugin>
</plugins>

View file

@ -10,8 +10,8 @@
###############################################################################
bin.includes = fragment.xml,\
about.html,\
cdt_win32.jar,\
.,\
META-INF/
src.includes = about.html,\
library/
source.cdt_win32.jar = src/
source.. = src/

View file

@ -310,12 +310,13 @@ public class ClassTypeHelper {
/**
* Returns methods either declared by the given class or generated by the compiler. Does not
* include methods declared in base classes.
* @param classType
* @return
*/
private static ObjectSet<ICPPMethod> getOwnMethods(ICPPClassType classType) {
ObjectSet<ICPPMethod> set= new ObjectSet<ICPPMethod>(4);
set.addAll(classType.getDeclaredMethods());
if (classType instanceof IProblemBinding) {
return set;
}
ICPPClassScope scope= (ICPPClassScope) classType.getCompositeScope();
set.addAll(scope.getImplicitMethods());
return set;

View file

@ -838,3 +838,22 @@ void TestClass::foo()
{
}
//!Bug 355006 - NPE implementing template function
//#org.eclipse.cdt.ui.tests.refactoring.implementmethod.ImplementMethodRefactoringTest
//@.config
filename=A.h
infos=1
//@A.h
/*$*/template<typename T> void func(T&);/*$$*/
//=
template<typename T> void func(T&);
template<typename T> inline void func(T& )
{
}

View file

@ -260,15 +260,16 @@ public class ImplementMethodRefactoring extends CRefactoring2 {
IASTFunctionDefinition functionDefinition = nodeFactory.newFunctionDefinition(declSpecifier, createdMethodDeclarator, nodeFactory.newCompoundStatement());
functionDefinition.setParent(unit);
if (NodeHelper.isContainedInTemplateDeclaration(declarationParent)) {
ICPPASTTemplateDeclaration templateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
templateDeclaration.setParent(unit);
ICPPASTTemplateDeclaration templateDeclaration = NodeHelper.findContainedTemplateDecalaration(declarationParent);
if (templateDeclaration != null) {
ICPPASTTemplateDeclaration newTemplateDeclaration = nodeFactory.newTemplateDeclaration(functionDefinition);
newTemplateDeclaration.setParent(unit);
for (ICPPASTTemplateParameter templateParameter : ((ICPPASTTemplateDeclaration) declarationParent.getParent().getParent() ).getTemplateParameters()) {
templateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
for (ICPPASTTemplateParameter templateParameter : templateDeclaration.getTemplateParameters()) {
newTemplateDeclaration.addTemplateParameter(templateParameter.copy(CopyStyle.withLocations));
}
return templateDeclaration;
return newTemplateDeclaration;
}
return functionDefinition;
}

View file

@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2008, 2009 Institute for Software, HSR Hochschule fuer Technik
* Copyright (c) 2008, 2011 Institute for Software, HSR Hochschule fuer Technik
* Rapperswil, University of applied sciences and others
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
@ -212,11 +212,16 @@ public class NodeHelper {
}
public static boolean isContainedInTemplateDeclaration(IASTNode node) {
if (node == null) {
return false;
} else if (node instanceof ICPPASTTemplateDeclaration) {
return true;
return findContainedTemplateDecalaration(node) != null;
}
public static ICPPASTTemplateDeclaration findContainedTemplateDecalaration(IASTNode node) {
while (node != null) {
if (node instanceof ICPPASTTemplateDeclaration) {
return (ICPPASTTemplateDeclaration) node;
}
node = node.getParent();
}
return isContainedInTemplateDeclaration(node.getParent());
return null;
}
}

View file

@ -12,6 +12,7 @@
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.build.crossgcc-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.build.crossgcc</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -11,7 +11,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gdb-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.gdb</artifactId>
<packaging>eclipse-feature</packaging>
<version>7.0.0-SNAPSHOT</version>
</project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.gdb.source-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gdb.source-feature</artifactId>
<artifactId>org.eclipse.cdt.gdb.source</artifactId>
<packaging>eclipse-feature</packaging>
<version>7.0.0-SNAPSHOT</version>
</project>

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gnu.debug-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.debug</artifactId>
<packaging>eclipse-feature</packaging>
<version>7.1.0-SNAPSHOT</version>
</project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.gnu.debug.source-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View file

@ -11,7 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.gnu.debug.source-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.debug.source</artifactId>
<packaging>eclipse-feature</packaging>
<version>7.1.0-SNAPSHOT</version>
</project>

View file

@ -24,16 +24,16 @@ import org.eclipse.cdt.dsf.concurrent.Query;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IProcessDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMData;
import org.eclipse.cdt.dsf.debug.service.IRunControl;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IContainerDMContext;
import org.eclipse.cdt.dsf.debug.service.IRunControl.IExecutionDMContext;
import org.eclipse.cdt.dsf.debug.service.command.ICommandControlService;
import org.eclipse.cdt.dsf.gdb.breakpoints.CBreakpointGdbThreadsFilterExtension;
import org.eclipse.cdt.dsf.gdb.internal.ui.GdbUIPlugin;
import org.eclipse.cdt.dsf.gdb.launching.GdbLaunch;
import org.eclipse.cdt.dsf.gdb.service.IGDBBackend;
import org.eclipse.cdt.dsf.mi.service.IMIExecutionDMContext;
import org.eclipse.cdt.dsf.mi.service.IMIProcesses;
import org.eclipse.cdt.dsf.service.DsfServicesTracker;
@ -256,7 +256,7 @@ public class GdbThreadFilterEditor {
private void createThreadViewer(Composite parent) {
Label label = new Label(parent, SWT.NONE);
label.setText("&Restrict to Selected Targets and Threads:"); //$NON-NLS-1$
label.setText(Messages.GdbThreadFilterEditor_RestrictToSelected);
label.setFont(parent.getFont());
label.setLayoutData(new GridData());
GridData data = new GridData(GridData.FILL_BOTH);
@ -388,7 +388,7 @@ public class GdbThreadFilterEditor {
IContainerDMContext[] containerDmcs = (IContainerDMContext[])getData();
rm.setData(containerDmcs);
} else {
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wront type of container contexts.")); //$NON-NLS-1$
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Wrong type of container contexts.")); //$NON-NLS-1$
}
rm.done();
}
@ -458,7 +458,7 @@ public class GdbThreadFilterEditor {
class ContainerLabelQuery extends Query<String> {
@Override
protected void execute(DataRequestMonitor<String> rm) {
protected void execute(final DataRequestMonitor<String> rm) {
if (!session.isActive()) {
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Container's session not active.")); //$NON-NLS-1$
rm.done();
@ -466,13 +466,22 @@ public class GdbThreadFilterEditor {
}
DsfServicesTracker tracker = new DsfServicesTracker(GdbUIPlugin.getBundleContext(), session.getId());
IGDBBackend backend = tracker.getService(IGDBBackend.class);
if (backend != null) {
rm.setData(backend.getProgramPath().toOSString());
IProcesses processService = tracker.getService(IProcesses.class);
IProcessDMContext procDmc = DMContexts.getAncestorOfType(container, IProcessDMContext.class);
if (processService != null && procDmc != null) {
processService.getExecutionData(
procDmc,
new DataRequestMonitor<IThreadDMData>(ImmediateExecutor.getInstance(), rm) {
@Override
public void handleSuccess() {
rm.setData(getData().getName());
rm.done();
}
});
} else {
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "GDB Backend not accessible.")); //$NON-NLS-1$
rm.setStatus(getFailStatus(IDsfStatusConstants.INVALID_STATE, "Processes service not accessible.")); //$NON-NLS-1$
rm.done();
}
rm.done();
tracker.dispose();
}
}
@ -511,7 +520,8 @@ public class GdbThreadFilterEditor {
ImmediateExecutor.getInstance(), rm) {
@Override
protected void handleSuccess() {
final StringBuilder builder = new StringBuilder("Thread["); //$NON-NLS-1$
final StringBuilder builder = new StringBuilder(Messages.GdbThreadFilterEditor_Thread);
builder.append("["); //$NON-NLS-1$
builder.append(((IMIExecutionDMContext)thread).getThreadId());
builder.append("] "); //$NON-NLS-1$
builder.append(getData().getId());

View file

@ -31,7 +31,10 @@ public class Messages extends NLS {
public static String TracepointPropertyPage_PassCount;
public static String TracepointPropertyPage_Class;
public static String TracepointPropertyPage_Enabled;
public static String GdbThreadFilterEditor_Thread;
public static String GdbThreadFilterEditor_RestrictToSelected;
static {
// initialize resource bundle
NLS.initializeMessages(Messages.class.getName(), Messages.class);

View file

@ -29,3 +29,6 @@ TracepointPropertyPage_IgnoreCount=&Ignore count:
TracepointPropertyPage_PassCount=&Pass count:
TracepointPropertyPage_Class=Class:
TracepointPropertyPage_Enabled=Enabled
GdbThreadFilterEditor_Thread=Thread
GdbThreadFilterEditor_RestrictToSelected=&Restrict to Selected Processes and Threads:

View file

@ -1669,7 +1669,7 @@ public class MIBreakpointsManager extends AbstractDsfService implements IBreakpo
// Extract the thread IDs (if there is none, we are covered)
for (IContainerDMContext ctxt : targets) {
if (DMContexts.isAncestorOf(ctxt, context)) {
if (ctxt.equals(context) || DMContexts.isAncestorOf(ctxt, context)) {
threads.add(filterExtension.getThreadFilters(ctxt));
}
}

View file

@ -12,6 +12,6 @@
</parent>
<version>4.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.gdb.dsf-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.dsf</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.gnu.dsf.source-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View file

@ -12,6 +12,6 @@
</parent>
<version>4.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.gdb.dsf.source-feature</artifactId>
<artifactId>org.eclipse.cdt.gnu.dsf.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,7 @@
</parent>
<version>2.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.examples.dsf-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.examples.dsf</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,7 @@
</parent>
<version>7.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdtdebug.gdbjtag-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.debug.gdbjtag</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>5.2.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.lrparser.sdk.feature</artifactId>
<artifactId>org.eclipse.cdt.core.lrparser.sdk</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -11,7 +11,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.eclipse.cdt.features</groupId>
<version>5.2.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.lrparser.source.feature</artifactId>
<artifactId>org.eclipse.cdt.core.lrparser.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>2.1.100-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.debug.ui.memory-feature</artifactId>
<artifactId>org.eclipse.cdt.debug.ui.memory</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -11,7 +11,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.eclipse.cdt.features</groupId>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.p2-feature</artifactId>
<artifactId>org.eclipse.cdt.p2</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -149,6 +149,8 @@
<module>dsf/org.eclipse.cdt.examples.dsf.pda.ui</module>
<module>dsf/org.eclipse.cdt.examples.dsf-feature</module>
<module>releng/org.eclipse.cdt.repo</module>
<module>core/org.eclipse.cdt.core.tests</module>
<module>core/org.eclipse.cdt.ui.tests</module>
<module>build/org.eclipse.cdt.managedbuilder.core.tests</module>
@ -161,7 +163,6 @@
<module>debug/org.eclipse.cdt.debug.ui.tests</module>
-->
<module>releng/org.eclipse.cdt.repo</module>
</modules>
<repositories>

View file

@ -11,6 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -11,6 +11,6 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.platform-feature</artifactId>
<artifactId>org.eclipse.cdt.platform</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>org.eclipse.cdt.platform.source-feature</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
</buildSpec>
<natures>
</natures>
</projectDescription>

View file

@ -11,6 +11,6 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.platform.source-feature</artifactId>
<artifactId>org.eclipse.cdt.platform.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -14,4 +14,47 @@
<version>8.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.repo</artifactId>
<packaging>eclipse-repository</packaging>
<properties>
<cdt-install>/home/data/httpd/download.eclipse.org/tools/cdt/builds/hudson/cdt-maint</cdt-install>
</properties>
<profiles>
<profile>
<id>production</id>
<build>
<plugins>
<plugin>
<artifactId>maven-antrun-plugin</artifactId>
<executions>
<execution>
<id>deploy</id>
<phase>install</phase>
<goals>
<goal>run</goal>
</goals>
<configuration>
<tasks>
<mkdir dir="${cdt-install}"/>
<delete>
<fileset dir="${cdt-install}">
<include name="**" />
</fileset>
</delete>
<copy
file="target/org.eclipse.cdt.repo.zip"
tofile="${cdt-install}/org.eclipse.cdt.repo.${unqualifiedVersion}.${buildQualifier}.zip"/>
<unzip
src="target/org.eclipse.cdt.repo.zip"
dest="${cdt-install}"/>
</tasks>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</profile>
</profiles>
</project>

View file

@ -11,6 +11,7 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<artifactId>org.eclipse.cdt.sdk-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.sdk</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>1.0.3-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.bupc-feature</artifactId>
<artifactId>org.eclipse.cdt.bupc</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>5.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.parser.upc.sdk.feature</artifactId>
<artifactId>org.eclipse.cdt.core.parser.upc.sdk</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -11,7 +11,8 @@
<relativePath>../../pom.xml</relativePath>
</parent>
<groupId>org.eclipse.cdt.features</groupId>
<version>5.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.core.parser.upc.source.feature</artifactId>
<artifactId>org.eclipse.cdt.core.parser.upc.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,7 @@
</parent>
<version>5.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.util-feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.util</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>1.0.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.msw-feature</artifactId>
<artifactId>org.eclipse.cdt.msw</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,6 @@
</parent>
<version>6.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.xlc.sdk-feature</artifactId>
<artifactId>org.eclipse.cdt.xlc.sdk</artifactId>
<packaging>eclipse-feature</packaging>
</project>

View file

@ -12,6 +12,7 @@
</parent>
<version>6.1.0-SNAPSHOT</version>
<artifactId>org.eclipse.cdt.xlc.source.feature</artifactId>
<groupId>org.eclipse.cdt.features</groupId>
<artifactId>org.eclipse.cdt.xlc.source</artifactId>
<packaging>eclipse-feature</packaging>
</project>