Move `RecordDecl::isInjectedClassName` to
`CXXRecordDecl::isInjectedClassName`. C language doesn't have the term
"injected class name".
Co-authored-by: Matheus Izvekov <mizvekov@gmail.com>
Coming from internal using experience.
The original log is just confusing... Users can't understand it unless
he reads the code.
This patch tries to make this more understandable.
Note that the mentioned module files in the logs might be removed
intentionally. We need another option to allow users to remain these
module files. Let's done this in another patch.
This patch switches over uses of use_clang to clang_setup to fix a
potential race condition that has been impacting CI.
This is split from the refactoring to ensure I'm not missing anything
major here on the clang-tools-extra side.
This should fix#145703.
Reviewers: AaronBallman, HighCommander4, HerrCai0907, petrhosek, Keenuts
Reviewed By: petrhosek
Pull Request: https://github.com/llvm/llvm-project/pull/147437
In PR #128503, the CLI option would take precedence over the config option
only if it was set to `never`. This commit ensures the CLI option always takes
precedence over the config option.
ArrayRef has a constructor that accepts std::nullopt. This
constructor dates back to the days when we still had llvm::Optional.
Since the use of std::nullopt outside the context of std::optional is
kind of abuse and not intuitive to new comers, I would like to move
away from the constructor and eventually remove it.
This patch replaces std::nullopt with {}.
This PR adds support for the `positionEncoding` client capability
introduced in LSP 3.17. Clangd can now negotiate the position encoding
with the client during initialization.
Fix https://github.com/clangd/clangd/issues/1746
Co-authored-by: kadir çetinkaya <kadircetinkaya.06.tr@gmail.com>
This is a re-application of llvm/llvm-project#142090 without the unit
test changes. A subsequent PR will follow that adds a unit test for
module dependencies.
### Changes
- Fix dangling string references in the return value of
getAllRequiredModules()
- Change a couple of calls in getOrBuildModuleFile() to use the loop
variable instead of the ModuleName parameter.
@ChuanqiXu9 for review
The missing include diagnostic has the capability to introduce the
necessary headers into the source file. However, it does not currently
follow the inclusion style found in the `.clangd` file. For example, if
the file explicitly mentions that headers should be include with angled
brackets, they could be included with quotes instead. More details in
https://github.com/llvm/llvm-project/issues/138740. This PR fixes this
gap, so that the style configuration is followed.
Users sometimes forget about configuration they've placed in the user
config file, or an ancestor directory of their project.
Logging the paths of loaded config files by default (without
--log=verbose) surfaces more readily where clangd is getting its
configuration from.
Simple module import dependencies, see
[module_dependencies.test](https://github.com/llvm/llvm-project/compare/main...fleeting-xx:llvm-project:fix_clangd_dependent_modules#diff-5510681cbe5b7ed3a72c5e683184e83fa66e911e9abb0e6670b01b87b3ca7b1a),
were not being correctly handled due to a couple of issues.
- The `MDB.getRequiredModules()` call returned a
`std::vector<std::string>` and all `StringRefs` were to entries in that
temporary value. So the `StringRef` elements in
`getAllRequiredModules()`'s return value were bound to values that went
out of scope.
- `ModulesBuilder::ModulesBuilderImpl::getOrBuildModuleFile()` was
iterating over each module dependency name, but only using the original
module name and path for various checks and module compilation.
In addition to fixing the above issues I added support for Windows paths
in modules.test and added a new unit test, module_dependencies.test,
which demonstrates the failure in the previous state and works correctly
after the fixes have been applied.
Please let me know if I've missed anything.
Co-authored-by: Dan Baker <dan@requires.coffee>
Under previous test setup, the test result will be influenced by
clang-tidy file in parent folder (between llvm-projects root and build
folder). It is inconventient and leads some confusion.
This PR wants to ensure sandbox to avoid outside's clang-tidy influenece
test result.
This reverts commit e2a885537f11f8d9ced1c80c2c90069ab5adeb1d. Build failures were fixed right away and reverting the original commit without the fixes breaks the build again.
The `DiagnosticOptions` class is currently intrusively
reference-counted, which makes reasoning about its lifetime very
difficult in some cases. For example, `CompilerInvocation` owns the
`DiagnosticOptions` instance (wrapped in `llvm::IntrusiveRefCntPtr`) and
only exposes an accessor returning `DiagnosticOptions &`. One would
think this gives `CompilerInvocation` exclusive ownership of the object,
but that's not the case:
```c++
void shareOwnership(CompilerInvocation &CI) {
llvm::IntrusiveRefCntPtr<DiagnosticOptions> CoOwner = &CI.getDiagnosticOptions();
// ...
}
```
This is a perfectly valid pattern that is being actually used in the
codebase.
I would like to ensure the ownership of `DiagnosticOptions` by
`CompilerInvocation` is guaranteed to be exclusive. This can be
leveraged for a copy-on-write optimization later on. This PR changes
usages of `DiagnosticOptions` across `clang`, `clang-tools-extra` and
`lldb` to not be intrusively reference-counted.
This reverts commit 7a242387c950c7060143da6da0e6fb91f36bb458. Even after 175f8a44, the Modules/fmodules-validate-once-per-build-session.c test is not fixed on the clang-armv8-quick build bot. (Failure occurs on line 114.)
This reverts commit 18b885f66babff3a10451bc811ffc077d61ed8ee, effectively reapplying #139987. This commit fixes unit tests (for example ASTUnitTest.SaveLoadPreservesLangOptionsInPrintingPolicy) where the `ASTUnit::ModCache` pointer dereferenced within `ASTUnit::serialize()` was null. This commit makes sure each factory function does initialize `ASTUnit::ModCache`.
This fixes an issue reported by the sanitizer with the following error
message:
`copy_constructor_call: IndexOpts` is passed by value as a parameter to`
clang::index::IndexingOptions::IndexingOptions` instead of being moved.
Timestamps are an implementation detail of the cross-process module
cache implementation. This PR hides it from the `ModuleCache` API, which
simplifies the in-process implementation.
This PR makes it so that `CompilerInvocation` needs to be provided to
`CompilerInstance` on construction. There are a couple of benefits in my
view:
* Making it impossible to mis-use some `CompilerInstance` APIs. For
example there are cases, where `createDiagnostics()` was called before
`setInvocation()`, causing the `DiagnosticEngine` to use the
default-constructed `DiagnosticOptions` instead of the intended ones.
* This shrinks `CompilerInstance`'s state space.
* This makes it possible to access **the** invocation in
`CompilerInstance`'s constructor (to be used in a follow-up).
This PR hides the reference-counted pointer that holds `TargetOptions`
from the public API of `CompilerInvocation`. This gives
`CompilerInvocation` an exclusive control over the lifetime of this
member, which will eventually be leveraged to implement a copy-on-write
behavior.
There are two clients that currently share ownership of that pointer:
* `TargetInfo` - This was refactored to hold a non-owning reference to
`TargetOptions`. The options object is typically owned by the
`CompilerInvocation` or by the new `CompilerInstance::AuxTargetOpts` for
the auxiliary target. This needed a bit of care in `ASTUnit::Parse()` to
keep the `CompilerInvocation` alive.
* `clangd::PreambleData` - This was refactored to exclusively own the
`TargetOptions` that get moved out of the `CompilerInvocation`.
`CallHierarchyOutgoingCall::fromRanges` are interpreted as ranges in the
same file as the item for which 'outgoingCalls' was called.
It's possible for outgoing calls to be in a different file than that
item if the item is just a declaration (e.g. in a header file). Now,
such calls are dropped instead of being returned to the client.
This is the same as the change made in #111616, but now for outgoing
calls.
Fixesclangd/clangd#2350
---------
Co-authored-by: Nathan Ridge <zeratul976@hotmail.com>
* Only show for blocks 10 lines or taller (including braces)
* Add parens for function call: "// if foo" -> "// if foo()" or "// if foo(...)"
* Print literal nullptr
* Escaping for abbreviated strings
Fixes https://github.com/clangd/clangd/issues/1807.
Based on the original PR at https://github.com/llvm/llvm-project/pull/72345.
Co-authored-by: daiyousei-qz <qyzheng2@outlook.com>