r368267 - [Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase
Shaurya Gupta via cfe-commits
cfe-commits at lists.llvm.org
Thu Aug 8 01:37:49 PDT 2019
Author: sureyeaah
Date: Thu Aug 8 01:37:49 2019
New Revision: 368267
URL: http://llvm.org/viewvc/llvm-project?rev=368267&view=rev
Log:
[Extract] Fixed SemicolonExtractionPolicy for SwitchStmt and SwitchCase
Reviewers: arphaman, sammccall
Subscribers: dexonsmith, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D65883
Modified:
cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
Modified: cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp?rev=368267&r1=368266&r2=368267&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp Thu Aug 8 01:37:49 2019
@@ -40,8 +40,11 @@ bool isSemicolonRequiredAfter(const Stmt
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:
Modified: cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp?rev=368267&r1=368266&r2=368267&view=diff
==============================================================================
--- cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp (original)
+++ cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp Thu Aug 8 01:37:49 2019
@@ -64,6 +64,7 @@ void extractStatementNotSemiSwitch() {
// CHECK-NEXT: extracted();{{$}}
// CHECK-NEXT: }
+
void extractStatementNotSemiWhile() {
/*range eextract=->+2:4*/while (true) {
int x = 0;
@@ -190,3 +191,15 @@ void careForNonCompoundSemicolons2() {
// 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: }
+
More information about the cfe-commits
mailing list