This reverts commit 0788acbccb.
This reverts commit c2d7a1f79cedfc9fcb518596aa839da4de0adb69: Revert "[clangd] Add test for FindTarget+RecoveryExpr (which already works). NFC"
It causes a crash on invalid code:
class X {
decltype(unresolved()) foo;
};
constexpr int s = sizeof(X);
Summary:
The previous behavior was aggressive,
#include "abc/f^/abc.h"
foo/ -> candidate
"f/abc.h" is replaced with "foo/", this patch will preserve the "abc.h".
Reviewers: sammccall
Subscribers: jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76770
Summary:
Now Preferred is always the canonical (first) decl, Definition is always the def
if available.
In practice the index was already forcing this behaviour anyway, so there's no
change. (Unless you weren't using this index, in which case this patch makes
textDocument/declaration and toggling work as expected).
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D73369
Summary: Previously, we dropped the AST node for nonexistent member exprs.
Reviewers: sammccall
Subscribers: cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76764
Summary:
One change: because there's no way to signal failure individually for
each cursor, we now "succeed" with an empty range with no parent if a
cursor doesn't point at anything.
Reviewers: usaxena95
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76741
Summary:
clang-apply-replacements currently deduplicates all diagnostic replacements. However if you get a duplicated replacement from one TU then its expected that it should not be deduplicated. This goes some way to solving [[ https://bugs.llvm.org/show_bug.cgi?id=45150 | export-fixes to yaml adds extra newlines and breaks offsets. ]]
Take this example yaml.
```
---
MainSourceFile: '/home/nathan/test/test.cpp'
Diagnostics:
- DiagnosticName: readability-braces-around-statements
DiagnosticMessage:
Message: statement should be inside braces
FilePath: '/home/nathan/test/test.cpp'
FileOffset: 14
Replacements:
- FilePath: '/home/nathan/test/test.cpp'
Offset: 14
Length: 0
ReplacementText: ' {'
- FilePath: '/home/nathan/test/test.cpp'
Offset: 28
Length: 0
ReplacementText: '
}'
- DiagnosticName: readability-braces-around-statements
DiagnosticMessage:
Message: statement should be inside braces
FilePath: '/home/nathan/test/test.cpp'
FileOffset: 20
Replacements:
- FilePath: '/home/nathan/test/test.cpp'
Offset: 20
Length: 0
ReplacementText: ' {'
- FilePath: '/home/nathan/test/test.cpp'
Offset: 28
Length: 0
ReplacementText: '
}'
...```
The current behaviour is to deduplicate the text insertions at Offset 28 and only apply one of the replacements.
However as both of these replacements came from the same translation unit we can be confident they were both meant to be applied together
The new behaviour won't deduplicate the text insertion and instead insert both of the replacements.
If the duplicate replacement is found inside different translation units (from a header file change perhaps) then they will still be deduplicated as before.
Reviewers: aaron.ballman, gribozavr2, klimek, ymandel
Reviewed By: ymandel
Subscribers: ymandel, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76054
`parseDocumentation` retains hard line breaks and removes soft line
breaks inside documentation comments.
Wether a line break is hard or soft is determined by the following rules
(some of which have been discussed in
https://github.com/clangd/clangd/issues/95):
Line breaks that are preceded by a punctuation are retained
Line breaks that are followed by "interesting characters" (e.g. Markdown
syntax, doxygen commands) are retained
All other line breaks are removed
Related issue: https://github.com/clangd/clangd/issues/95
Differential Revision: https://reviews.llvm.org/D76094
Summary:
The ClangdVFSTest.TestStackOverflow unittest does not seem to work
when building the test with address sanitizer activated. Afaict the
goal is to get a constexpr depth error, rather than stack overflow.
But with asan instrumentation we do get stack overflow complaints
from asan. As a workaround this patch simply disables the test case,
when being built with address sanitizer activated.
Reviewers: sammccall, Dmitry.Kozhevnikov
Reviewed By: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits, llvm-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76533
Summary:
Made llvmlibc::RestrictSystemLibcHeadersCheck a subclass of protability::RestrictSystemIncludesCheck to re-use common code between the two.
This also adds the ability to white list linux development headers.
Reviewers: aaron.ballman
Reviewed By: aaron.ballman
Subscribers: mgorny, xazax.hun, MaskRay, cfe-commits, sivachandra
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D76395
Summary:
Bugzilla: https://bugs.llvm.org/show_bug.cgi?id=27702
I wasn't sure how this type of thing is usually tested. So any advice would be appreciated.
`check-llvm`, `check-clang` and `check-clang-tools` are clean for me.
**C++98**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
"directory": "/home/tetsuo/dev/llvm-project/test",
"command": "/usr/bin/c++ -std=gnu++98 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
"file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
3053 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&' or 'Foo' [misc-unconventional-assign-operator]
Foo &operator=(Foo &Other) {
^
Suppressed 3052 warnings (3052 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
**C++17**
```
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ cat compile_commands.json
[
{
"directory": "/home/tetsuo/dev/llvm-project/test",
"command": "/usr/bin/c++ -std=gnu++17 -o CMakeFiles/test.dir/test.cpp.o -c /home/tetsuo/dev/llvm-project/test/test.cpp",
"file": "/home/tetsuo/dev/llvm-project/test/test.cpp"
}
]
tetsuo@garland-c-16-sgp1-01:~/dev/llvm-project/test$ ../build/bin/clang-tidy --checks=misc-unconventional-assign-operator test.cpp
5377 warnings generated.
/home/tetsuo/dev/llvm-project/test/test.cpp:7:3: warning: operator=() should take 'Foo const&', 'Foo&&' or 'Foo' [misc-unconventional-assign-operator]
Foo &operator=(Foo &Other) {
^
Suppressed 5376 warnings (5376 in non-user code).
Use -header-filter=.* to display errors from all non-system headers. Use -system-headers to display errors from system headers as well.
```
Reviewers: njames93, MaskRay, alexfh, hokein, aaron.ballman
Reviewed By: njames93
Subscribers: xazax.hun, cfe-commits
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D75901
Summary:
Conservatively escaping everything is bad in coc.nvim which shows the markdown
to the user, and we have reports of it causing problems for other parsers.
Fixes https://github.com/clangd/clangd/issues/301
Reviewers: kadircet
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75687
Summary:
Previously, the range for "->" CXXOperatorCallExpr is the range of the
class object (not including the operator!), e.g. "[[vector_ptr]]->size()".
This patch includes the range of the operator, which fixes the issue
where clangd doesn't go to the overloaded operator "->" definition.
Reviewers: sammccall
Reviewed By: sammccall
Subscribers: ilya-biryukov, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D76128
Summary:
Cover a new use case when using a 'signed char' as an integer
might lead to issue with non-ASCII characters. Comparing
a 'signed char' with an 'unsigned char' using equality / unequality
operator produces an unexpected result for non-ASCII characters.
Reviewers: aaron.ballman, alexfh, hokein, njames93
Reviewed By: njames93
Subscribers: xazax.hun, cfe-commits
Tags: #clang, #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D75749
Summary:
This facilitates performing go-to-definition in contexts where AST-based
resolution does not work, such as comments, string literals, preprocessor
disabled regions, and macro definitions, based on textual lookup in the index.
Partially fixes https://github.com/clangd/clangd/issues/241
Reviewers: sammccall
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D72874
Summary: This adds a new module to enforce standards specific to the llvm-libc project. This change also adds the first check which restricts user from including system libc headers accidentally which can lead to subtle bugs that would be a challenge to detect.
Reviewers: alexfh, hokein, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: juliehockett, arphaman, jfb, abrachet, sivachandra, Eugene.Zelenko, njames93, mgorny, xazax.hun, MaskRay, cfe-commits
Tags: #clang-tools-extra, #libc-project, #clang
Differential Revision: https://reviews.llvm.org/D75332
Most clients of SourceManager.h need to do things like turning source
locations into file & line number pairs, but this doesn't require
bringing in FileManager.h and LLVM's FS headers.
The main code change here is to sink SM::createFileID into the cpp file.
I reason that this is not performance critical because it doesn't happen
on the diagnostic path, it happens along the paths of macro expansion
(could be hot) and new includes (less hot).
Saves some includes:
309 - /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileManager.h
272 - /usr/local/google/home/rnk/llvm-project/clang/include/clang/Basic/FileSystemOptions.h
271 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/VirtualFileSystem.h
267 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/FileSystem.h
266 - /usr/local/google/home/rnk/llvm-project/llvm/include/llvm/Support/Chrono.h
Differential Revision: https://reviews.llvm.org/D75406
Summary: Didn't realize that headers such as stddef.h may not exist on all systems. This patch mocks the headers so that the check's tests work on all systems. (:
Reviewers: RKSimon, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: xazax.hun, cfe-commits
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D76015
Summary:
These functions only use the FormatStyle to obtain a LangOptions via
format::getFormattingLangOpts(), and some callers can more easily obtain
a LangOptions more directly.
Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, kadircet, usaxena95, cfe-commits
Tags: #clang
Differential Revision: https://reviews.llvm.org/D75716
Summary:
Created a general check for restrict-system-includes under portability as recommend in the comments under D75332. I also fleshed out the user facing documentation to show examples for common use-cases such as allow-list, block-list, and wild carding.
Removed fuchsia's check as per phosek sugguestion.
Reviewers: aaron.ballman, phosek, alexfh, hokein, njames93
Reviewed By: phosek
Subscribers: Eugene.Zelenko, mgorny, xazax.hun, phosek, cfe-commits, MaskRay
Tags: #clang-tools-extra, #clang
Differential Revision: https://reviews.llvm.org/D75786