This revision was automatically updated to reflect the committed changes. Closed by commit rL368267: [Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase (authored by SureYeaah, committed by ). Herald added a project: LLVM. Herald added a subscriber: llvm-commits.
Changed prior to commit: https://reviews.llvm.org/D65883?vs=213925&id=214084#toc Repository: rL LLVM CHANGES SINCE LAST ACTION https://reviews.llvm.org/D65883/new/ https://reviews.llvm.org/D65883 Files: cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp Index: cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp =================================================================== --- cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp +++ cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp @@ -64,6 +64,7 @@ // CHECK-NEXT: extracted();{{$}} // CHECK-NEXT: } + void extractStatementNotSemiWhile() { /*range eextract=->+2:4*/while (true) { int x = 0; @@ -190,3 +191,15 @@ // CHECK-NEXT: extracted();{{$}} // CHECK-NEXT: // // CHECK-NEXT: } + +void careForSwitchSemicolon() { + /*range mextract=->+0:51*/switch(0) default: break; +} +// CHECK: 1 'mextract' results: +// CHECK: static void extracted() { +// CHECK-NEXT: switch(0) default: break;{{$}} +// CHECK-NEXT: }{{[[:space:]].*}} +// CHECK-NEXT: void careForSwitchSemicolon() { +// CHECK-NEXT: extracted();{{$}} +// CHECK-NEXT: } + Index: cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp =================================================================== --- cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp +++ cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp @@ -40,8 +40,11 @@ return isSemicolonRequiredAfter(CXXFor->getBody()); if (const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(S)) return isSemicolonRequiredAfter(ObjCFor->getBody()); + if(const auto *Switch = dyn_cast<SwitchStmt>(S)) + return isSemicolonRequiredAfter(Switch->getBody()); + if(const auto *Case = dyn_cast<SwitchCase>(S)) + return isSemicolonRequiredAfter(Case->getSubStmt()); switch (S->getStmtClass()) { - case Stmt::SwitchStmtClass: case Stmt::CXXTryStmtClass: case Stmt::ObjCAtSynchronizedStmtClass: case Stmt::ObjCAutoreleasePoolStmtClass:
Index: cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp =================================================================== --- cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp +++ cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp @@ -64,6 +64,7 @@ // CHECK-NEXT: extracted();{{$}} // CHECK-NEXT: } + void extractStatementNotSemiWhile() { /*range eextract=->+2:4*/while (true) { int x = 0; @@ -190,3 +191,15 @@ // CHECK-NEXT: extracted();{{$}} // CHECK-NEXT: // // CHECK-NEXT: } + +void careForSwitchSemicolon() { + /*range mextract=->+0:51*/switch(0) default: break; +} +// CHECK: 1 'mextract' results: +// CHECK: static void extracted() { +// CHECK-NEXT: switch(0) default: break;{{$}} +// CHECK-NEXT: }{{[[:space:]].*}} +// CHECK-NEXT: void careForSwitchSemicolon() { +// CHECK-NEXT: extracted();{{$}} +// CHECK-NEXT: } + Index: cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp =================================================================== --- cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp +++ cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp @@ -40,8 +40,11 @@ return isSemicolonRequiredAfter(CXXFor->getBody()); if (const auto *ObjCFor = dyn_cast<ObjCForCollectionStmt>(S)) return isSemicolonRequiredAfter(ObjCFor->getBody()); + if(const auto *Switch = dyn_cast<SwitchStmt>(S)) + return isSemicolonRequiredAfter(Switch->getBody()); + if(const auto *Case = dyn_cast<SwitchCase>(S)) + return isSemicolonRequiredAfter(Case->getSubStmt()); switch (S->getStmtClass()) { - case Stmt::SwitchStmtClass: case Stmt::CXXTryStmtClass: case Stmt::ObjCAtSynchronizedStmtClass: case Stmt::ObjCAutoreleasePoolStmtClass:
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits