mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-29 19:45:01 +02:00
Don't report problems inside macro expansions.
This commit is contained in:
parent
44a3a89caa
commit
04f74e7829
1 changed files with 16 additions and 1 deletions
|
@ -25,6 +25,8 @@ import org.eclipse.cdt.core.dom.ast.IASTDefaultStatement;
|
|||
import org.eclipse.cdt.core.dom.ast.IASTExpressionStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTGotoStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTIfStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTMacroExpansionLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTNodeLocation;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTReturnStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTStatement;
|
||||
import org.eclipse.cdt.core.dom.ast.IASTSwitchStatement;
|
||||
|
@ -70,7 +72,7 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
|
||||
@Override
|
||||
public int visit(IASTStatement statement) {
|
||||
if (statement instanceof IASTSwitchStatement) {
|
||||
if (statement instanceof IASTSwitchStatement && !isProducedMyMacroExpansion(statement)) {
|
||||
IASTSwitchStatement switchStmt = (IASTSwitchStatement) statement;
|
||||
IASTStatement body = switchStmt.getBody();
|
||||
if (body instanceof IASTCompoundStatement) {
|
||||
|
@ -148,6 +150,19 @@ public class CaseBreakChecker extends AbstractIndexAstChecker implements IChecke
|
|||
}
|
||||
return true; // TODO
|
||||
}
|
||||
|
||||
/**
|
||||
* 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.
|
||||
* @return <code>true</code> if the statement is a result of macro expansion
|
||||
*/
|
||||
private boolean isProducedMyMacroExpansion(IASTStatement statement) {
|
||||
IASTNodeLocation[] locations = statement.getNodeLocations();
|
||||
return locations.length > 0 && locations[0] instanceof IASTMacroExpansionLocation &&
|
||||
(locations.length == 1 || locations.length == 2 && locations[1].getNodeLength() == 1);
|
||||
}
|
||||
}
|
||||
|
||||
public CaseBreakChecker() {
|
||||
|
|
Loading…
Add table
Reference in a new issue