[PATCH] D65883: [Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase
Shaurya Gupta via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 01:38:09 PDT 2019
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:
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65883.214084.patch
Type: text/x-patch
Size: 1754 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190808/ef04065a/attachment.bin>
More information about the cfe-commits
mailing list