[clang] [clang-tools-extra] [clangd] Autocomplete fixes for methods (PR #165916)

Nathan Ridge via cfe-commits cfe-commits at lists.llvm.org
Sat Mar 7 23:07:21 PST 2026


================
@@ -6860,12 +6966,19 @@ void SemaCodeCompletion::CodeCompleteQualifiedId(Scope *S, CXXScopeSpec &SS,
   // resolves to a dependent record.
   DeclContext *Ctx = SemaRef.computeDeclContext(SS, /*EnteringContext=*/true);
 
+  std::optional<Sema::ContextRAII> SavedContext;
+  // When completing a definition, simulate that we are in class scope to access
+  // private methods.
+  if (IsInDeclarationContext && Ctx != nullptr)
+    SavedContext.emplace(SemaRef, Ctx);
+
   // Try to instantiate any non-dependent declaration contexts before
   // we look in them. Bail out if we fail.
   NestedNameSpecifier NNS = SS.getScopeRep();
   if (NNS && !NNS.isDependent()) {
-    if (Ctx == nullptr || SemaRef.RequireCompleteDeclContext(SS, Ctx))
+    if (Ctx == nullptr || SemaRef.RequireCompleteDeclContext(SS, Ctx)) {
----------------
HighCommander4 wrote:

nit: drop this brace addition

https://github.com/llvm/llvm-project/pull/165916


More information about the cfe-commits mailing list