mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-01 06:05:24 +02:00
Bug 514684 - call writeAttributes on more Statements
and added JUnit tests Change-Id: Ic09aa96f896b0a5dd998156e05930704775f695b Signed-off-by: romibi <romibi@bluewin.ch>
This commit is contained in:
parent
c22ccedea2
commit
5d9dd823fa
2 changed files with 87 additions and 0 deletions
|
@ -199,6 +199,84 @@ void bar()
|
||||||
[[attr]] int i;
|
[[attr]] int i;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//!Attributed Do-while Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
[[attr]] do{
|
||||||
|
} while (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed For Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
[[attr]] for (int i = 0;i < 10;i++){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Range-Based For Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
int a[] = {0, 1, 2};
|
||||||
|
[[attr]] for (int n: a){
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Break Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
while (true){
|
||||||
|
[[attr]] break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Continue Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
while (true){
|
||||||
|
[[attr]] continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Goto Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
[[attr]] goto label;
|
||||||
|
label:
|
||||||
|
;
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed GNU Goto Statement 514684
|
||||||
|
//%CPP GNU
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
label2:
|
||||||
|
;
|
||||||
|
void* ptr = &&label2;
|
||||||
|
[[attr]] goto *ptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Null Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
[[attr]];
|
||||||
|
}
|
||||||
|
|
||||||
|
//!Attributed Switch Statement 514684
|
||||||
|
//%CPP
|
||||||
|
void foo()
|
||||||
|
{
|
||||||
|
[[attr]] switch (1){
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//!Empty Attribute
|
//!Empty Attribute
|
||||||
//%CPP
|
//%CPP
|
||||||
[[]] int i;
|
[[]] int i;
|
||||||
|
|
|
@ -163,6 +163,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeDoStatement(IASTDoStatement doStatement) {
|
private void writeDoStatement(IASTDoStatement doStatement) {
|
||||||
|
writeAttributes(doStatement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
nextCompoundNoNewLine();
|
nextCompoundNoNewLine();
|
||||||
|
|
||||||
scribe.print(DO);
|
scribe.print(DO);
|
||||||
|
@ -174,6 +175,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeForStatement(IASTForStatement forStatement) {
|
private void writeForStatement(IASTForStatement forStatement) {
|
||||||
|
writeAttributes(forStatement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.noNewLines();
|
scribe.noNewLines();
|
||||||
scribe.print(FOR);
|
scribe.print(FOR);
|
||||||
writeStatement(forStatement.getInitializerStatement(),false);
|
writeStatement(forStatement.getInitializerStatement(),false);
|
||||||
|
@ -201,6 +203,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
|
private void writeForStatement(ICPPASTRangeBasedForStatement forStatment) {
|
||||||
|
writeAttributes(forStatment, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.noNewLines();
|
scribe.noNewLines();
|
||||||
scribe.print(FOR);
|
scribe.print(FOR);
|
||||||
writeDeclarationWithoutSemicolon(forStatment.getDeclaration());
|
writeDeclarationWithoutSemicolon(forStatment.getDeclaration());
|
||||||
|
@ -246,11 +249,13 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeBreakStatement(IASTBreakStatement statement) {
|
private void writeBreakStatement(IASTBreakStatement statement) {
|
||||||
|
writeAttributes(statement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.print(BREAK);
|
scribe.print(BREAK);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeContinueStatement(IASTContinueStatement statement) {
|
private void writeContinueStatement(IASTContinueStatement statement) {
|
||||||
|
writeAttributes(statement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.print(CONTINUE);
|
scribe.print(CONTINUE);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
}
|
}
|
||||||
|
@ -264,12 +269,14 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeGotoStatement(IASTGotoStatement gotoStatement) {
|
private void writeGotoStatement(IASTGotoStatement gotoStatement) {
|
||||||
|
writeAttributes(gotoStatement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.print(GOTO);
|
scribe.print(GOTO);
|
||||||
gotoStatement.getName().accept(visitor);
|
gotoStatement.getName().accept(visitor);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeGNUASTGotoStatement(IGNUASTGotoStatement gotoStatement) {
|
private void writeGNUASTGotoStatement(IGNUASTGotoStatement gotoStatement) {
|
||||||
|
writeAttributes(gotoStatement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
scribe.print(GOTO);
|
scribe.print(GOTO);
|
||||||
gotoStatement.getLabelNameExpression().accept(visitor);
|
gotoStatement.getLabelNameExpression().accept(visitor);
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
|
@ -289,6 +296,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNullStatement(IASTNullStatement nullStmt) {
|
private void writeNullStatement(IASTNullStatement nullStmt) {
|
||||||
|
writeAttributes(nullStmt, EnumSet.noneOf(SpaceLocation.class));
|
||||||
scribe.printSemicolon();
|
scribe.printSemicolon();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -360,6 +368,7 @@ public class StatementWriter extends NodeWriter {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeSwitchStatement(IASTSwitchStatement switchStatement) {
|
private void writeSwitchStatement(IASTSwitchStatement switchStatement) {
|
||||||
|
writeAttributes(switchStatement, EnumSet.of(SpaceLocation.AFTER));
|
||||||
switchIsNew = true;
|
switchIsNew = true;
|
||||||
|
|
||||||
scribe.print(SWITCH_BRACKET);
|
scribe.print(SWITCH_BRACKET);
|
||||||
|
|
Loading…
Add table
Reference in a new issue