[PATCH] D156403: [clangd] Revert the symbol collector behavior to old pre-include-cleaner-library behavior due to a regression.

Kadir Cetinkaya via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jul 27 03:25:13 PDT 2023


kadircet accepted this revision.
kadircet added inline comments.
This revision is now accepted and ready to land.


================
Comment at: clang-tools-extra/clangd/index/SymbolCollector.cpp:901
     }
+    if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
+      if (auto Header = StdSym->header())
----------------
we shouldn't be overriding the include header if it's already set above. also i think it would be easier to have this out of the way so that reverting to old behaviour is easier:
```
llvm::StringRef getStdHeader(const Symbol *S, const LanguageOptions &LO) {
  tooling::stdlib::Lang Lang = tooling::stdlib::Lang::CXX;
    if (ASTCtx->getLangOpts().C11)
      Lang = tooling::stdlib::Lang::C;
    else if(!ASTCtx->getLangOpts().CPlusPlus)
      return "";

    if (S->Scope == "std::" && S->Name == "move") {
      if (!S->Signature.contains(','))
        return "<utility>";
      return "<algorithm>";
    }
   
    if (auto StdSym = tooling::stdlib::Symbol::named(S->Scope, S->Name, Lang))
     if (auto Header = StdSym->header())
       return Header->name();
    return "";
}
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D156403



More information about the cfe-commits mailing list