[PATCH] D130363: [clang] Give priority to Class context while parsing declarations
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Aug 17 01:07:10 PDT 2022
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4dd71b3cb947: [clang] Give priority to Class context while parsing declarations (authored by furkanusta, committed by kadircet).
Changed prior to commit:
https://reviews.llvm.org/D130363?vs=451604&id=453224#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D130363/new/
https://reviews.llvm.org/D130363
Files:
clang/lib/Parse/ParseDecl.cpp
clang/test/CodeCompletion/overrides.cpp
Index: clang/test/CodeCompletion/overrides.cpp
===================================================================
--- clang/test/CodeCompletion/overrides.cpp
+++ clang/test/CodeCompletion/overrides.cpp
@@ -11,7 +11,7 @@
class C : public B {
public:
void vfunc(bool param) override;
- vf
+ vf;
};
// Runs completion at ^vf
@@ -31,3 +31,13 @@
// CHECK-CC3-NOT: COMPLETION: Pattern : int ttt(bool param, int x = 3) const override{{$}}
// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
// CHECK-CC3-NOT: COMPLETION: Pattern : void vfunc(bool param) override{{$}}
+
+void func() {
+ class D : public A {
+
+ };
+}
+
+// Runs completion at empty line on line 37.
+// RUN: not %clang_cc1 -fsyntax-only -code-completion-at=%s:37:1 %s -o - | FileCheck -check-prefix=CHECK-CC4 %s
+// CHECK-CC4: COMPLETION: Pattern : void vfunc(bool param, int p) override{{$}}
Index: clang/lib/Parse/ParseDecl.cpp
===================================================================
--- clang/lib/Parse/ParseDecl.cpp
+++ clang/lib/Parse/ParseDecl.cpp
@@ -3266,13 +3266,14 @@
return;
}
- if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
- CCC = Sema::PCC_LocalDeclarationSpecifiers;
- else if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
+ // Class context can appear inside a function/block, so prioritise that.
+ if (TemplateInfo.Kind != ParsedTemplateInfo::NonTemplate)
CCC = DSContext == DeclSpecContext::DSC_class ? Sema::PCC_MemberTemplate
: Sema::PCC_Template;
else if (DSContext == DeclSpecContext::DSC_class)
CCC = Sema::PCC_Class;
+ else if (getCurScope()->getFnParent() || getCurScope()->getBlockParent())
+ CCC = Sema::PCC_LocalDeclarationSpecifiers;
else if (CurParsedObjCImpl)
CCC = Sema::PCC_ObjCImplementation;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130363.453224.patch
Type: text/x-patch
Size: 1936 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20220817/078e44a5/attachment.bin>
More information about the cfe-commits
mailing list