Age | Commit message (Collapse) | Author |
|
Reviewers: JonasToth, aaron.ballman
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D56552
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@351048 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Finds potentially redundant preprocessor directives.
Reviewed By: aaron.ballman
Differential Revision: https://reviews.llvm.org/D54349
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@350922 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
And also enable it by default to be consistent with e.g.
modernize-use-using.
This helps e.g. when running this check on client code where the macro
is provided by the system, so there is no easy way to modify it.
Reviewed By: JonasToth, lebedev.ri
Differential Revision: https://reviews.llvm.org/D56025
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@350056 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@349891 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@349758 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@348583 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
readability-implicit-bool-conversion
Summary: There is no ambiguity / information loss in this conversion
Reviewers: alexfh, aaron.ballman, hokein
Reviewed By: alexfh
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D54941
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347671 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
When a warning is issued in a template instantiation, the check would previously
use template arguments in a note, which would result in inconsistent or
duplicate warnings (depending on how deduplication was done). This patch removes
template arguments from the note.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347652 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Removed the uses of the allOf() matcher inside node matchers that are implicit
allOf(). Replaced uses of allOf() with the explicit node matcher where it makes
matchers more readable. Replace anyOf(hasName(), hasName(), ...) with the more
efficient and readable hasAnyName().
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@347520 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
in r346847
Summary: (See D54204 for original review)
Reviewers: hokein
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D54579
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@346961 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This check flags function top-level const-qualified return types and suggests removing the mostly-superfluous const qualifier where possible.
Patch by Yitzhak Mandelbaum.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345764 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This patch introduces a new clang-tidy check that matches on all `declStmt` that declare more then one variable
and transform them into one statement per declaration if possible.
It currently only focusses on variable declarations but should be extended to cover more kinds of declarations in the future.
It is related to https://reviews.llvm.org/D27621 and does use it's extensive test-suite. Thank you to firolino for his work!
Reviewers: rsmith, aaron.ballman, alexfh, hokein, kbobyrev
Reviewed By: aaron.ballman
Subscribers: ZaMaZaN4iK, mgehre, nemanjai, kbarton, lebedev.ri, Eugene.Zelenko, mgorny, xazax.hun, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D51949
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345735 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
(CERT DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)
Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.
All valid combinations of suffixes are supported.
```
auto x = 1; // OK, no suffix.
auto x = 1u; // warning: integer literal suffix 'u' is not upper-case
auto x = 1U; // OK, suffix is uppercase.
...
```
This is a re-commit, the original was reverted by me in
rL345305 due to discovered bugs. (implicit code, template instantiation)
Tests were added, and the bugs were fixed.
I'm unable to find any further bugs, hopefully there aren't any..
References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun
Reviewed By: aaron.ballman
Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D52670
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345381 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
There are some lurking issues with the handling of the SourceManager.
Somehow sometimes we end up extracting completely wrong
portions of the source buffer.
Reverts r344772, r44760, r344758, r344755.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@345305 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
And also enable it by default to be consistent with e.g. modernize-use-using.
This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.
Reviewed By: JonasToth
Differential Revision: https://reviews.llvm.org/D53454
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344871 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
constexpr if.
Summary:
It fixes the false positive when using constexpr if and where else cannot be removed:
Example:
```
if constexpr (sizeof(int) > 4)
// ...
return /* ... */;
else // This else cannot be removed.
// ...
return /* ... */;
```
Reviewers: alexfh, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: lebedev.ri, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D53372
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344785 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
DCL16-C, MISRA C:2012, 7.3, MISRA C++:2008, 2-13-4)
Summary:
Detects when the integral literal or floating point (decimal or hexadecimal)
literal has non-uppercase suffix, and suggests to make the suffix uppercase,
with fix-it.
All valid combinations of suffixes are supported.
```
auto x = 1; // OK, no suffix.
auto x = 1u; // warning: integer literal suffix 'u' is not upper-case
auto x = 1U; // OK, suffix is uppercase.
...
```
References:
* [[ https://wiki.sei.cmu.edu/confluence/pages/viewpage.action?pageId=87152241 | CERT DCL16-C ]]
* MISRA C:2012, 7.3 - The lowercase character "l" shall not be used in a literal suffix
* MISRA C++:2008, 2-13-4 - Literal suffixes shall be upper case
Reviewers: JonasToth, aaron.ballman, alexfh, hokein, xazax.hun
Reviewed By: aaron.ballman
Subscribers: Eugene.Zelenko, mgorny, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D52670
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@344755 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
check.
Summary:
Option to check for different naming conventions on the following types:
- GlobalConstantPointer
- GlobalPointer
- LocalConstantPointer
- LocalPointer
- PointerParameter
- ConstantPointerParameter
When not specified, the conventions for the non pointer types will be applied (GlobalConstant, GlobalVariable, LocalConstant, ...).
Patch by ffigueras!
Reviewers: alexfh, kbobyrev
Reviewed By: alexfh
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D52882
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343788 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
readability-implicit-bool-conversion
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343578 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The convenience wrapper in STLExtras is available since rL342102.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@343166 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
in source code headers.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342601 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
findStyleKind is only called if D is an explicit identifier with a name,
so the checks for operators will never return true. The explicit assert()
enforces this invariant.
Differential Revision: https://reviews.llvm.org/D52179
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@342514 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
(both floating-point and integral).
Patch by Florin Iucha <florin@signbit.net>
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339516 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Subscribers: nemanjai, ioeric, kbarton, cfe-commits
Differential Revision: https://reviews.llvm.org/D50355
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339401 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Reviewers: javed.absar
Subscribers: nemanjai, kbarton, ilya-biryukov, ioeric, jkorous, arphaman, jfb, cfe-commits
Differential Revision: https://reviews.llvm.org/D50354
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@339400 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
approximate name matches.
Summary:
The goal is to reduce false positives when the difference is intentional, like:
foo(StringRef name);
foo(StringRef name_ref) {
string name = cleanup(name_ref);
...
}
Or semantically unimportant, like:
foo(StringRef full_name);
foo(StringRef name) { ... }
There are other matching names we won't recognise (e.g. syns vs synonyms) but
this catches many that we see in practice, and gives people a systematic
workaround.
The old behavior is available as a 'Strict' option.
Subscribers: xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D49285
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@336992 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
of ExprWithCleanups type
bool foo(A &S) {
if (S != (A)S)
return false;
return true;
}
is fixed into (w/o this patch)
...
return !S != (A)S; // negotiation affects first operand only
}
instead of (with this patch)
...
return S == (A)S; // note == instead of !=
}
Differential Revision: https://reviews.llvm.org/D47122
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@333003 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
subscript expressions that can be simplified.
Currently, diagnoses code that calls container.data()[some_index] when the container exposes a suitable operator[]() method that can be used directly.
Patch by Shuai Wang.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@332519 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
The DEBUG() macro is very generic so it might clash with other projects.
The renaming was done as follows:
- git grep -l 'DEBUG' | xargs sed -i 's/\bDEBUG\s\?(/LLVM_DEBUG(/g'
- git diff -U0 master | ../clang/tools/clang-format/clang-format-diff.py -i -p1 -style LLVM
Differential Revision: https://reviews.llvm.org/D44976
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@332371 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary: using ivar in class extension is not supported in 32-bit architecture of MacOS.
Reviewers: alexfh, hokein
Reviewed By: alexfh
Subscribers: klimek, cfe-commits
Differential Revision: https://reviews.llvm.org/D45912
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@330559 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
not have prefix '_'
This commit has been breaking most bots for a day now. There is a fix
proposed in https://reviews.llvm.org/D45912 but when I applied that
I just got different errors. Reverting to get our bots back to green.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@330528 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
For code of ivar declaration:
int barWithoutPrefix;
The fix will be:
int _barWithoutPrefix;
Reviewers: benhamilton, hokein, alexfh, aaron.ballman, ilya-biryukov
Reviewed By: alexfh
Subscribers: Eugene.Zelenko, xazax.hun, klimek, mgorny, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D45392
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@330492 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Pretty straight-forward, just count all the variable declarations in the function's body, and if more than the configured threshold - do complain.
Note that this continues perverse practice of disabling the new option by default.
I'm not certain where is the balance point between not being too noisy, and actually enforcing the good practice.
If we really want to not disable this by default, but also to not cause too many new warnings, we could default to 50 or so.
But that is a lot of variables too...
I was able to find one coding style referencing variable count:
- https://www.kernel.org/doc/html/v4.15/process/coding-style.html#functions
> Another measure of the function is the number of local variables. They shouldn’t exceed 5-10, or you’re doing something wrong.
Reviewers: hokein, xazax.hun, JonasToth, aaron.ballman, alexfh
Reviewed By: aaron.ballman
Subscribers: kimgr, Eugene.Zelenko, rnkovacs, cfe-commits
Tags: #clang-tools-extra
Differential Revision: https://reviews.llvm.org/D44602
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@329902 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
to portability-simd-intrinsics
Reviewers: alexfh
Subscribers: klimek, nemanjai, mgorny, xazax.hun, kbarton, cfe-commits
Differential Revision: https://reviews.llvm.org/D44173
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@326909 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
Many architectures provide SIMD operations (e.g. x86 SSE/AVX, Power AltiVec/VSX,
ARM NEON). It is common that SIMD code implementing the same algorithm, is
written in multiple target-dispatching pieces to optimize for different
architectures or micro-architectures.
The C++ standard proposal P0214 and its extensions cover many common SIMD
operations. By migrating from target-dependent intrinsics to P0214 operations,
the SIMD code can be simplified and pieces for different targets can be unified.
Refer to http://wg21.link/p0214 for introduction and motivation for the
data-parallel standard library.
Subscribers: klimek, aemerson, mgorny, xazax.hun, kristof.beyls, hintonda, cfe-commits
Differential Revision: https://reviews.llvm.org/D42983
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@325272 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@323766 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
implicit converions to bool in more contexts.
Summary: Expand readability-redundant-smartptr-get to understand implicit converions to bool in more contexts.
Reviewers: hokein
Subscribers: klimek, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D41998
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@322497 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
nested namespaces
Summary:
Fixes bug 34701
When we encounter a namespace find the location of the left bracket.
Then if the text between the name and the left bracket contains a ':'
then it's a C++17 nested namespace.
Reviewers: #clang-tools-extra, alexfh, aaron.ballman
Reviewed By: aaron.ballman
Subscribers: curdeius, cfe-commits, krasimir, JonasToth, JDevlieghere, xazax.hun
Tags: #clang-tools-extra
Patch by Alexandru Octavian Buțiu!
Differential Revision: https://reviews.llvm.org/D38284
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@322274 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
readability-inconsistent-declaration-parameter-name
And also enable it by default to be consistent with e.g. modernize-use-using.
This helps e.g. when running this check on client code where the macro is
provided by the system, so there is no easy way to modify it.
Reviewers: alexfh, piotrdz, hokein, ilya-biryukov
Reviewed By: alexfh
Differential Revision: https://reviews.llvm.org/D41716
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@321913 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
constants when checking identifiers naming
Summary:
They are not locally const qualified so they weren't classified as
constants by the readability-identifier-naming check.
Reviewers: alexfh
Reviewed By: alexfh
Subscribers: klimek, cfe-commits, xazax.hun
Patch by Beren Minor!
Differential Revision: https://reviews.llvm.org/D39363
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@320406 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319325 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
The readability-else-after-return check was not warning about
an else after a throw of an exception that had arguments that needed
to be cleaned up.
Reviewers: aaron.ballman, alexfh, djasper
Reviewed By: aaron.ballman
Subscribers: lebedev.ri, klimek, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D40505
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319174 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
declarations
Fixes http://llvm.org/PR34410.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@319021 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This reverts r315057. The revision introduces assertion failures:
assertion failed at llvm/tools/clang/include/clang/Basic/SourceManager.h:428 in
const clang::SrcMgr::ExpansionInfo &clang::SrcMgr::SLocEntry::getExpansion()
const: isExpansion() && "Not a macro expansion SLocEntry!"
Stack trace:
__assert_fail
clang::SrcMgr::SLocEntry::getExpansion()
clang::SourceManager::getExpansionLocSlowCase()
clang::SourceManager::getExpansionLoc()
clang::Lexer::getRawToken()
clang::tidy::readability::NamespaceCommentCheck::check()
clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::MatchVisitor::visitMatch()
clang::ast_matchers::internal::BoundNodesTreeBuilder::visitMatches()
clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchWithFilter()
clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::matchDispatch()
clang::ast_matchers::internal::(anonymous namespace)::MatchASTVisitor::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::RecursiveASTVisitor<>::TraverseDeclContextHelper()
clang::RecursiveASTVisitor<>::TraverseDecl()
clang::ast_matchers::MatchFinder::matchAST()
clang::MultiplexConsumer::HandleTranslationUnit()
clang::ParseAST()
clang::FrontendAction::Execute()
clang::CompilerInstance::ExecuteAction()
clang::tooling::FrontendActionFactory::runInvocation()
clang::tooling::ToolInvocation::runInvocation()
clang::tooling::ToolInvocation::run()
Still working on an isolated test case.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@315580 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Fixes PR34701.
Patch by Alexandru Octavian Buțiu.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@315057 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
This check is relatively simple, and is often being used
as an example. I'm aware of at least two cases, when
simply copying the FunctionASTVisitor class to a new
check resulted in a rather unobvious segfault. Having it
in anonymous namespace prevents such a problem.
No functionality change, so i opted to avoid phabricator,
especially since clang-tidy reviews are seriously jammed.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@312912 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Patch by: Lilla Barancsuk
Differential Revision: https://reviews.llvm.org/D35937
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@310371 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Summary:
This patch renames checks, check options and changes messages to use correct
term "implicit conversion" instead of "implicit cast" (which has been in use in
Clang AST since ~10 years, but it's still technically incorrect w.r.t. C++
standard).
* performance-implicit-cast-in-loop -> performance-implicit-conversion-in-loop
* readability-implicit-bool-cast -> readability-implicit-bool-conversion
- readability-implicit-bool-cast.AllowConditionalIntegerCasts ->
readability-implicit-bool-conversion.AllowIntegerConditions
- readability-implicit-bool-cast.AllowConditionalPointerCasts ->
readability-implicit-bool-conversion.AllowPointerConditions
Reviewers: hokein, jdennett
Reviewed By: hokein
Subscribers: mgorny, JDevlieghere, xazax.hun, cfe-commits
Differential Revision: https://reviews.llvm.org/D36456
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@310366 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Differential Revision: https://reviews.llvm.org/D36154
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@309810 91177308-0d34-0410-b5e6-96231b3b80d8
|
|
Use getAnyMember() instead of getMember() to avoid crash on anonymous
structs/unions.
Don't warn about initializing members of an anonymous union.
Fixes PR32966.
Reviewed by alexfh.
git-svn-id: https://llvm.org/svn/llvm-project/clang-tools-extra/trunk@309668 91177308-0d34-0410-b5e6-96231b3b80d8
|