From: Shaurya Gupta Date: Wed, 14 Aug 2019 13:37:39 +0000 (+0000) Subject: [Tooling] Added DeclStmtClass to ExtractionSemicolonPolicy X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=62741b0ffdf6874c069ac9f040705e8def785751;p=clang [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 --- 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(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: } +