diff --git a/clang/lib/Sema/SemaCodeComplete.cpp b/clang/lib/Sema/SemaCodeComplete.cpp --- a/clang/lib/Sema/SemaCodeComplete.cpp +++ b/clang/lib/Sema/SemaCodeComplete.cpp @@ -1816,6 +1816,19 @@ Results.AddResult(CodeCompletionResult(Builder.TakeString())); } +// using name = type +static void AddUsingAliasResult(ResultBuilder &Results) { + CodeCompletionBuilder Builder(Results.getAllocator(), + Results.getCodeCompletionTUInfo()); + Builder.AddTypedTextChunk("using"); + Builder.AddChunk(CodeCompletionString::CK_HorizontalSpace); + Builder.AddPlaceholderChunk("name"); + Builder.AddChunk(CodeCompletionString::CK_Equal); + Builder.AddPlaceholderChunk("type"); + Builder.AddChunk(CodeCompletionString::CK_SemiColon); + Results.AddResult(CodeCompletionResult(Builder.TakeString())); +} + static bool WantTypesInContext(Sema::ParserCompletionContext CCC, const LangOptions &LangOpts) { switch (CCC) { @@ -2045,6 +2058,9 @@ if (SemaRef.getLangOpts().ObjC) AddObjCTopLevelResults(Results, true); + if (SemaRef.getLangOpts().CPlusPlus11) + AddUsingAliasResult(Results); + AddTypedefResult(Results); LLVM_FALLTHROUGH; @@ -2073,6 +2089,9 @@ AddStaticAssertResult(Builder, Results, SemaRef.getLangOpts()); if (CCC == Sema::PCC_Class) { + if (SemaRef.getLangOpts().CPlusPlus11) + AddUsingAliasResult(Results); + AddTypedefResult(Results); bool IsNotInheritanceScope = @@ -2139,6 +2158,9 @@ case Sema::PCC_RecoveryInFunction: case Sema::PCC_Statement: { + if (SemaRef.getLangOpts().CPlusPlus11) + AddUsingAliasResult(Results); + AddTypedefResult(Results); if (SemaRef.getLangOpts().CPlusPlus && Results.includeCodePatterns() && diff --git a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp --- a/clang/test/CodeCompletion/ordinary-name-cxx11.cpp +++ b/clang/test/CodeCompletion/ordinary-name-cxx11.cpp @@ -62,6 +62,7 @@ // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-CC1-NEXT: COMPLETION: union // CHECK-CC1-NEXT: COMPLETION: unsigned + // CHECK-CC1-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-CC1-NEXT: COMPLETION: void // CHECK-CC1-NEXT: COMPLETION: volatile @@ -112,6 +113,7 @@ // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-CC2-NEXT: COMPLETION: union // CHECK-CC2-NEXT: COMPLETION: unsigned + // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>; // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-CC2-NEXT: COMPLETION: void @@ -156,6 +158,7 @@ // CHECK-CC3-NEXT: COMPLETION: union // CHECK-CC3-NEXT: COMPLETION: unsigned // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#> + // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC3-NEXT: COMPLETION: virtual // CHECK-CC3-NEXT: COMPLETION: void // CHECK-CC3-NEXT: COMPLETION: volatile @@ -264,6 +267,7 @@ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-NO-RTTI-NEXT: COMPLETION: union // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned + // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-NO-RTTI-NEXT: COMPLETION: void // CHECK-NO-RTTI-NEXT: COMPLETION: volatile diff --git a/clang/test/CodeCompletion/ordinary-name.cpp b/clang/test/CodeCompletion/ordinary-name.cpp --- a/clang/test/CodeCompletion/ordinary-name.cpp +++ b/clang/test/CodeCompletion/ordinary-name.cpp @@ -59,6 +59,7 @@ // CHECK-CC1-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-CC1-NEXT: COMPLETION: union // CHECK-CC1-NEXT: COMPLETION: unsigned + // CHECK-CC1-NOT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC1-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-CC1-NEXT: COMPLETION: void // CHECK-CC1-NEXT: COMPLETION: volatile @@ -102,6 +103,7 @@ // CHECK-CC2-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-CC2-NEXT: COMPLETION: union // CHECK-CC2-NEXT: COMPLETION: unsigned + // CHECK-CC2-NOT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC2-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>; // CHECK-CC2-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-CC2-NEXT: COMPLETION: void @@ -140,6 +142,7 @@ // CHECK-CC3-NEXT: COMPLETION: union // CHECK-CC3-NEXT: COMPLETION: unsigned // CHECK-CC3-NEXT: COMPLETION: Pattern : using <#qualifier#>::<#name#>; + // CHECK-CC3-NOT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-CC3-NEXT: COMPLETION: virtual // CHECK-CC3-NEXT: COMPLETION: void // CHECK-CC3-NEXT: COMPLETION: volatile @@ -232,6 +235,7 @@ // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : typeof(<#type#>) // CHECK-NO-RTTI-NEXT: COMPLETION: union // CHECK-NO-RTTI-NEXT: COMPLETION: unsigned + // CHECK-NO-RTTI-NOT: COMPLETION: Pattern : using <#name#> = <#type#>; // CHECK-NO-RTTI-NEXT: COMPLETION: Pattern : using namespace <#identifier#>; // CHECK-NO-RTTI-NEXT: COMPLETION: void // CHECK-NO-RTTI-NEXT: COMPLETION: volatile