[clang] [ClangRepl] Type Directed Code Completion (PR #67349)

Vassil Vassilev via cfe-commits cfe-commits at lists.llvm.org
Mon Nov 6 10:58:19 PST 2023


================
@@ -159,29 +308,62 @@ void ExternalSource::completeVisibleDeclsMap(
   for (auto *DeclCtxt = ParentTUDeclCtxt; DeclCtxt != nullptr;
        DeclCtxt = DeclCtxt->getPreviousDecl()) {
     for (auto &IDeclContext : DeclCtxt->decls()) {
-      if (NamedDecl *Decl = llvm::dyn_cast<NamedDecl>(IDeclContext)) {
-        if (auto DeclOrErr = Importer->Import(Decl)) {
-          if (NamedDecl *importedNamedDecl =
-                  llvm::dyn_cast<NamedDecl>(*DeclOrErr)) {
-            SetExternalVisibleDeclsForName(ChildDeclContext,
-                                           importedNamedDecl->getDeclName(),
-                                           importedNamedDecl);
-          }
-
-        } else {
-          llvm::consumeError(DeclOrErr.takeError());
-        }
+      if (!llvm::isa<NamedDecl>(IDeclContext))
+        continue;
+
+      NamedDecl *Decl = llvm::cast<NamedDecl>(IDeclContext);
+
+      auto DeclOrErr = Importer->Import(Decl);
+      if (!DeclOrErr) {
+        llvm::consumeError(DeclOrErr.takeError());
+        continue;
       }
+
+      if (!llvm::isa<NamedDecl>(*DeclOrErr))
+        continue;
+
+      NamedDecl *importedNamedDecl = llvm::cast<NamedDecl>(*DeclOrErr);
+
+      SetExternalVisibleDeclsForName(ChildDeclContext,
+                                     importedNamedDecl->getDeclName(),
+                                     importedNamedDecl);
+
+      if (!llvm::isa<CXXRecordDecl>(importedNamedDecl))
+        continue;
+
+      auto *Record =
+        llvm::cast<CXXRecordDecl>(importedNamedDecl);
+
+      if (auto Err = Importer->ImportDefinition(Decl)) {
+        consumeError(std::move(Err));
----------------
vgvassilev wrote:

Likewise.

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


More information about the cfe-commits mailing list