[PATCH] D38618: Do not add a colon chunk to the code completion of class inheritance access modifiers
Erik Verbruggen via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Oct 24 06:47:40 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL316436: Do not add a colon chunk to the code completion of class inheritance access… (authored by erikjv).
Changed prior to commit:
https://reviews.llvm.org/D38618?vs=119273&id=120067#toc
Repository:
rL LLVM
https://reviews.llvm.org/D38618
Files:
cfe/trunk/include/clang/Sema/Scope.h
cfe/trunk/lib/Parse/ParseDeclCXX.cpp
cfe/trunk/lib/Sema/SemaCodeComplete.cpp
cfe/trunk/test/Index/complete-super.cpp
Index: cfe/trunk/include/clang/Sema/Scope.h
===================================================================
--- cfe/trunk/include/clang/Sema/Scope.h
+++ cfe/trunk/include/clang/Sema/Scope.h
@@ -127,6 +127,9 @@
/// This is a compound statement scope.
CompoundStmtScope = 0x400000,
+
+ /// We are between inheritance colon and the real class/struct definition scope.
+ ClassInheritanceScope = 0x800000,
};
private:
/// The parent scope for this scope. This is null for the translation-unit
Index: cfe/trunk/test/Index/complete-super.cpp
===================================================================
--- cfe/trunk/test/Index/complete-super.cpp
+++ cfe/trunk/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)
Index: cfe/trunk/lib/Sema/SemaCodeComplete.cpp
===================================================================
--- cfe/trunk/lib/Sema/SemaCodeComplete.cpp
+++ cfe/trunk/lib/Sema/SemaCodeComplete.cpp
@@ -1658,21 +1658,23 @@
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: cfe/trunk/lib/Parse/ParseDeclCXX.cpp
===================================================================
--- cfe/trunk/lib/Parse/ParseDeclCXX.cpp
+++ cfe/trunk/lib/Parse/ParseDeclCXX.cpp
@@ -3195,6 +3195,9 @@
}
if (Tok.is(tok::colon)) {
+ ParseScope InheritanceScope(this, getCurScope()->getFlags() |
+ Scope::ClassInheritanceScope);
+
ParseBaseClause(TagDecl);
if (!Tok.is(tok::l_brace)) {
bool SuggestFixIt = false;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D38618.120067.patch
Type: text/x-patch
Size: 3141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20171024/acc4dbed/attachment.bin>
More information about the cfe-commits
mailing list