Summary:
Diagnostic locations were broken when it was result of a macro
expansion. This patch fixes it by using expansion location instead of location
inside macro body.
Fixes https://github.com/clangd/clangd/issues/201.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70494
Summary:
Currently define inline action fully qualifies any names in the
function body, which is not optimal and definitely natural.
This patch tries to improve the situation by dropping any name
specifiers shared by function and names spelled in the body. For example
if you are moving definition of a function in namespace clang::clangd,
and body has any decl's coming from clang or clang::clangd namespace,
those qualifications won't be added since they are redundant.
It also drops any qualifiers that are visible in target context.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69033
Summary:
Introduce a new helper for getting minimally required qualifiers
necessary to spell a name at a point in a given DeclContext. Currently takes
using directives and nested namespecifier of DeclContext itself into account.
Initially will be used in define inline and outline actions.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69608
The original bug report can be found
[here](https://github.com/clangd/clangd/issues/85)
Given the following code:
```c++
void function() {
auto Lambda = [](int a, double &b) {return 1.f;};
La^
}
```
Triggering the completion at `^` would show `(lambda)` before this patch
and would show signature `(int a, double &b) const`, build a snippet etc
with this patch.
Reviewers: sammccall
Reviewed by: sammccall
Differential revision: https://reviews.llvm.org/D70445
Summary:
This is mostly mechanical, with a few exceptions:
- getDeducedType moved into AST.h where it belongs. It now takes
ASTContext instead of ParsedAST, and avoids using the preprocessor.
- hover now uses SelectionTree directly rather than via
getDeclAtPosition helper
- hover on 'auto' used to find the decl that contained the 'auto' and
use that to set Kind and documentation for the hover result.
Now we use targetDecl() to find the decl matching the deduced type instead.
This changes tests, e.g. 'variable' -> class for auto on lambdas.
I think this is better, but the motivation was to avoid depending on
the internals of DeducedTypeVisitor. This functionality is removed
from the visitor.
Reviewers: kadircet
Subscribers: mgorny, ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70357
this reland the commit 4f80fc2491 which
has been reverted at f805c60a09.
Fixed windows buildbot failure (by adding -fno-delayed-template-parsing flag).
This patch adds the cross references for Macros in the MainFile.
We add references for the main file to the ParsedAST. We query the
references from it using the SymbolID.
Xref outside main file will be added to the index in a separate patch.
Summary: so that clangd C++ API users (via ClangdServer) can access it.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70380
Summary:
Semantically they're the same thing, and it's important when the underlying
struct is anonymous.
There doesn't seem to be a problem attaching the same comment to multiple things
as it already happens with `/** doc */ int a, b;`
This affects an Index test but the results look better (name present, USR points
to the typedef).
Fixes https://github.com/clangd/clangd/issues/189
Reviewers: kadircet, lh123
Subscribers: ilya-biryukov, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70203
Builtins are rarely if ever accessed via the Preprocessor. They are
typically found on the ASTContext, so there should be no performance
penalty to using a pointer indirection to store the builtin context.
Summary:
This is shorter and usually the extra info is noise.
There are cases where the params become type-parameter-0-0 that are hard to fix.
This affects a few features:
- 'name' field in structured hover API (not exposed yet)
- 'name' field in locateSymbolAt (not exposed in LSP)
- 'document/symbol' - the symbol is hierarchically nested in the class
template, or written as foo<t>::foo when defined out-of-line.
Added a test case for hover from https://github.com/clangd/clangd/issues/76.
This patch fixes one field, but no fewer than four others are wrong!
I'll fix them...
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70308
Summary:
For the constructor Foo() : classmember(arg) {}
The AST looks like:
- CXXCtorInitializer classmember(arg)
- CXXConstructExpr classmember(arg)
- DeclRefExpr: arg
We want the 'classmember' to be associated with the CXXCtorInitializer, not the
CXXConstructExpr. (CXXConstructExpr is known to have bad ranges).
So just early-claim it.
Thanks @hokein for tracking down/reducing the bug.
Reviewers: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, hokein
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70312
Summary:
we have a few places using `ASTCtx.getLangOpts().IsHeaderFile` to
determine a header file, but it relies on "-x c-header" compiler flag,
if the compilation command doesn't have this flag, we will get a false
positive. We are encountering this issue in bazel build system.
To solve this problem, we infer the file from file name, actual changes will
come in follow-ups.
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70235
Summary:
This doesn't cover decls in diagnostics, which use NamedDecl::getNameForDiagnostic().
(That should also be fixed later I think).
This covers some cases of https://github.com/clangd/clangd/issues/76
(hover, but not outline or sighelp)
Reviewers: hokein
Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70236
Summary:
The DeclRefExpr for the callee of overloaded `operator()` and `operator[]` are
assigned the range of the paren/bracket lists in the AST.
These are better thought of as implicit (at least `()` - `[] is murkier).
But there's no bit on Expr for implicit, so just ignore them on our side.
While here, deal with the case where an implicit stmt (e.g. implicit-this)
is wrapped in an implicit cast. Previously we ignored the statement but not
the cast, and so the cast ended up being selected.
Fixes https://github.com/clangd/clangd/issues/195
Reviewers: kadircet, lh123
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D70194
Summary:
We use the name from the IdentifierInfo of the Macro to compute its
SymbolID. It is better to just take the Name as a parameter to avoid
storing the IdentifierInfo whenever we need the SymbolID for the Macro.
Patch by UTKARSH SAXENA!
Reviewers: hokein
Reviewed By: hokein
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69937
Summary:
There is a regression from https://reviews.llvm.org/D68467. Unlike class
forward declarations, function ducomentation is written in the declaration in
headers, the function definition doesn't contain any documentation, cases like:
```
foo.h
// this is foo.
void foo();
foo.cc
void foo() {}
```
we should still show documentation from the foo declaration.
Reviewers: ilya-biryukov
Reviewed By: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69961
Summary:
Previously, we match ranges, which is hard to spot the difference.
Now, we diff the code after rename against the expected result, it
produces much nicer output.
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69890
Summary:
This will be used for incoming cross-file rename (to detect index
staleness issue).
Reviewers: ilya-biryukov
Subscribers: MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69615
Summary:
To keep the logic of finding locations of interesting AST nodes in one
place.
The advantage is better coverage of various AST nodes, both now and in
the future: as new nodes get added to `findExplicitReferences`, semantic
highlighting will automatically pick them up.
The drawback of this change is that we have to traverse declarations
inside our file twice in order to highlight dependent names, 'auto'
and 'decltype'. Hopefully, this should not affect the actual latency
too much, most time should be spent in building the AST and not
traversing it.
Reviewers: hokein
Reviewed By: hokein
Subscribers: nridge, merge_guards_bot, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D69673