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
- Build Status
Buildable 15150 Build 15150: arc lint + arc unit
Event Timeline
clangd/Headers.cpp | ||
---|---|---|
45 | There is another list of header extensions in ClangdServer::switchSourceHeader, let's reuse the list of extensions used here and there. | |
48 | Maybe use llvm::sys::path::extension and search it in HeaderExtensions using StringRef::equals_lower? | |
60 | 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 | ||
173 | Why not on Windows? |
clangd/Headers.cpp | ||
---|---|---|
42–43 | 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 | ||
---|---|---|
45 | 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 | ||
173 | because our system header map doesn't really support windows... |
clangd/Headers.h | ||
---|---|---|
26–27 | File also needs to be absolute. | |
clangd/index/FileIndex.cpp | ||
35 | if this is always true now, we could remove the option? | |
36 | This is not going to handle IWYU right? |
clangd/Headers.cpp | ||
---|---|---|
68 | Not related to this patch, but just noticed that we don't call FS->setCurrentWorkingDirectory(CompileCommand.Directory) here. | |
clangd/index/CanonicalIncludes.cpp | ||
21 ↗ | (On Diff #134932) | 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. | |
37 | NIT: remove local var, replace with CollectorOpts.Includes = CanonicalIncludesForSystemHeaders()? | |
unittests/clangd/FileIndexTests.cpp | ||
173 | Thanks for clarification. |
clangd/index/CanonicalIncludes.cpp | ||
---|---|---|
21 ↗ | (On Diff #134932) | 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)