Aims to fix#127471
Covered the edge case where an int expression is not necessarily
directly wrapped around an 'ImplicitCastExpr' which seemed to be a
requirement in 'use-integer-sign-comparison.cpp' check to trigger.
**For instance**:
```cpp
#include <vector>
bool f() {
std::vector<int> v;
unsigned int i = 0;
return i >= v.size();
}
```
New option AllowNoNamespaceComments for
`google-readability-namespace-comments.AllowNoNamespaceComments` is
added.
When true, the check will allow that no namespace comment is present. If
a namespace comment is added but it is not matching, the check will
fail. Default is `false`
Fixes#124264
Add check for `DeclRefExpr` which points to an explicit object
parameter.
Fixes#141381.
---------
Co-authored-by: fubowen <fubowen@protomail.com>
Co-authored-by: flovent <flbven@protomail.com>
Sometimes a project may want to enable this check only in C++, and
disable it in C, since the patterns the check warns about are quite
common and idiomatic in C, and there are no better alternatives.
Fixes#140659
Co-authored-by: Carlos Gálvez <carlos.galvez@zenseact.com>
This patch refactors CommentKind handling in clang-doc by introducing a
strongly typed enum class for better type safety and clarity. It updates
all relevant places, including YAML traits and serialization, to work
with the new enum. Additionally, it enhances the Mustache-based HTML
generation by fully supporting all comment kinds, ensuring accurate
structured rendering of comment blocks. The changes simplify future
maintenance, improve robustness by eliminating unchecked defaults, and
ensure consistency between generators.
Fixes https://github.com/llvm/llvm-project/issues/142083
Add support for lambda-expression in `use-trailing-return-type` check.
Added two new options:
1. `TransformFunctions` will trigger function declarations to use
trailing return type.
2. `TransformLambdas` will trigger lambda expression to use trailing
return type if it was not stated explicitly.
Fixed false positives when lambda was matched as a function in C++11
mode.
Closes https://github.com/llvm/llvm-project/issues/95711
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
Anchors are automatically generated, but adding another anchor with the
same name hides the anchor that we actually want. Simply removing the
unnecessary self-referential anchor `lifetimebound` fixes the links.
The documentation for coro_disable_lifetimebound and coro_lifetimebound
also had an unnecessary redirection. It's possible to change the link
text to differ from the heading, but I think that's not necessary here.
Also fix a reference in clang-tidy that was using the (unstable)
numbered anchor.
We have multiple different attributes in clang representing device
kernels for specific targets/languages. Refactor them into one attribute
with different spellings to make it more easily scalable for new
languages/targets.
---------
Signed-off-by: Sarnie, Nick <nick.sarnie@intel.com>
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.
namespace-template.mustache only rendered placeholder text. Enum and
record tags were added to the template. Now, we can render an index.html
for the global namespace and other namespaces.
Added tests and deleted some of the disabled unit tests.
This matcher would never match anything, because all record types
as-written would be wrapped in an ElaboratedType.
Just fixing that leads to a matcher which has too many false positives
to be useful.
The warning message itself is not great either, it has a hard-coded type
name.
This patch re-enables -ftime-trace support in clang-doc. Initial support
in #97644 was reverted, and never relanded. This patch adds back the
command line option, and leverages the RAII tracing infrastructure more
thoroughly.
On Windows, we hit the "no such file or directory" case, not the "Not a
directory" one.
MS STL produces the "no such file or directory" message for
`std::error_code(ENOENT, std::generic_category()).message()`, while
libc++ and libstdc++ produce a similar message with a capital N.
Adjust the error message regex to match for either of them.
That said, this kind of test is very brittle with respect to
portability.
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.
This patch refactors the clang-doc tool to replace manual error handling
(e.g., checking error codes and calling exit()) with llvm::ExitOnError.
Fixes#140085
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>
We can only print and use a default arg, if it is instantiated.
I was unable to reduce the test case for this to something of reasonable
size, but this is easily hit by running clang-doc to generate clang's
documentation. For now, we can fix the assertion quickly to unbreak
users, and add the proper test once it is small enough.
The error message:
/usr/bin/ld: CMakeFiles/clang-doc.dir/ClangDocMain.cpp.o: undefined refe
rence to symbol '_Z20getMustacheHtmlFilesN4llvm9StringRefERN5clang3doc15
ClangDocContextE' /usr/bin/ld: /work/kparzysz/git/llvm.org/b/x86/./lib/l
ibclangDocSupport.so.21.0git: error adding symbols: DSO missing from com
mand line
collect2: error: ld returned 1 exit status
make[2]: *** [tools/clang/tools/extra/clang-doc/tool/CMakeFiles/clang-do
c.dir/build.make:107: bin/clang-doc] Error 1
Originally part of #133161. This patch adds preliminary tracking
for of TypeInfo, by tracking if the type is a builtin or template.
The new functionality is not yet exercised.
Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
This patch adds a command line option and enables the Mustache template
HTML backend. This allows users to use the new, more flexible templates
over the old and cumbersome HTML output. Split from #133161.
Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
This patch updates Serialize.cpp to serialize more data about C++
templates, which are supported by the new mustache HTML template.
Split from #133161.
Co-authored-by: Peter Chou <peter.chou@mail.utoronto.ca>
Currently we generate an incorrect suggestion for shared/unique pointers
to arrays; for instance ([Godbolt](https://godbolt.org/z/Tens1reGP)):
```c++
#include <memory>
void test_shared_ptr_to_array() {
std::shared_ptr<int[]> i;
auto s = sizeof(*i.get());
}
```
```
<source>:5:20: warning: redundant get() call on smart pointer [readability-redundant-smartptr-get]
5 | auto s = sizeof(*i.get());
| ^~~~~~~
| i
1 warning generated.
```
`sizeof(*i)` is incorrect, though, because the array specialization of
`std::shared/unique_ptr` does not have an `operator*()`. Therefore I
have disabled this check for smart pointers to arrays for now; future
work could, of course, improve on this by suggesting, say,
`sizeof(i[0])` in the above example.
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.
Fix false positives in `bugprone-crtp-constructor-accessibility` check
on deleted constructors that cannot be used to construct objects, even
if they have public or protected access.
Closes https://github.com/llvm/llvm-project/issues/131737.
These are identified by misc-include-cleaner. I've filtered out those
that break builds. Also, I'm staying away from llvm-config.h,
config.h, and Compiler.h, which likely cause platform- or
compiler-specific build failures.
This aims to address a portion of #122480 by adding matchers on binary
operators. **This allows the detection of explicit arithmetic operations
within initializers.**
- Deleted unused includes
- Deleted useless braces
- Converted private methods to static function to improve compilations
speed and readability
- Modernized tests to use `cxx-or-later`