Merge remote-tracking branch 'origin/swift-3.1-branch' into stable
* origin/swift-3.1-branch:
Handle StaticAssertDecl in DeclContextPrinter
Handle VarTemplateDecl in DeclContextPrinter
Handle AccessSpecDecl in DeclContextPrinter
Handle ClassTemplateSpecializationDecl in DeclContextPrinter
Handle EmptyDecl in DeclContextPrinter
Handle UsingDecl and UsingShadowDecl in DeclContextPrinter
Handle FriendDecl in DeclContextPrinter
[CodeCompletion] Autocomplete NS_DESIGNATED_INITIALIZER in initializers with arguments
diff --git a/lib/Frontend/ASTConsumers.cpp b/lib/Frontend/ASTConsumers.cpp
index bd2ee06..d8118cb 100644
--- a/lib/Frontend/ASTConsumers.cpp
+++ b/lib/Frontend/ASTConsumers.cpp
@@ -370,6 +370,26 @@
break;
}
+ case Decl::ClassTemplateSpecialization: {
+ const auto *CTSD = cast<ClassTemplateSpecializationDecl>(DC);
+ if (CTSD->isCompleteDefinition())
+ Out << "[class template specialization] ";
+ else
+ Out << "<class template specialization> ";
+ Out << *CTSD;
+ break;
+ }
+
+ case Decl::ClassTemplatePartialSpecialization: {
+ const auto *CTPSD = cast<ClassTemplatePartialSpecializationDecl>(DC);
+ if (CTPSD->isCompleteDefinition())
+ Out << "[class template partial specialization] ";
+ else
+ Out << "<class template partial specialization> ";
+ Out << *CTPSD;
+ break;
+ }
+
default:
llvm_unreachable("a decl that inherits DeclContext isn't handled");
}
@@ -400,7 +420,8 @@
case Decl::CXXConstructor:
case Decl::CXXDestructor:
case Decl::CXXConversion:
- {
+ case Decl::ClassTemplateSpecialization:
+ case Decl::ClassTemplatePartialSpecialization: {
DeclContext* DC = cast<DeclContext>(I);
PrintDeclContext(DC, Indentation+2);
break;
@@ -478,6 +499,37 @@
Out << "<omp threadprivate> " << '"' << I << "\"\n";
break;
}
+ case Decl::Friend: {
+ Out << "<friend>";
+ if (const NamedDecl *ND = cast<FriendDecl>(I)->getFriendDecl())
+ Out << ' ' << *ND;
+ Out << "\n";
+ break;
+ }
+ case Decl::Using: {
+ Out << "<using> " << *cast<UsingDecl>(I) << "\n";
+ break;
+ }
+ case Decl::UsingShadow: {
+ Out << "<using shadow> " << *cast<UsingShadowDecl>(I) << "\n";
+ break;
+ }
+ case Decl::Empty: {
+ Out << "<empty>\n";
+ break;
+ }
+ case Decl::AccessSpec: {
+ Out << "<access specifier>\n";
+ break;
+ }
+ case Decl::VarTemplate: {
+ Out << "<var template> " << *cast<VarTemplateDecl>(I) << "\n";
+ break;
+ }
+ case Decl::StaticAssert: {
+ Out << "<static assert>\n";
+ break;
+ }
default:
Out << "DeclKind: " << DK << '"' << I << "\"\n";
llvm_unreachable("decl unhandled");
diff --git a/lib/Sema/SemaCodeComplete.cpp b/lib/Sema/SemaCodeComplete.cpp
index 1532c55..a4b58d6 100644
--- a/lib/Sema/SemaCodeComplete.cpp
+++ b/lib/Sema/SemaCodeComplete.cpp
@@ -7470,6 +7470,23 @@
}
Results.ExitScope();
+
+ if (!AtParameterName && !SelIdents.empty() &&
+ SelIdents.front()->getName().startswith("init")) {
+ for (const auto &M : PP.macros()) {
+ if (M.first->getName() != "NS_DESIGNATED_INITIALIZER")
+ continue;
+ Results.EnterNewScope();
+ CodeCompletionBuilder Builder(Results.getAllocator(),
+ Results.getCodeCompletionTUInfo());
+ Builder.AddTypedTextChunk(
+ Builder.getAllocator().CopyString(M.first->getName()));
+ Results.AddResult(CodeCompletionResult(Builder.TakeString(), CCP_Macro,
+ CXCursor_MacroDefinition));
+ Results.ExitScope();
+ }
+ }
+
HandleCodeCompleteResults(this, CodeCompleter,
CodeCompletionContext::CCC_Other,
Results.data(),Results.size());
diff --git a/test/Coverage/ast-printing.cpp b/test/Coverage/ast-printing.cpp
index 3205078..40d04a8 100644
--- a/test/Coverage/ast-printing.cpp
+++ b/test/Coverage/ast-printing.cpp
@@ -1,7 +1,7 @@
-// RUN: %clang_cc1 -fsyntax-only %s
-// RUN: %clang_cc1 -ast-print %s
-// RUN: %clang_cc1 -ast-dump %s
-// RUN: %clang_cc1 -print-decl-contexts %s
-// RUN: %clang_cc1 -fdump-record-layouts %s
+// RUN: %clang_cc1 -std=c++14 -fsyntax-only %s
+// RUN: %clang_cc1 -std=c++14 -ast-print %s
+// RUN: %clang_cc1 -std=c++14 -ast-dump %s
+// RUN: %clang_cc1 -std=c++14 -print-decl-contexts %s
+// RUN: %clang_cc1 -std=c++14 -fdump-record-layouts %s
#include "cxx-language-features.inc"
diff --git a/test/Coverage/cxx-language-features.inc b/test/Coverage/cxx-language-features.inc
index 31b50be..1e3b074 100644
--- a/test/Coverage/cxx-language-features.inc
+++ b/test/Coverage/cxx-language-features.inc
@@ -25,3 +25,43 @@
template <E1 v> class C1 {};
template <E1 v> C1<v> f1() { return C1<v>(); }
void f2() { f1<EC1>(); }
+
+// Friend declarations
+struct FriendlyStruct {
+ friend bool operator==(FriendlyStruct, FriendlyStruct) { return true; }
+ friend struct FriendedStruct;
+};
+
+struct FriendedStruct { };
+
+// Using declaration
+namespace provider {
+ void foo();
+}
+namespace user {
+ using provider::foo;
+}
+
+// Empty declaration
+;
+
+// Template specialization declarations
+template<typename T> class ClassTemplateSpecialization;
+
+template<>
+class ClassTemplateSpecialization<bool> { };
+
+template<typename T, bool> struct ClassTemplatePartialSpecialization;
+
+template<typename T>
+struct ClassTemplatePartialSpecialization<T, true> { };
+
+// Access specifier
+struct AccessSpec {
+private:
+};
+
+// Variable template
+template <typename T> T varTemplate = 0;
+
+static_assert(true, "");
diff --git a/test/Index/complete-designated-initializer.m b/test/Index/complete-designated-initializer.m
new file mode 100644
index 0000000..4ccafc2
--- /dev/null
+++ b/test/Index/complete-designated-initializer.m
@@ -0,0 +1,43 @@
+// Note: the run lines follow their respective tests, since line/column
+// matter in this test.
+
+// rdar://21014571
+
+#define NS_DESIGNATED_INITIALIZER __attribute__((objc_designated_initializer))
+
+@interface DesignatedInitializerCompletion
+
+- (instancetype)init ;
+- (instancetype)initWithFoo:(int)foo ;
+- (instancetype)initWithX:(int)x andY:(int)y ;
+
+@end
+
+@implementation DesignatedInitializerCompletion
+
+- (instancetype)init {
+}
+
+- (instancetype)initWithFoo:(int)foo {
+}
+
+- (instancetype)initWithX:(int)x andY:(int)y {
+}
+
+@end
+
+// RUN: c-index-test -code-completion-at=%s:10:22 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:11:38 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:11:29 %s | FileCheck -check-prefix=CHECK-NONE %s
+// RUN: c-index-test -code-completion-at=%s:11:34 %s | FileCheck -check-prefix=CHECK-NONE %s
+// RUN: c-index-test -code-completion-at=%s:12:34 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:12:46 %s | FileCheck %s
+
+// RUN: c-index-test -code-completion-at=%s:18:22 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:21:38 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:24:34 %s | FileCheck %s
+// RUN: c-index-test -code-completion-at=%s:24:46 %s | FileCheck %s
+
+// CHECK: macro definition:{TypedText NS_DESIGNATED_INITIALIZER} (70)
+
+// CHECK-NONE-NOT: NS_DESIGNATED_INITIALIZER