[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-22 Thread Erik Verbruggen via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rL311442: Fix templated type alias completion when using 
global completion cache (authored by erikjv).

Changed prior to commit:
  https://reviews.llvm.org/D35355?vs=109968=112144#toc

Repository:
  rL LLVM

https://reviews.llvm.org/D35355

Files:
  cfe/trunk/lib/Frontend/ASTUnit.cpp
  cfe/trunk/lib/Parse/ParseTemplate.cpp
  cfe/trunk/test/Index/code-completion.cpp


Index: cfe/trunk/test/Index/code-completion.cpp
===
--- cfe/trunk/test/Index/code-completion.cpp
+++ cfe/trunk/test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle 
<}{Placeholder typename T}{RightAngle >} (50)
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)
Index: cfe/trunk/lib/Parse/ParseTemplate.cpp
===
--- cfe/trunk/lib/Parse/ParseTemplate.cpp
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
@@ -1023,8 +1025,8 @@
 ? OO_None
 : TemplateName.OperatorFunctionId.Operator;
 
-TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
-  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
+TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
+  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
   LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
 
 Tok.setAnnotationValue(TemplateId);


Index: cfe/trunk/test/Index/code-completion.cpp
===
--- cfe/trunk/test/Index/code-completion.cpp
+++ cfe/trunk/test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
Index: cfe/trunk/lib/Frontend/ASTUnit.cpp
===
--- cfe/trunk/lib/Frontend/ASTUnit.cpp
+++ cfe/trunk/lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)
Index: cfe/trunk/lib/Parse/ParseTemplate.cpp
===
--- cfe/trunk/lib/Parse/ParseTemplate.cpp
+++ cfe/trunk/lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-

[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-18 Thread Erik Verbruggen via Phabricator via cfe-commits
erikjv added a comment.

I'll commit it, probably next Tuesday.


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-14 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Can someone help me to commit it to the proper branch?
(I don't have permissions)


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-09 Thread Manuel Klimek via Phabricator via cfe-commits
klimek accepted this revision.
klimek added a comment.
This revision is now accepted and ready to land.

LG


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-08 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Ping...


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-07 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan updated this revision to Diff 109968.
yvvan added a comment.

Add unit-test for the case fixed in this review


https://reviews.llvm.org/D35355

Files:
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseTemplate.cpp
  test/Index/code-completion.cpp


Index: test/Index/code-completion.cpp
===
--- test/Index/code-completion.cpp
+++ test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test 
-code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle 
<}{Placeholder typename T}{RightAngle >} (50)
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
@@ -1023,8 +1025,8 @@
 ? OO_None
 : TemplateName.OperatorFunctionId.Operator;
 
-TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
-  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
+TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
+  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
   LAngleLoc, RAngleLoc, TemplateArgs, TemplateIds);
 
 Tok.setAnnotationValue(TemplateId);
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)


Index: test/Index/code-completion.cpp
===
--- test/Index/code-completion.cpp
+++ test/Index/code-completion.cpp
@@ -37,6 +37,16 @@
   return 0;
 }
 
+template 
+struct Foo { T member; };
+
+template using Bar = Foo;
+
+void test_template_alias() {
+  // RUN: env CINDEXTEST_COMPLETION_CACHING=1 c-index-test -code-completion-at=%s:47:1 %s | FileCheck -check-prefix=CHECK-TEMPLATE-ALIAS %s
+
+}
+
 // CHECK-MEMBER: FieldDecl:{ResultType double}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType int}{Text X::}{TypedText member}
 // CHECK-MEMBER: FieldDecl:{ResultType float}{Text Y::}{TypedText member}
@@ -88,3 +98,5 @@
 // CHECK-EXPR-NEXT: Class name
 // CHECK-EXPR-NEXT: Nested name specifier
 // CHECK-EXPR-NEXT: Objective-C interface
+
+// CHECK-TEMPLATE-ALIAS: AliasTemplateDecl:{TypedText Bar}{LeftAngle <}{Placeholder typename T}{RightAngle >} (50)
Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -198,9 +198,11 @@
 
   if (Tok.is(tok::kw_using)) {
 // FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
@@ -1023,8 +1025,8 @@
 ? OO_None
 : TemplateName.OperatorFunctionId.Operator;
 
-TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
-  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
+TemplateIdAnnotation *TemplateId = TemplateIdAnnotation::Create(
+  SS, TemplateKWLoc, TemplateNameLoc, TemplateII, OpKind, Template, TNK,
 

[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

In https://reviews.llvm.org/D35355#831845, @klimek wrote:

> Sorry for missing this - can you add a test?


I think I can :)
Will add it next week.


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Manuel Klimek via Phabricator via cfe-commits
klimek added a comment.

Sorry for missing this - can you add a test?


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-08-04 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

one more Ping. this is quite a useful fix that does not cost much


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-07-18 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan added a comment.

Ping


https://reviews.llvm.org/D35355



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D35355: Fix templated type alias completion when using global completion cache

2017-07-13 Thread Ivan Donchevskii via Phabricator via cfe-commits
yvvan created this revision.

When we have enabled cache for global completions we did not have diagnostics 
for Bar and could not complete Ba as in provided code example.

template 
struct Foo { T member; };

template using Bar = Foo;

int main() {

  Ba

}


https://reviews.llvm.org/D35355

Files:
  lib/Frontend/ASTUnit.cpp
  lib/Parse/ParseTemplate.cpp


Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -197,10 +197,11 @@
   MaybeParseCXX11Attributes(prefixAttrs);
 
   if (Tok.is(tok::kw_using)) {
-// FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, 
TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)


Index: lib/Parse/ParseTemplate.cpp
===
--- lib/Parse/ParseTemplate.cpp
+++ lib/Parse/ParseTemplate.cpp
@@ -197,10 +197,11 @@
   MaybeParseCXX11Attributes(prefixAttrs);
 
   if (Tok.is(tok::kw_using)) {
-// FIXME: We should return the DeclGroup to the caller.
-ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
- prefixAttrs);
-return nullptr;
+auto usingDeclPtr = ParseUsingDirectiveOrDeclaration(Context, TemplateInfo, DeclEnd,
+ prefixAttrs);
+if (!usingDeclPtr)
+  return nullptr;
+return usingDeclPtr.get().getSingleDecl();
   }
 
   // Parse the declaration specifiers, stealing any diagnostics from
Index: lib/Frontend/ASTUnit.cpp
===
--- lib/Frontend/ASTUnit.cpp
+++ lib/Frontend/ASTUnit.cpp
@@ -243,7 +243,8 @@
   
   uint64_t Contexts = 0;
   if (isa(ND) || isa(ND) || 
-  isa(ND) || isa(ND)) {
+  isa(ND) || isa(ND) ||
+  isa(ND)) {
 // Types can appear in these contexts.
 if (LangOpts.CPlusPlus || !isa(ND))
   Contexts |= (1LL << CodeCompletionContext::CCC_TopLevel)
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits