Summary:
Fix assertion failure: "Name is not a simple identifier".
`Decl::GetName` assumes the name should be an identifier. When the check
processes the function calling statement with speciail key name like
'it.operator->()', it will trigger the assert in `GetName`.
Rather than using `Decl::GetName`, we use `getNameAsString` which works
with special key names in C++.
Reviewers: bkramer
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D18141
llvm-svn: 263426
Summary:
Move code shared between UnnecessaryCopyInitialization and ForRangeCopyCheck into utilities files.
Add more test cases for UnnecessaryCopyInitialization and disable fixes inside of macros.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D17488
llvm-svn: 262781
This doesn't really do much at the moment. You can load it via libclang
and set the -checks via an extra command line argument as illustrated in
the test case. Support for other options (including headers check) is
currently missing. Also when using this with libclang some checks may
not work with the precompiled preamble in place.
This can be used to easily show clang-tidy warnings in an editor
integration as all that's needed is adding command line flags that are
passed into libclang. Warnings and FixIts are exposed via the existing
CXDiagnostic machinery.
Differential Revision: http://reviews.llvm.org/D17807
llvm-svn: 262595
It was failing to build with:
clang-tidy\readability\IdentifierNamingCheck.cpp(640):
error C2882: 'format' : illegal use of namespace identifier in expression
llvm-svn: 262257
Summary:
The clang-tidy will trigger an assertion if it's not in the building directory.
TEST:
cd <llvm-repo>/
./build/bin/clang-tidy --checks=-*,modernize-use-nullptr -p build tools/clang/tools/extra/clang-tidy/ClangTidy.cpp
The crash issue is gone after applying this patch.
Fixes PR24834, PR26241
Reviewers: bkramer, alexfh
Subscribers: rizsotto.mailinglist, cfe-commits
Differential Revision: http://reviews.llvm.org/D17335
llvm-svn: 261991
Summary: Because of the recent Google Code shutdown links to the Google Code Style up there are no longer relevant.
Reviewers: alexfh, hokein
Subscribers: cfe-commits
Patch by Kirill Bobyrev!
Differential Revision: http://reviews.llvm.org/D17602
llvm-svn: 261868
For now, it just detects that host is non-Windows and target is msvc.
FIXME: It should be probable for cross compilations. Detect whether target's headers would be available.
llvm-svn: 261814
Summary:
This patch introduces the modernize-deprecated-headers check, which is supposed to replace deprecated C library headers with the C++ STL-ones.
For information see documentation; for exmaples see the test cases.
Reviewers: Eugene.Zelenko, LegalizeAdulthood, alexfh
Subscribers: cfe-commits
Patch by Kirill Bobyrev!
Differential Revision: http://reviews.llvm.org/D17484
llvm-svn: 261738
Adds a new check "misc-forward-declaration-namespace".
In check, A forward declaration is considerred in a potentially wrong namespace
if there is any definition/declaration with the same name exists in a different
namespace.
Reviewers: akuegel, hokein, alexfh
Patch by Eric Liu!
Differential Revision: http://reviews.llvm.org/D17195
llvm-svn: 261737
instead of a get() method we find in the class.
The duck typed smart pointer class could have overloaded get() methods
and we should only skip the one that matches.
llvm-svn: 261102
Summary:
The test code will trigger following an assert failure:
assert.h assertion failed at LoopConvertUtils.cpp:560 in
bool clang::tidy::modernize::ForLoopIndexUseVisitor::TraverseMemberExpr(clang::MemberExpr*): ExprType->isPointerType() && "Operator-> returned non-pointer type"
Reviewers: alexfh
Differential Revision: http://reviews.llvm.org/D17287
llvm-svn: 260953
Summary:
This patch is a continuation of http://reviews.llvm.org/D10553 by Jonathan B Coe.
The main additions are:
1. For C++11 the check suggests in-class field initialization as fix. This
makes the fields future proof towards the addition of new constructors.
2 For older language versions the fields are added in the right position
in the initializer list with more tests.
3. User documentation.
Reviewers: alexfh, jbcoe
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16517
llvm-svn: 260873
Summary:
Fix oversight not checking the value of the Optional<bool> returned by
isExpensiveToCopy().
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D17064
llvm-svn: 260870
Summary:
Add check performance-faster-string-find.
It replaces single character string literals to character literals in calls to string::find and friends.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D16152
llvm-svn: 260712
Expand the simplify boolean expression check to handle implicit conversion of integral types to bool and improve the handling of implicit conversion of member pointers to bool.
Implicit conversion of member pointers are replaced with explicit comparisons to nullptr.
Implicit conversions of integral types are replaced with explicit comparisons to 0.
Patch by Richard Thomson.
llvm-svn: 260681
I added portability warnings when int results are casted to long. I forgot to handle uint, ulong and ulonglong.
Tested on x86 and powerpc targets, hope it works now on all buildbots.
llvm-svn: 260667
Summary:
The check will trigger a assert failure("CondEndLoc.isValid") when
checking the IfStmt whose condition expression is not parsed.
In this case, we should ignore that.
Reviewers: alexfh
Subscribers: cfe-commits
Differential Revision: http://reviews.llvm.org/D17069
llvm-svn: 260505