Index: include/clang/Sema/Scope.h =================================================================== --- include/clang/Sema/Scope.h +++ include/clang/Sema/Scope.h @@ -124,6 +124,9 @@ /// We are currently in the filter expression of an SEH except block. SEHFilterScope = 0x200000, + + /// We are between inheritance colon and the real class/struct definition scope + ClassInheritanceScope = 0x400000, }; private: /// The parent scope for this scope. This is null for the translation-unit Index: lib/Parse/ParseDeclCXX.cpp =================================================================== --- lib/Parse/ParseDeclCXX.cpp +++ lib/Parse/ParseDeclCXX.cpp @@ -3193,6 +3193,9 @@ } if (Tok.is(tok::colon)) { + ParseScope InheritanceScope(this, Scope::ClassScope | Scope::DeclScope | + Scope::ClassInheritanceScope); + ParseBaseClause(TagDecl); if (!Tok.is(tok::l_brace)) { bool SuggestFixIt = false; Index: lib/Sema/SemaCodeComplete.cpp =================================================================== --- lib/Sema/SemaCodeComplete.cpp +++ lib/Sema/SemaCodeComplete.cpp @@ -1647,21 +1647,22 @@ if (CCC == Sema::PCC_Class) { AddTypedefResult(Results); + bool IsNotInheritanceScope = !(S->getFlags() & Scope::ClassInheritanceScope); // public: Builder.AddTypedTextChunk("public"); - if (Results.includeCodePatterns()) + if (IsNotInheritanceScope && Results.includeCodePatterns()) Builder.AddChunk(CodeCompletionString::CK_Colon); Results.AddResult(Result(Builder.TakeString())); // protected: Builder.AddTypedTextChunk("protected"); - if (Results.includeCodePatterns()) + if (IsNotInheritanceScope && Results.includeCodePatterns()) Builder.AddChunk(CodeCompletionString::CK_Colon); Results.AddResult(Result(Builder.TakeString())); // private: Builder.AddTypedTextChunk("private"); - if (Results.includeCodePatterns()) + if (IsNotInheritanceScope && Results.includeCodePatterns()) Builder.AddChunk(CodeCompletionString::CK_Colon); Results.AddResult(Result(Builder.TakeString())); } Index: test/Index/complete-super.cpp =================================================================== --- test/Index/complete-super.cpp +++ test/Index/complete-super.cpp @@ -40,3 +40,8 @@ // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText private}{Colon :} (40) // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText protected}{Colon :} (40) // CHECK-ACCESS-PATTERN: NotImplemented:{TypedText public}{Colon :} (40) + +// RUN: env CINDEXTEST_CODE_COMPLETE_PATTERNS=1 c-index-test -code-completion-at=%s:10:12 %s | FileCheck -check-prefix=CHECK-INHERITANCE-PATTERN %s +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText private} (40) +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText protected} (40) +// CHECK-INHERITANCE-PATTERN: NotImplemented:{TypedText public} (40)