[clang] 834c718 - [CodeComplete] Tweak code completion for `typename`.
Kadir Cetinkaya via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 26 01:38:40 PDT 2020
Author: Kadir Cetinkaya
Date: 2020-06-26T10:32:12+02:00
New Revision: 834c71829cc2e22841bf75e86b988c46252c70dc
URL: https://github.com/llvm/llvm-project/commit/834c71829cc2e22841bf75e86b988c46252c70dc
DIFF: https://github.com/llvm/llvm-project/commit/834c71829cc2e22841bf75e86b988c46252c70dc.diff
LOG: [CodeComplete] Tweak code completion for `typename`.
Summary:
Currently, clangd always completes `typename` as `typename qualifier::name`, I think the current behavior is not useful when the code completion is triggered in `template <>`. So I tweak it to `typename identifier`.
Patch by @lh123 !
Reviewers: sammccall, kadircet
Reviewed By: kadircet
Subscribers: ilya-biryukov, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D82373
Added:
Modified:
clang/lib/Sema/SemaCodeComplete.cpp
clang/test/CodeCompletion/ordinary-name-cxx11.cpp
clang/test/CodeCompletion/ordinary-name.cpp
Removed:
################################################################################
diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp
index 913c43886b4e..8835ecc79b9f 100644
--- a/clang/lib/Sema/SemaCodeComplete.cpp
+++ b/clang/lib/Sema/SemaCodeComplete.cpp
@@ -1687,11 +1687,9 @@ static void AddTypeSpecifierResults(const LangOptions &LangOpts,
Results.AddResult(Result("class", CCP_Type));
Results.AddResult(Result("wchar_t", CCP_Type));
- // typename qualified-id
+ // typename name
Builder.AddTypedTextChunk("typename");
Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace);
- Builder.AddPlaceholderChunk("qualifier");
- Builder.AddTextChunk("::");
Builder.AddPlaceholderChunk("name");
Results.AddResult(Result(Builder.TakeString()));
diff --git a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
index e568ee1ee3d8..dcbb5ecb4f69 100644
--- a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
+++ b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp
@@ -57,7 +57,7 @@ void foo() {
// CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
// CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
- // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC1-NEXT: COMPLETION: union
@@ -107,7 +107,7 @@ void foo() {
// CHECK-CC2-NEXT: COMPLETION: thread_local
// CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
- // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC2-NEXT: COMPLETION: union
@@ -150,7 +150,7 @@ void foo() {
// CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
// CHECK-CC3-NEXT: COMPLETION: thread_local
// CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
- // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC3-NEXT: COMPLETION: union
@@ -198,7 +198,7 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
// CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
- // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC4-NEXT: COMPLETION: union
@@ -259,7 +259,7 @@ void foo() {
// CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
// CHECK-NO-RTTI-NOT: typeid
- // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#name#>
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-NO-RTTI-NEXT: COMPLETION: union
diff --git a/clang/test/CodeCompletion/ordinary-name.cpp b/clang/test/CodeCompletion/ordinary-name.cpp
index 3f891307bb74..a87c992d85f7 100644
--- a/clang/test/CodeCompletion/ordinary-name.cpp
+++ b/clang/test/CodeCompletion/ordinary-name.cpp
@@ -54,7 +54,7 @@ void foo() {
// CHECK-CC1: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC1-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
// CHECK-CC1-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
- // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC1-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC1-NEXT: COMPLETION: union
@@ -97,7 +97,7 @@ void foo() {
// CHECK-CC2-NEXT: COMPLETION: Pattern : template<<#parameters#>>
// CHECK-CC2-NEXT: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC2-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
- // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC2-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC2-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC2-NEXT: COMPLETION: union
@@ -134,7 +134,7 @@ void foo() {
// CHECK-CC3-NEXT: COMPLETION: struct
// CHECK-CC3-NEXT: COMPLETION: Pattern : template<<#parameters#>>
// CHECK-CC3-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
- // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC3-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC3-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC3-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC3-NEXT: COMPLETION: union
@@ -176,7 +176,7 @@ void foo() {
// CHECK-CC4-NEXT: COMPLETION: Pattern : [#bool#]true
// CHECK-CC4-NEXT: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-CC4-NEXT: COMPLETION: Pattern : [#std::type_info#]typeid(<#expression-or-type#>)
- // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-CC4-NEXT: COMPLETION: Pattern : typename <#name#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-CC4-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-CC4-NEXT: COMPLETION: union
@@ -227,7 +227,7 @@ void foo() {
// CHECK-NO-RTTI: COMPLETION: TYPEDEF : TYPEDEF
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typedef <#type#> <#name#>;
// CHECK-NO-RTTI-NOT: typeid
- // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#qualifier#>::<#name#>
+ // CHECK-NO-RTTI: COMPLETION: Pattern : typename <#name#>
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof <#expression#>
// CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>)
// CHECK-NO-RTTI-NEXT: COMPLETION: union
More information about the cfe-commits
mailing list