[PATCH] D154382: [ClangRepl] support code completion at a REPL

Vassil Vassilev via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 12 02:45:49 PDT 2023


v.g.vassilev added a reviewer: aaron.ballman.
v.g.vassilev added a subscriber: aaron.ballman.
v.g.vassilev added a comment.

@capfredf this seems to be heading in a good direction. Please find another round of comments.

@aaron.ballman, I could not find a person that's active in that area. Could you help with finding reviewers for this type of patch?



================
Comment at: clang/include/clang/Interpreter/Interpreter.h:117
   ASTContext &getASTContext();
+  void CodeComplete(llvm::StringRef Input, size_t Col, size_t Line = 1);
   const CompilerInstance *getCompilerInstance() const;
----------------
I could not find where this interface was used. If it is unused, let'd drop it.


================
Comment at: clang/include/clang/Sema/Sema.h:13324
+    /// Code completion occurs at top-level in a REPL session
+    PCC_ReplTopLevel,
   };
----------------



================
Comment at: clang/lib/Interpreter/IncrementalParser.cpp:338
+  //   return;
+  // }
+  if (FE) {
----------------
Seems that we have stray debug fragments? Can you remove them?


================
Comment at: clang/lib/Interpreter/IncrementalParser.cpp:376
   // Create FileID for the current buffer.
-  FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, /*LoadedID=*/0,
-                               /*LoadedOffset=*/0, NewLoc);
+  // FileID FID = SM.createFileID(std::move(MB), SrcMgr::C_User, /*LoadedID=*/0,
+  //                              /*LoadedOffset=*/0, NewLoc);
----------------
Why we had to comment out this line?


================
Comment at: clang/lib/Interpreter/Interpreter.cpp:248
+  auto *CConsumer = new ReplCompletionConsumer(CompResults);
+  CI->setCodeCompletionConsumer(CConsumer);
+  IncrParser = std::make_unique<IncrementalParser>(
----------------
IIUC, `setCodeCompletionConsumer` takes the ownership of `CConsumer`. I'd suggest to drop `CConsumer` member.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D154382/new/

https://reviews.llvm.org/D154382



More information about the cfe-commits mailing list