[PATCH] D61104: [clang][ASTContext] Try to avoid sorting comments for code completion

Dmitri Gribenko via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Apr 25 08:51:20 PDT 2019


gribozavr added inline comments.


================
Comment at: clang/include/clang/AST/ASTContext.h:800
+  /// The result doesn't contain decls that don't have any comment attached.
+  std::unordered_map<const Decl *, RawComment *> getRawCommentsForDeclsNoCache(
+      const std::unordered_map<const Decl *, std::vector<const Decl *>>
----------------
Why not DenseMap?


================
Comment at: clang/include/clang/AST/ASTContext.h:808
+  std::unordered_map<const Decl *, RawComment *>
+  getRawCommentsForAnyRedecls(const std::vector<const Decl *> &NDs) const;
+
----------------
Use ArrayRef.


================
Comment at: clang/lib/AST/ASTContext.cpp:303
+
+  return Result;
+}
----------------
I'm really worried about all the logic duplication here vs. existing code.


================
Comment at: clang/lib/AST/RawCommentList.cpp:366
+    }
+  }
 }
----------------
Why is merging in `RawCommentList::addComment` not sufficient?


================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3180
   if (IncludeBriefComments) {
+    // Try to get the comment if it wasn't provided
+    if (!Comment)
----------------
There are only a couple of callers of this function, can we change them all to provide a comment if it exists?


================
Comment at: clang/lib/Sema/SemaCodeComplete.cpp:3398
+  for (const auto *const ND : NDs) {
+    if (const ObjCMethodDecl *M = dyn_cast<ObjCMethodDecl>(ND)) {
+      if (const ObjCPropertyDecl *PDecl = M->findPropertyDecl()) {
----------------
This method decl logic looks out of place here.  It should be pushed down into the core logic for attaching comments.


Repository:
  rC Clang

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

https://reviews.llvm.org/D61104





More information about the cfe-commits mailing list