From: Douglas Gregor Date: Tue, 6 Apr 2010 20:11:37 +0000 (+0000) Subject: Do not produce semicolons at the end of code-completion results X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe0bdba44641c5d20e6b7c889545b087ff10179e;p=clang Do not produce semicolons at the end of code-completion results git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100557 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp index 20621fdb6b..ced2e78c08 100644 --- a/lib/Sema/SemaCodeComplete.cpp +++ b/lib/Sema/SemaCodeComplete.cpp @@ -884,7 +884,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddPlaceholderChunk("identifier"); Pattern->AddChunk(CodeCompletionString::CK_Equal); Pattern->AddPlaceholderChunk("identifier"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // Using directives @@ -894,7 +893,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTextChunk("namespace"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("identifier"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // asm(string-literal) @@ -903,7 +901,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddChunk(CodeCompletionString::CK_LeftParen); Pattern->AddPlaceholderChunk("string-literal"); Pattern->AddChunk(CodeCompletionString::CK_RightParen); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // Explicit template instantiation @@ -911,7 +908,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTypedTextChunk("template"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("declaration"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); } @@ -928,7 +924,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTypedTextChunk("using"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("qualified-id"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // using typename qualified-id; (only in a dependent context) @@ -939,7 +934,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTextChunk("typename"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("qualified-id"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); } @@ -1092,7 +1086,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddChunk(CodeCompletionString::CK_LeftParen); Pattern->AddPlaceholderChunk("expression"); Pattern->AddChunk(CodeCompletionString::CK_RightParen); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // for ( for-init-statement ; condition ; expression ) { statements } @@ -1118,7 +1111,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, // continue ; Pattern = new CodeCompletionString; Pattern->AddTypedTextChunk("continue"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); } @@ -1126,7 +1118,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, // break ; Pattern = new CodeCompletionString; Pattern->AddTypedTextChunk("break"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); } @@ -1147,7 +1138,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("expression"); } - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // goto identifier ; @@ -1155,7 +1145,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTypedTextChunk("goto"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("identifier"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // Using directives @@ -1165,7 +1154,6 @@ static void AddOrdinaryNameResults(Action::CodeCompletionContext CCC, Pattern->AddTextChunk("namespace"); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("identifier"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); } @@ -2468,7 +2456,6 @@ static void AddObjCTopLevelResults(ResultBuilder &Results, bool NeedAt) { Pattern->AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,class)); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("identifier"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // @interface name @@ -2577,7 +2564,6 @@ static void AddObjCStatementResults(ResultBuilder &Results, bool NeedAt) { Pattern->AddTypedTextChunk(OBJC_AT_KEYWORD_NAME(NeedAt,throw)); Pattern->AddChunk(CodeCompletionString::CK_HorizontalSpace); Pattern->AddPlaceholderChunk("expression"); - Pattern->AddChunk(CodeCompletionString::CK_SemiColon); Results.AddResult(Result(Pattern)); // @synchronized ( expression ) { statements } diff --git a/test/CodeCompletion/ordinary-name.cpp b/test/CodeCompletion/ordinary-name.cpp index d938c79eae..699b01de74 100644 --- a/test/CodeCompletion/ordinary-name.cpp +++ b/test/CodeCompletion/ordinary-name.cpp @@ -21,7 +21,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: float // CHECK-CC1-NEXT: COMPLETION: foo : [#void#]foo() // CHECK-CC1-NEXT: COMPLETION: Pattern : for(<#init-statement#>;<#condition#>;<#inc-expression#>){<#statements#> - // CHECK-CC1: COMPLETION: Pattern : goto <#identifier#>; + // CHECK-CC1: COMPLETION: Pattern : goto <#identifier#> // CHECK-CC1-NEXT: COMPLETION: Pattern : if(<#condition#>){<#statements#> // CHECK-CC1: COMPLETION: int // CHECK-CC1-NEXT: COMPLETION: long @@ -29,7 +29,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: Pattern : new <#type-id#>[<#size#>](<#expressions#>) // CHECK-CC1-NEXT: COMPLETION: operator // CHECK-CC1-NEXT: COMPLETION: Pattern : reinterpret_cast<<#type-id#>>(<#expression#>) - // CHECK-CC1-NEXT: COMPLETION: Pattern : return; + // CHECK-CC1-NEXT: COMPLETION: Pattern : return // CHECK-CC1-NEXT: COMPLETION: short // CHECK-CC1-NEXT: COMPLETION: signed // CHECK-CC1-NEXT: COMPLETION: Pattern : sizeof(<#expression-or-type#>) @@ -48,7 +48,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC1-NEXT: COMPLETION: union // CHECK-CC1-NEXT: COMPLETION: unsigned - // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; + // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#> // CHECK-CC1-NEXT: COMPLETION: void // CHECK-CC1-NEXT: COMPLETION: volatile // CHECK-CC1-NEXT: COMPLETION: wchar_t @@ -58,7 +58,7 @@ void foo() { // CHECK-CC1-NEXT: COMPLETION: z : [#void#]z(<#int#>) // RUN: %clang_cc1 -fsyntax-only -code-completion-at=%s:4:1 %s -o - | FileCheck -check-prefix=CHECK-CC2 %s - // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>); + // CHECK-CC2: COMPLETION: Pattern : asm(<#string-literal#>) // CHECK-CC2-NEXT: COMPLETION: bool // CHECK-CC2-NEXT: COMPLETION: char // CHECK-CC2-NEXT: COMPLETION: class @@ -71,14 +71,14 @@ void foo() { // CHECK-CC2-NEXT: COMPLETION: int // CHECK-CC2-NEXT: COMPLETION: long // CHECK-CC2-NEXT: COMPLETION: Pattern : namespace <#identifier#>{<#declarations#> - // CHECK-CC2: COMPLETION: Pattern : namespace <#identifier#> = <#identifier#>; + // CHECK-CC2: COMPLETION: Pattern : namespace <#identifier#> = <#identifier#> // CHECK-CC2-NEXT: COMPLETION: operator // CHECK-CC2-NEXT: COMPLETION: short // CHECK-CC2-NEXT: COMPLETION: signed // CHECK-CC2-NEXT: COMPLETION: static // CHECK-CC2-NEXT: COMPLETION: struct // CHECK-CC2-NEXT: COMPLETION: t : t - // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#>; + // CHECK-CC2-NEXT: COMPLETION: Pattern : template <#declaration#> // CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>> // CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF // CHECK-CC2-NEXT: COMPLETION: typedef @@ -86,8 +86,8 @@ void foo() { // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC2-NEXT: COMPLETION: union // CHECK-CC2-NEXT: COMPLETION: unsigned - // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; - // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualified-id#>; + // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#> + // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualified-id#> // CHECK-CC2-NEXT: COMPLETION: void // CHECK-CC2-NEXT: COMPLETION: volatile // CHECK-CC2-NEXT: COMPLETION: wchar_t @@ -122,7 +122,7 @@ void foo() { // CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#expression-or-type#>) // CHECK-CC3-NEXT: COMPLETION: union // CHECK-CC3-NEXT: COMPLETION: unsigned - // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualified-id#>; + // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualified-id#> // CHECK-CC3-NEXT: COMPLETION: virtual // CHECK-CC3-NEXT: COMPLETION: void // CHECK-CC3-NEXT: COMPLETION: volatile diff --git a/test/Index/complete-at-directives.m b/test/Index/complete-at-directives.m index 1d0a471dbb..811bca00ef 100644 --- a/test/Index/complete-at-directives.m +++ b/test/Index/complete-at-directives.m @@ -6,7 +6,7 @@ @end // RUN: c-index-test -code-completion-at=%s:2:2 %s | FileCheck -check-prefix=CHECK-CC1 %s -// CHECK-CC1: {TypedText class}{HorizontalSpace }{Placeholder identifier}{SemiColon ;} +// CHECK-CC1: {TypedText class}{HorizontalSpace }{Placeholder identifier} // CHECK-CC1: {TypedText compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class} // CHECK-CC1: {TypedText implementation}{HorizontalSpace }{Placeholder class} // CHECK-CC1: {TypedText interface}{HorizontalSpace }{Placeholder class} @@ -24,7 +24,7 @@ // CHECK-CC3: {TypedText synthesize}{HorizontalSpace }{Placeholder property} // RUN: c-index-test -code-completion-at=%s:2:1 %s | FileCheck -check-prefix=CHECK-CC4 %s -// CHECK-CC4: NotImplemented:{TypedText @class}{HorizontalSpace }{Placeholder identifier}{SemiColon ;} +// CHECK-CC4: NotImplemented:{TypedText @class}{HorizontalSpace }{Placeholder identifier} // CHECK-CC4: NotImplemented:{TypedText @compatibility_alias}{HorizontalSpace }{Placeholder alias}{HorizontalSpace }{Placeholder class} // CHECK-CC4: NotImplemented:{TypedText @implementation}{HorizontalSpace }{Placeholder class} // CHECK-CC4: NotImplemented:{TypedText @interface}{HorizontalSpace }{Placeholder class} diff --git a/test/Index/complete-at-exprstmt.m b/test/Index/complete-at-exprstmt.m index e8efc3cf46..87e554ff22 100644 --- a/test/Index/complete-at-exprstmt.m +++ b/test/Index/complete-at-exprstmt.m @@ -14,7 +14,7 @@ // CHECK-CC1: {TypedText protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} // CHECK-CC1: {TypedText selector}{LeftParen (}{Placeholder selector}{RightParen )} // CHECK-CC1: {TypedText synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }} -// CHECK-CC1: {TypedText throw}{HorizontalSpace }{Placeholder expression}{SemiColon ;} +// CHECK-CC1: {TypedText throw}{HorizontalSpace }{Placeholder expression} // CHECK-CC1: {TypedText try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }} // RUN: c-index-test -code-completion-at=%s:9:19 %s | FileCheck -check-prefix=CHECK-CC2 %s // CHECK-CC2: {TypedText encode}{LeftParen (}{Placeholder type-name}{RightParen )} @@ -25,7 +25,7 @@ // CHECK-CC3: NotImplemented:{TypedText @protocol}{LeftParen (}{Placeholder protocol-name}{RightParen )} // CHECK-CC3: NotImplemented:{TypedText @selector}{LeftParen (}{Placeholder selector}{RightParen )} // CHECK-CC3: NotImplemented:{TypedText @synchronized}{HorizontalSpace }{LeftParen (}{Placeholder expression}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }} -// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression}{SemiColon ;} +// CHECK-CC3: NotImplemented:{TypedText @throw}{HorizontalSpace }{Placeholder expression} // CHECK-CC3: NotImplemented:{TypedText @try}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @catch}{LeftParen (}{Placeholder parameter}{RightParen )}{LeftBrace {}{Placeholder statements}{RightBrace }}{Text @finally}{LeftBrace {}{Placeholder statements}{RightBrace }} // CHECK-CC3: NotImplemented:{ResultType SEL}{TypedText _cmd} // CHECK-CC3: ParmDecl:{ResultType int}{TypedText arg}