[PATCH] D114864: [clangd] IncludeClenaer: Don't mark forward declarations of a class if it's declared in the main file

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 1 04:48:12 PST 2021


kadircet added a comment.

I can't fully remember the discussion but what about the case in which we don't have a declaration in the main file, but see a definition and multiple forward declarations. Is there a good reason to still include re-decls in this case?



================
Comment at: clang-tools-extra/clangd/IncludeCleaner.cpp:57
+    // because they're often unrelated.
+    if (const auto *RD = llvm::dyn_cast<RecordDecl>(TT->getDecl())) {
+      const auto *MostRecent = RD->getMostRecentDecl();
----------------
why don't we do this inside `add` instead? which can take care of duplication, and remain as the only place we modify `Result` ?


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114864



More information about the cfe-commits mailing list