summaryrefslogtreecommitdiffstats
path: root/clang
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
commit36ca1e6399feaaee1e007bafa40449fecdba70aa (patch)
treea32b98f21ee6cd787bfb53062ab1d7f62f352898 /clang
parent40837e97b199b4d6546df9f8912e14a56c434417 (diff)
downloadbcm5719-llvm-36ca1e6399feaaee1e007bafa40449fecdba70aa.tar.gz
bcm5719-llvm-36ca1e6399feaaee1e007bafa40449fecdba70aa.zip
[Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy
Since the DeclStmt range includes the semicolon, it doesn't need a semicolon at the end during extraction llvm-svn: 368850
Diffstat (limited to 'clang')
-rw-r--r--clang/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp1
-rw-r--r--clang/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp13
2 files changed, 13 insertions, 1 deletions
diff --git a/clang/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp b/clang/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
index 09c89c15a97..5d57ecf90a9 100644
--- a/clang/lib/Tooling/Refactoring/Extract/SourceExtraction.cpp
+++ b/clang/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/clang/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp b/clang/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
index 97f12475761..865e8290923 100644
--- a/clang/test/Refactor/Extract/ExtractionSemicolonPolicy.cpp
+++ b/clang/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: }
+
OpenPOWER on IntegriCloud