o Avoid inserting a header include into the header itself.
o Avoid inserting non-header files.
o Canonicalize include paths for symbols in dynamic index.
Details
Diff Detail
- Repository
- rCTE Clang Tools Extra
Event Timeline
clangd/Headers.cpp | ||
---|---|---|
46 | There is another list of header extensions in ClangdServer::switchSourceHeader, let's reuse the list of extensions used here and there. | |
49 | Maybe use llvm::sys::path::extension and search it in HeaderExtensions using StringRef::equals_lower? | |
53 | Maybe replace !hasHeaderExtension(Header) to hasSourceExtension(Header)? | |
clangd/index/FileIndex.cpp | ||
18 | Maybe store a static inside the function body (to properly free memory) and return a const reference (to avoid mutating shared data)? const CanonicalIncludes &CanonicalIncludesForSystemHeaders() { static CanonicalInclude Includes = []() -> CanonicalHeader { CanonicalInclude Includes; addSystemHeadersMapping(Includes); return Includes; }; return Includes; } Also Sam mentioned that CanonicalIncludes is not thread-safe, as the Regex's match() mutates. | |
unittests/clangd/FileIndexTests.cpp | ||
184 | Why not on Windows? |
clangd/Headers.cpp | ||
---|---|---|
43–44 | As discussed offline, this seems dubious.
(later we'll want a flag on the symbol for whether it's public, so we can support find-symbol-by-name for mainfile-declared symbols) |
- Stop indexing main files in dynamic index; addressed review comments.
clangd/Headers.cpp | ||
---|---|---|
46 | Acked. (The change is not relevant anymore.) | |
clangd/index/FileIndex.cpp | ||
18 | As discussed offline, we want to avoid destructing static objects because ... Made CanonicalIncludes thread-safe by adding a mutex around matches. | |
unittests/clangd/FileIndexTests.cpp | ||
184 | because our system header map doesn't really support windows... |
clangd/Headers.h | ||
---|---|---|
27–28 | File also needs to be absolute. | |
clangd/index/FileIndex.cpp | ||
36 | if this is always true now, we could remove the option? | |
37 | This is not going to handle IWYU right? |
clangd/Headers.cpp | ||
---|---|---|
66 | Not related to this patch, but just noticed that we don't call FS->setCurrentWorkingDirectory(CompileCommand.Directory) here. | |
clangd/index/CanonicalIncludes.cpp | ||
21 | Technically, if one thread initializes CanonicalIncludes and the other thread reads from it, this is a data race. | |
clangd/index/FileIndex.cpp | ||
18 | NIT: lowerCase the function name. | |
38 | NIT: remove local var, replace with CollectorOpts.Includes = CanonicalIncludesForSystemHeaders()? | |
unittests/clangd/FileIndexTests.cpp | ||
184 | Thanks for clarification. |
clangd/index/CanonicalIncludes.cpp | ||
---|---|---|
21 | As Sam pointed out, it's fine the way it is right now. We don't want any thread-safety guarantees from the non-const methods of the class. |
File also needs to be absolute.
(May want to add asserts for this at the start of the impl - up to you)