summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/test/clang-tidy
Commit message (Collapse)AuthorAgeFilesLines
* [clang-tidy] Extend UnnecessaryCopyInitialization check to trigger on ↵Felix Berger2016-03-051-3/+72
| | | | | | | | | | | | | | | | non-const copies that can be safely converted to const references. 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
* [clang-tidy] Make 'modernize-use-nullptr' check work on multiple nested ↵Haojian Wu2016-03-041-0/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | implicit cast expressions. Summary: For some test cases like: ``` int func(int, void*, void*); (double)func(0, 0, 0); ``` The AST contains several `ImplicitCastExpr`s, so we should not only check on the first sub expression. ``` `-CStyleCastExpr 0x7fe43a088938 <line:6:3, col:24> 'double' <NoOp> `-ImplicitCastExpr 0x7fe43a088920 <col:11, col:24> 'double' <IntegralToFloating> `-CallExpr 0x7fe43a0888a0 <col:11, col:24> 'int' |-ImplicitCastExpr 0x7fe43a088888 <col:11> 'int (*)(int, void *, void *)' <FunctionToPointerDecay> | `-DeclRefExpr 0x7fe43a0887d8 <col:11> 'int (int, void *, void *)' lvalue Function 0x7fe43a0886f0 'func1' 'int (int, void *, void *)' |-IntegerLiteral 0x7fe43a088800 <col:17> 'int' 0 |-ImplicitCastExpr 0x7fe43a0888e0 <col:20> 'void *' <NullToPointer> | `-IntegerLiteral 0x7fe43a088820 <col:20> 'int' 0 `-ImplicitCastExpr 0x7fe43a0888f8 <col:23> 'void *' <NullToPointer> `-IntegerLiteral 0x7fe43a088840 <col:23> 'int' 0 ``` Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17849 llvm-svn: 262698
* [clang-tidy] Improve the robustness of a test.Gabor Horvath2016-03-031-3/+2
| | | | llvm-svn: 262618
* [clang-tidy] Do not emit warnings from misc-suspicious-semicolon when the ↵Gabor Horvath2016-03-031-0/+13
| | | | | | compilation fails. llvm-svn: 262615
* [clang-tidy] Add "clang-tidy as a clang plugin" skeleton.Benjamin Kramer2016-03-031-0/+1
| | | | | | | | | | | | | | | | | 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
* [clang-tidy] Fix an assertion failure of "SLocEntry::getExpansion()" when ↵Haojian Wu2016-03-021-0/+16
| | | | | | | | | | | | | | IncludeInserter handles macro header file. Summary: Also Fixes PR24749. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17805 llvm-svn: 262484
* [clang-tidy] Make 'modernize-pass-by-value' fix work on header files.Haojian Wu2016-03-022-0/+15
| | | | | | | | | | Reviewers: alexfh Subscribers: jbcoe, cfe-commits Differential Revision: http://reviews.llvm.org/D17756 llvm-svn: 262470
* [clang-tidy] Fix an assertion failure in `modernize-use-nullptr` check.Haojian Wu2016-02-261-0/+12
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17640 llvm-svn: 262024
* [clang-tidy] Fix a crash issue when clang-tidy runs with compilation database.Haojian Wu2016-02-262-0/+56
| | | | | | | | | | | | | | | | | | | | | 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
* Add a new check, readability-redundant-string-init, that checks unnecessary ↵Alexander Kornienko2016-02-251-0/+86
| | | | | | | | | | | | | | string initializations. Reviewers: hokein, alexfh Subscribers: cfe-commits Patch by Shuai Wang! Differential Revision: http://reviews.llvm.org/D17586 llvm-svn: 261939
* Revert r261814, "check-clang-tools: Introduce the feature target-headers", ↵NAKAMURA Takumi2016-02-252-2/+0
| | | | | | corresponding to r261893. llvm-svn: 261897
* [clang-tidy] Adding headers needed in modernize-deprecated-headers testsAlexander Kornienko2016-02-2528-2/+2
| | | | llvm-svn: 261893
* check-clang-tools: Introduce the feature "target-headers".NAKAMURA Takumi2016-02-252-0/+2
| | | | | | | 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
* [clang-tidy] introduce modernize-deprecated-headers checkAlexander Kornienko2016-02-242-0/+310
| | | | | | | | | | | | | | | | | 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
* [clang-tidy] Added a check for forward declaration in the potentially wrong ↵Alexander Kornienko2016-02-241-0/+163
| | | | | | | | | | | | | | | | | namespace 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
* Add a new check, cert-env33-c, that diagnoses uses of system(), popen(), and ↵Aaron Ballman2016-02-221-0/+20
| | | | | | _popen() to execute a command processor. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/pages/viewpage.action?pageId=2130132 llvm-svn: 261530
* Add a new check, cert-flp30-c, that diagnoses loop induction expressions of ↵Aaron Ballman2016-02-191-0/+19
| | | | | | floating-point type. This check corresponds to the CERT secure coding rule: https://www.securecoding.cert.org/confluence/display/c/FLP30-C.+Do+not+use+floating-point+variables+as+loop+counters llvm-svn: 261324
* [clang-tidy] Match the type against the get() method we are calling,Samuel Benzaquen2016-02-171-0/+15
| | | | | | | | | 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
* [clang-tidy] Fix an assert failure in `modernize-loop-convert`.Haojian Wu2016-02-161-0/+18
| | | | | | | | | | | | | | 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
* [clang-tidy] Fix an assert failure of ForStmt in ↵Haojian Wu2016-02-161-2/+7
| | | | | | | | | | | | `readability-braces-around-statements` check. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17134 llvm-svn: 260952
* [clang-tidy] ClangTidy check to flag uninitialized builtin and pointer fields.Felix Berger2016-02-152-0/+178
| | | | | | | | | | | | | | | | | | | | | 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
* [clang-tidy] Only invoke ForRangeCopyCheck on expensive-to-copy types.Felix Berger2016-02-151-0/+25
| | | | | | | | | | | | | | 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
* [clang-tidy] Add check performance-faster-string-findSamuel Benzaquen2016-02-121-0/+110
| | | | | | | | | | | | | | 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
* Reapply r260096.Aaron Ballman2016-02-121-5/+40
| | | | | | | | | | | | 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
* [clang-tidy] improve misc-misplaced-widening-cast so it also detects ↵Daniel Marjamaki2016-02-121-1/+1
| | | | | | | | | | | | portability problems. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D17140 llvm-svn: 260665
* [clang-tidy] google-runtime-int: fix a false positive in implicit code.Alexander Kornienko2016-02-111-0/+7
| | | | llvm-svn: 260535
* Merge branch 'arcpatch-D16922'Cong Liu2016-02-111-0/+44
| | | | llvm-svn: 260532
* [clang-tidy] Fix an assert failure in 'readability-braces-around-statements' ↵Haojian Wu2016-02-111-0/+7
| | | | | | | | | | | | | | | | | | check. 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
* [clang-tidy] Add a check to find unintended semicolons that changes the ↵Gabor Horvath2016-02-111-0/+117
| | | | | | | | | | semantics. Reviewers: hokein, alexfh Differential Revision: http://reviews.llvm.org/D16535 llvm-svn: 260503
* [clang-tidy] Add -target in misc-misplaced-widening-cast test so it will ↵Daniel Marjamaki2016-02-091-1/+1
| | | | | | work on various bots llvm-svn: 260225
* [clang-tidy] Add 'misc-misplaced-widening-cast' check.Daniel Marjamaki2016-02-091-0/+63
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16310 llvm-svn: 260223
* [clang-tidy] Make readability-container-size-empty work with inline ↵Gabor Horvath2016-02-091-2/+17
| | | | | | namespaces. Fix PR25812. llvm-svn: 260217
* [clang-tidy] Fix assertion failure on `at` function in modernize-loop-convert.Haojian Wu2016-02-082-0/+9
| | | | | | | | | | Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16926 llvm-svn: 260107
* Reverting r260096; it causes build bot failures:Aaron Ballman2016-02-081-40/+5
| | | | | | | http://bb.pgr.jp/builders/cmake-clang-tools-x86_64-linux/builds/23351 http://lab.llvm.org:8011/builders/clang-s390x-linux/builds/492 llvm-svn: 260097
* Expand the simplify boolean expression check to handle implicit conversion ↵Aaron Ballman2016-02-081-5/+40
| | | | | | | | | | | | 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: 260096
* [clang-tidy] Move incorrect-roundings to upstream.Haojian Wu2016-02-081-0/+86
| | | | | | | | | | | | Summary: This is originally implemented by Jacques Pienaar. Reviewers: alexfh Subscribers: cfe-commits, jpienaar Differential Revision: http://reviews.llvm.org/D16764 llvm-svn: 260084
* [clang-tidy] More friendly warning in "google-runtime-references" when ↵Haojian Wu2016-02-041-2/+2
| | | | | | | | | | | | meeting an unnamed function parameter. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16882 llvm-svn: 259787
* [clang-tidy] Fix a crash issue on misc-virtual-near-miss check.Haojian Wu2016-02-031-0/+6
| | | | | | | | | | | | | | Summary: The crash is caused by triggering a Assertion failed in DeclCXX.h when the check detects non-defined class return type in a class method declaration. Reviewers: congliu, alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16854 llvm-svn: 259668
* [clang-tidy] bug fix: Don't warn on partial template specialization in ↵Haojian Wu2016-02-031-0/+25
| | | | | | | | | | | | `misc-definitions-in-headers` check. Reviewers: alexfh Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D16578 llvm-svn: 259643
* [clang-tidy] Removed unnecessary parameters in the testAlexander Kornienko2016-02-021-1/+1
| | | | llvm-svn: 259531
* [clang-tidy] Add non-constant references in function parameters check.Alexander Kornienko2016-02-021-0/+139
| | | | | | | | | | | | | | | Summary: This is implemented originally by Alexander Kornienko. Reviewers: alexfh Subscribers: cfe-commits Patch by Haojian Wu! Differential Revision: http://reviews.llvm.org/D16717 llvm-svn: 259530
* Add a new check, readability-redundant-control-flow, that check for some ↵Aaron Ballman2016-02-011-0/+222
| | | | | | | | forms of redundant control flow statements. Currently checks for return statements at the end of a function with a void return type and continue statements at the end of looping statements. Patch by Richard Thomson. llvm-svn: 259362
* test/clang-tidy/performance-for-range-copy.cpp: Appease for targeting ms mode.NAKAMURA Takumi2016-01-301-1/+1
| | | | llvm-svn: 259289
* [clang-tidy] ForRangeCopyCheck that warns on and fixes unnecessary copies of ↵Alexander Kornienko2016-01-292-0/+262
| | | | | | | | | | loop variables. Patch by Felix Berger! Differential revision: http://reviews.llvm.org/D13849 llvm-svn: 259199
* Fixed function params comparison. Updated docs and tests.Alexander Kornienko2016-01-291-0/+7
| | | | | | | | | | | | | | Summary: "checkParamTypes" may fail if the the type of some parameter is not canonical. Fixed it by comparing canonical types. And added "getCanonicalType()" and "getCanonicalDecl()" on more places to prevent potential fail. Reviewers: alexfh Subscribers: cfe-commits Patch by Cong Liu! Differential Revision: http://reviews.llvm.org/D16587 llvm-svn: 259197
* [clang-tidy] Fix style issues. NFCAlexander Kornienko2016-01-291-0/+0
| | | | llvm-svn: 259196
* [clang-tidy] Move implicit-cast-in-loop check to upstream.Alexander Kornienko2016-01-291-0/+161
| | | | | | | | | | | | | | Summary: This is implemented originally by Alex Pilkiewicz (pilki@google.com). Reviewers: alexfh Subscribers: cfe-commits Patch by Haojian Wu! Differential Revision: http://reviews.llvm.org/D16721 llvm-svn: 259195
* Fix crashing on user-defined conversion.Alexander Kornienko2016-01-261-0/+1
| | | | | | | | | | | | | | Summary: Fix the assertion failure for the user-defined conversion method. e.g.: operator bool() Reviewers: alexfh, aaron.ballman Subscribers: aaron.ballman, cfe-commits Patch by Cong Liu! Differential Revision: http://reviews.llvm.org/D16536 llvm-svn: 258801
* Add support to the misc-assert-side-effect check for MSVC-style assert ↵Aaron Ballman2016-01-251-1/+10
| | | | | | macros, which use !! instead of an if statement or a conditional operator. llvm-svn: 258714
* [clang-tidy] Handle decayed types and other improvements in VirtualNearMiss ↵Gabor Horvath2016-01-221-2/+12
| | | | | | | | | | | check. Handle decayed types, ignore qualifiers and accessibility when considering a method as a possible overload. Differential Revision: http://reviews.llvm.org/D16179 llvm-svn: 258562
OpenPOWER on IntegriCloud