summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShaurya Gupta <shauryab98@gmail.com>2019-08-14 13:37:39 +0000
committerShaurya Gupta <shauryab98@gmail.com>2019-08-14 13:37:39 +0000
commit62741b0ffdf6874c069ac9f040705e8def785751 (patch)
treeae8d2b55ce683682c89041731b876f807e12401c
parent39b5f65011af82077a1c8b05ce0995488c2e9dd9 (diff)
downloadclang-62741b0ffdf6874c069ac9f040705e8def785751.tar.gz
[Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Since the DeclStmt range includes the semicolon, it doesn't need a semicolon at the end during extraction git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@368850 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Tooling/Refactoring/Extract/SourceExtraction.cpp1
-rw-r--r--test/Refactor/Extract/ExtractionSemicolonPolicy.cpp13
2 files changed, 13 insertions, 1 deletions
diff --git a/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp b/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
index 09c89c15a9..5d57ecf90a 100644
--- a/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
+++ b/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
@@ -45,6 +45,7 @@ bool isSemicolonRequiredAfter(const Stmt *S) {
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:
diff --git a/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp b/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
index 97f1247576..865e829092 100644
--- a/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
+++ b/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
@@ -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: }
+