r368850 - [Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Shaurya Gupta via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 14 06:37:39 PDT 2019
Author: sureyeaah
Date: Wed Aug 14 06:37:39 2019
New Revision: 368850
URL: http://llvm.org/viewvc/llvm-project?rev=368850&view=rev
Log:
[Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Since the DeclStmt range includes the semicolon, it doesn't need a
semicolon at the end during extraction
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=368850&r1=368849&r2=368850&view=diff
==============================================================================
--- cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp (original)
+++ cfe/trunk/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp Wed Aug 14 06:37:39 2019
@@ -45,6 +45,7 @@ bool isSemicolonRequiredAfter(const Stmt
if(const auto *Case = dyn_cast<SwitchCase>(S))
return isSemicolonRequiredAfter(Case->getSubStmt());
switch (S->getStmtClass()) {
+ case Stmt::DeclStmtClass:
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=368850&r1=368849&r2=368850&view=diff
==============================================================================
--- cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp (original)
+++ cfe/trunk/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp Wed Aug 14 06:37:39 2019
@@ -193,7 +193,7 @@ void careForNonCompoundSemicolons2() {
// CHECK-NEXT: }
void careForSwitchSemicolon() {
- /*range mextract=->+0:51*/switch(0) default: break;
+ /*range mextract=->+0:53*/switch(0) default: break;
}
// CHECK: 1 'mextract' results:
// CHECK: static void extracted() {
@@ -203,3 +203,14 @@ void careForSwitchSemicolon() {
// CHECK-NEXT: extracted();{{$}}
// CHECK-NEXT: }
+void extractStatementNotSemiDecl() {
+ /*range nextract=->+0:38*/int x = 5;
+}
+// CHECK: 1 'nextract' results:
+// CHECK: static void extracted() {
+// CHECK-NEXT: int x = 5;{{$}}
+// CHECK-NEXT: }{{[[:space:]].*}}
+// CHECK-NEXT: void extractStatementNotSemiDecl() {
+// CHECK-NEXT: extracted();{{$}}
+// CHECK-NEXT: }
+
More information about the cfe-commits
mailing list