summaryrefslogtreecommitdiffstats
path: root/clang-tools-extra/clang-tidy/utils
Commit message (Collapse)AuthorAgeFilesLines
* Fix MSVC "not all control paths return a value" warning. NFCI.Simon Pilgrim2020-01-061-0/+1
|
* NFC: Fix trivial typos in commentsKazuaki Ishizaki2020-01-042-2/+2
|
* [clang-tidy] fix linkage with clangSema for FixitHintUtils, undo previous ↵Jonas Toth2020-01-031-0/+1
| | | | wrong fix
* [clang-tidy] implement utility-function to add 'const' to variablesJonas Toth2020-01-034-3/+230
| | | | | | | | | | | | | | | | | | | | | | | Summary: This patch extends the already existing facility to add 'const' to variables to be more flexible and correct. The previous version did not consider pointers as value AND pointee. For future automatic introduction for const-correctness this shortcoming needs to be fixed. It always allows configuration where the 'const' token is inserted, either on the left side (if possible) or the right side. It adds many unit-tests to the utility-function that did not exist before, as the function was implicitly tested through clang-tidy checks. These tests were not changed, as the API is still compatible. Reviewers: aaron.ballman, hokein, alexfh, shuaiwang, lebedev.ri Reviewed By: aaron.ballman Subscribers: jdoerfert, mgorny, xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D54395
* [NFC] Fixes -Wrange-loop-analysis warningsMark de Wever2020-01-012-2/+2
| | | | | | This avoids new warnings due to D68912 adds -Wrange-loop-analysis to -Wall. Differential Revision: https://reviews.llvm.org/D71857
* Fix readability-const-return-type identifying the wrong `const` tokenIlya Mirsky2019-12-242-17/+30
| | | | | | | Replace tidy::utils::lexer::getConstQualifyingToken with a corrected and also generalized to other qualifiers variant - getQualifyingToken. Fixes PR44326
* [clang-tidy] modernize-use-equals-default avoid adding redundant semicolonsMitchell Balan2019-11-202-0/+15
| | | | | | | | | | | | | | | | | | | Summary: `modernize-use-equals-default` replaces default constructors/destructors with `= default;`. When the optional semicolon after a member function is present, this results in two consecutive semicolons. This patch checks to see if the next non-comment token after the code to be replaced is a semicolon, and if so offers a replacement of `= default` rather than `= default;`. This patch adds trailing comments and semicolons to about 5 existing tests. Reviewers: malcolm.parsons, angelgarcia, aaron.ballman, alexfh Patch by: poelmanc Subscribers: MyDeveloperDay, JonasToth, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D70144
* [libTooling] Further simplify `Stencil` type and introduce `MatchComputation`.Yitzhak Mandelbaum2019-11-111-1/+1
| | | | | | | | | | | | | | | | | | | | Summary: This revision introduces a new interface `MatchComputation` which generalizes the `Stencil` interface and replaces the `std::function` interface of `MatchConsumer`. With this revision, `Stencil` (as an abstraction) becomes just one collection of implementations of `MatchComputation<std::string>`. Correspondingly, we remove the `Stencil` class entirely in favor of a simple type alias, deprecate `MatchConsumer` and change all functions that accepted `MatchConsumer<std::string>` to use `MatchComputation<std::string>` instead. Reviewers: gribozavr Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69802
* [clang-tidy] Update TransformerClangTidyCheck to use new Transformer bindings.Yitzhak Mandelbaum2019-11-062-9/+9
| | | | | | | | | | | | | | Summary: Updates the relevant source files to use bindings in `clang::transformer` rather than `clang::tooling`. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D69804
* [clang-tidy] New checker performance-trivially-destructible-checkAnton Bikineev2019-11-013-1/+22
| | | | | | | | | | | | | Checks for types which can be made trivially-destructible by removing out-of-line defaulted destructor declarations. The check is motivated by the work on C++ garbage collector in Blink (rendering engine for Chrome), which strives to minimize destructors and improve runtime of sweeping phase. In the entire chromium codebase the check hits over 2000 times. Differential Revision: https://reviews.llvm.org/D69435
* [libTooling] Move Transformer files to their own directory/library.Yitzhak Mandelbaum2019-10-102-2/+2
| | | | | | | | | | | | | | | | | | | Summary: The Transformer library has been growing inside of lib/Tooling/Refactoring. However, it's not really related to anything else in that directory. This revision moves all Transformer-related files into their own include & lib directories. A followup revision will (temporarily) add forwarding headers to help any users migrate their code to the new location. Reviewers: gribozavr Subscribers: mgorny, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D68637 llvm-svn: 374271
* [clang-tidy] Fix a potential infinite loop in ↵Haojian Wu2019-09-181-0/+6
| | | | | | | | | | | | | | readability-isolate-declaration check. Reviewers: ilya-biryukov Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67654 llvm-svn: 372206
* [clang-tidy] Fix bug in bugprone-use-after-move checkYitzhak Mandelbaum2019-09-091-5/+12
| | | | | | | | | | | | | | | | | | | | Summary: The bugprone-use-after-move check exhibits false positives for certain uses of the C++17 if/switch init statements. These false positives are caused by a bug in the ExprSequence calculations. This revision adds tests for the false positives and fixes the corresponding sequence calculation. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D67292 llvm-svn: 371396
* [clang-tidy] Fix the potential infinite loop in ↵Haojian Wu2019-08-281-0/+4
| | | | | | | | | | | | | | | | | | recordIsTriviallyDefaultConstructible. Summary: The recordIsTriviallyDefaultConstructible may cause an infinite loop when running on an ill-formed decl. Reviewers: gribozavr Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66874 llvm-svn: 370200
* [clang-tidy] TransformerClangTidyCheck: change choice of location for ↵Yitzhak Mandelbaum2019-08-261-11/+5
| | | | | | | | | | | | | | | | | | | | | | | | | diagnostic message. Summary: This patch changes the location specified to the `ClangTidyCheck::diag()`. Currently, the beginning of the matched range is used. This patch uses the beginning of the first fix's range. This change both simplifies the code and (hopefully) gives a more intuitive result: the reported location aligns with the fix(es) provided, rather than the (arbitrary) range of the rule's match. N.B. this patch will break the line offset numbers in lit tests if the first fix is not at the beginning of the match. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66676 llvm-svn: 369914
* Remove \brief commands from doxygen comments.Dmitri Gribenko2019-08-226-16/+16
| | | | | | | | | | | | | | | | | | | | | | | Summary: We've been running doxygen with the autobrief option for a couple of years now. This makes the \brief markers into our comments redundant. Since they are a visual distraction and we don't want to encourage more \brief markers in new code either, this patch removes them all. Patch produced by for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done [This is analogous to LLVM r331272 and CFE r331834] Subscribers: srhines, nemanjai, javed.absar, kbarton, MaskRay, jkorous, arphaman, jfb, kadircet, jsji, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66578 llvm-svn: 369643
* [clang-tools-extra] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-144-6/+6
| | | | | | | | | | Now that we've moved to C++14, we no longer need the llvm::make_unique implementation from STLExtras.h. This patch is a mechanical replacement of (hopefully) all the llvm::make_unique instances across the monorepo. Differential revision: https://reviews.llvm.org/D66259 llvm-svn: 368944
* [clang-tidy] Update `TransformerClangTidyCheck` to use new `buildMatchers` ↵Yitzhak Mandelbaum2019-08-131-1/+2
| | | | | | | | | | | | | | | | | | functionality. Summary: `buildMatchers` is the new, more general way to extract the matcher from a rule. This change migrates the code to use it instead of `buildMatcher`. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D65879 llvm-svn: 368700
* [clang-tidy] Extend TransformerClangTidyCheck to support adding includes.Yitzhak Mandelbaum2019-07-022-0/+27
| | | | | | | | | | | | | | | | | Summary: This revision implements support for the `AddedIncludes` field in RewriteRule cases; that is, it supports specifying the addition of include directives in files modified by the clang tidy check. Reviewers: ilya-biryukov, gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63893 llvm-svn: 364922
* [clang-tidy] Fix NDEBUG build [NFC]Mikael Holmen2019-06-271-0/+2
| | | | llvm-svn: 364535
* [clang-tidy] Generalize TransformerClangTidyCheck to take a rule generator.Yitzhak Mandelbaum2019-06-262-12/+46
| | | | | | | | | | | | | | Summary: Tidy check behavior often depends on language and/or clang-tidy options. This revision allows a user of TranformerClangTidyCheck to pass rule _generator_ in place of a rule, where the generator takes both the language and clang-tidy options. Additionally, the generator returns an `Optional` to allow for the case where the check is deemed irrelevant/disable based on those options. Reviewers: gribozavr Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D63288 llvm-svn: 364442
* [clang-tidy] Fix unused-variable warning after r361647.Haojian Wu2019-05-271-6/+7
| | | | | | | | | | | | | | | | | | | | | Summary: A range-for was added in r361647 where the range variable was only used in an assertion. As a result, it warned for Release builds. This revision restructures the assertion to avoid the problem. Patch by Yitzhak Mandelbaum. Reviewers: ilya-biryukov Reviewed By: ilya-biryukov Subscribers: xazax.hun, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D62412 llvm-svn: 361749
* Rename clangToolingRefactor to clangToolingRefactoring for consistency with ↵Nico Weber2019-05-251-1/+1
| | | | | | | | | | its directory See "[cfe-dev] The name of clang/lib/Tooling/Refactoring". Differential Revision: https://reviews.llvm.org/D62420 llvm-svn: 361684
* [clang-tidy] In TransformerClangTidyCheck, require Explanation field.Yitzhak Mandelbaum2019-05-242-11/+24
| | | | | | | | | | | | | | | | | | | Summary: In general, the `Explanation` field is optional in `RewriteRule` cases. But, because the primary purpose of clang-tidy checks is to provide users with diagnostics, we assume that a missing explanation is a bug. This change adds an assertion that checks all cases for an explanation, and updates the code to rely on that assertion correspondingly. Reviewers: ilya-biryukov Subscribers: xazax.hun, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D62340 llvm-svn: 361647
* [clang-tidy] Add support for writing a check as a Transformer rewrite rule.Yitzhak Mandelbaum2019-05-223-0/+114
| | | | | | | | | | | | | | | | | | | | | | | | This revision introduces an adaptor from Transformer's rewrite rules (`clang::tooling::RewriteRule`) to `ClangTidyCheck`. For example, given a RewriteRule `MyCheckAsRewriteRule`, it lets one define a tidy check as follows: ``` class MyTidyCheck : public TransformerClangTidyCheck { public: MyTidyCheck(StringRef Name, ClangTidyContext *Context) : TransformerClangTidyCheck(MyCheckAsRewriteRule, Name, Context) {} }; ``` Reviewers: aaron.ballman Subscribers: mgorny, xazax.hun, cfe-commits, ilya-biryukov Tags: #clang Differential Revision: https://reviews.llvm.org/D61386 llvm-svn: 361418
* [clang-tidy] openmp-exception-escape - a new checkRoman Lebedev2019-03-222-0/+13
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: Finally, we are here! Analyzes OpenMP Structured Blocks and checks that no exception escapes out of the Structured Block it was thrown in. As per the OpenMP specification, structured block is an executable statement, possibly compound, with a single entry at the top and a single exit at the bottom. Which means, ``throw`` may not be used to to 'exit' out of the structured block. If an exception is not caught in the same structured block it was thrown in, the behaviour is undefined / implementation defined, the program will likely terminate. Reviewers: JonasToth, aaron.ballman, baloghadamsoftware, gribozavr Reviewed By: aaron.ballman, gribozavr Subscribers: mgorny, xazax.hun, rnkovacs, guansong, jdoerfert, cfe-commits, ABataev Tags: #clang-tools-extra, #openmp, #clang Differential Revision: https://reviews.llvm.org/D59466 llvm-svn: 356802
* [NFC] ExceptionEscapeCheck: small refactoringRoman Lebedev2019-03-222-1/+20
| | | | | | | | | | | | | | | | | | | Summary: D59466 wants to analyse the `Stmt`, and `ExceptionEscapeCheck` does not have that as a possible entry point. This simplifies addition of `Stmt` analysis entry point. Reviewers: baloghadamsoftware, JonasToth, gribozavr Reviewed By: gribozavr Subscribers: rnkovacs, cfe-commits Tags: #clang-tools-extra, #clang Differential Revision: https://reviews.llvm.org/D59650 llvm-svn: 356799
* [clang-tidy] Move all checks to the new registerPPCallbacks APIAlexander Kornienko2019-03-223-10/+11
| | | | llvm-svn: 356796
* Fix file headers. NFCFangrui Song2019-03-011-1/+1
| | | | llvm-svn: 355188
* [clang-tidy] undo bitfields in ExceptionAnalyzerJonas Toth2019-02-261-4/+2
| | | | | | | Scoped enums do induce some problems with some MSVC and GCC versions if used as bitfields. Therefor this is deactivated for now. llvm-svn: 354903
* Attempt to fix VS2015 build breakage from r354517. NFCI.Douglas Yung2019-02-211-1/+1
| | | | llvm-svn: 354545
* [clang-tidy] refactor ExceptionAnalyzer further to give ternary answerJonas Toth2019-02-202-82/+268
| | | | | | | | | | | | | | | | | | | | | | | | Summary: The analsis on the throwing behvaiour on functions and statements gave only a binary answer whether an exception could occur and if yes which types are thrown. This refactoring allows keeping track if there is a unknown factor, because the code calls to some functions with unavailable source code with no `noexcept` information. This 'potential Unknown' information is propagated properly and can be queried separately. Reviewers: lebedev.ri, aaron.ballman, baloghadamsoftware, alexfh Reviewed By: lebedev.ri, baloghadamsoftware Subscribers: xazax.hun, rnkovacs, a.sidorin, Szelethus, donat.nagy, dkrupp, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D57883 llvm-svn: 354517
* [clang-tidy] refactor bugprone-exception-escape analysis into classJonas Toth2019-01-313-0/+203
| | | | | | | | | | | | | | | | | | | | | | Summary: The check `bugprone-exception-escape` does an AST-based analysis to determine if a function might throw an exception and warns based on that information. The analysis part is refactored into a standalone class similiar to `ExprMutAnalyzer` that is generally useful. I intent to use that class in a new check to automatically introduce `noexcept` if possible. Reviewers: aaron.ballman, alexfh, hokein, baloghadamsoftware, lebedev.ri Reviewed By: baloghadamsoftware, lebedev.ri Subscribers: lebedev.ri, mgorny, xazax.hun, rnkovacs, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D57100 llvm-svn: 352741
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-1927-108/+81
| | | | | | | | | | | | | | | | | to reflect the new license. We understand that people may be surprised that we're moving the header entirely to discuss the new license. We checked this carefully with the Foundation's lawyer and we believe this is the correct approach. Essentially, all code in the project is now made available by the LLVM project under our new license, so you will see that the license headers include that license only. Some of our contributors have contributed code under our old license, and accordingly, we have retained a copy of our old license notice in the top-level files in each project and repository. llvm-svn: 351636
* [clang-tidy] Fixed code sample in a comment. NFCAlexander Kornienko2018-11-021-4/+6
| | | | llvm-svn: 345984
* [clang-tidy] .reset(new X) -> make_unique<X>() in a comment. NFCAlexander Kornienko2018-11-021-2/+2
| | | | llvm-svn: 345979
* Implement the readability-const-return-type check.Aaron Ballman2018-10-312-0/+36
| | | | | | | | This check flags function top-level const-qualified return types and suggests removing the mostly-superfluous const qualifier where possible. Patch by Yitzhak Mandelbaum. llvm-svn: 345764
* [clang-tidy] new check 'readability-isolate-declaration'Jonas Toth2018-10-312-0/+121
| | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 345735
* [clang-tidy] Re-commit: Add new 'readability-uppercase-literal-suffix' check ↵Roman Lebedev2018-10-262-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | (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 llvm-svn: 345381
* [clang-tidy] Revert my readability-uppercase-literal-suffix check.Roman Lebedev2018-10-252-38/+0
| | | | | | | | | | 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. llvm-svn: 345305
* [clang-tidy] Add new 'readability-uppercase-literal-suffix' check (CERT ↵Roman Lebedev2018-10-182-0/+38
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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 llvm-svn: 344755
* [clang-tidy] White List Option for performance-unnecessary-value-param, ↵Adam Balogh2018-10-121-0/+7
| | | | | | | | | | | | | | performance-unnecessary-copy-initialization and performance-for-range-copy New option added to these three checks to be able to silence false positives on types that are intentionally passed by value or copied. Such types are e.g. intrusive reference counting pointer types like llvm::IntrusiveRefCntPtr. The new option is named WhiteListTypes and can contain a semicolon-separated list of names of these types. Regular expressions are allowed. Default is empty. Differential Revision: https://reviews.llvm.org/D52727 llvm-svn: 344340
* [clang-tidy] NFC refactor lexer-utils to be usable without ASTContextJonas Toth2018-10-053-12/+9
| | | | | | | | | | | | | | | | | | | Summary: This patch is a small refactoring necessary for 'readability-isolate-declaration' and does not introduce functional changes. It allows to use the utility functions without a full `ASTContext` and requires only the `SourceManager` and the `LangOpts`. Reviewers: alexfh, aaron.ballman, hokein Reviewed By: alexfh Subscribers: nemanjai, xazax.hun, kbarton, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52684 llvm-svn: 343850
* [clang-tidy] Sequence statements with multiple parents correctly (PR39149)Martin Bohme2018-10-042-4/+11
| | | | | | | | | | | | | | | | | | | | | Summary: Before this fix, the bugprone-use-after-move check could incorrectly conclude that a use and move in a function template were not sequenced. For details, see https://bugs.llvm.org/show_bug.cgi?id=39149 Reviewers: alexfh, hokein, aaron.ballman, JonasToth Reviewed By: aaron.ballman Subscribers: xazax.hun, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D52782 llvm-svn: 343768
* [clangtidy] Remove old copy of ExprMutationAnalyzerShuai Wang2018-09-113-370/+0
| | | | | | | | | | | | | | | | | | Summary: This is 2/2 of moving ExprMutationAnalyzer from clangtidy to clang/Analysis. ExprMutationAnalyzer is moved to clang/Analysis in D51948. This diff migrates existing usages within clangtidy to point to the new location and remove the old copy of ExprMutationAnalyzer. Reviewers: george.karpenkov, JonasToth Reviewed By: george.karpenkov Subscribers: mgorny, a.sidorin, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D51950 llvm-svn: 342006
* [clang-tidy] Handle sugared reference types in ExprMutationAnalyzerShuai Wang2018-09-111-8/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: This handles cases like this: ``` typedef int& IntRef; void mutate(IntRef); void f() { int x; mutate(x); } ``` where the param type is a sugared type (`TypedefType`) instead of a reference type directly. Note that another category of similar but different cases are already handled properly before: ``` typedef int Int; void mutate(Int&); void f() { int x; mutate(x); } ``` Reviewers: aaron.ballman, alexfh, george.karpenkov Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D50953 llvm-svn: 341986
* [clang-tidy] Handle unique owning smart pointers in ExprMutationAnalyzerShuai Wang2018-09-111-2/+40
| | | | | | | | | | | | | | | | | | | | | | | | Summary: For smart pointers like std::unique_ptr which uniquely owns the underlying object, treat the mutation of the pointee as mutation of the smart pointer itself. This gives better behavior for cases like this: ``` void f(std::vector<std::unique_ptr<Foo>> v) { // undesirable analyze result of `v` as not mutated. for (auto& p : v) { p->mutate(); // only const member function `operator->` is invoked on `p` } } ``` Reviewers: hokein, george.karpenkov Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D50883 llvm-svn: 341967
* Revert "Revert "[clang-tidy] Handle unresolved expressions in ↵Shuai Wang2018-09-111-6/+20
| | | | | | | | | | | ExprMutationAnalyzer"" This is the same as D50619 plus fixes for buildbot failures on windows. The test failures on windows are caused by -fdelayed-template-parsing and is fixed by forcing -fno-delayed-template-parsing on test cases that requires AST for uninstantiated templates. llvm-svn: 341891
* Revert "[clang-tidy] Handle unresolved expressions in ExprMutationAnalyzer"Shuai Wang2018-09-101-20/+6
| | | | | | | | | | | | | | | | | Summary: Tests somehow break on windows (and only on windows) http://lab.llvm.org:8011/builders/clang-x64-ninja-win7/builds/13003 http://lab.llvm.org:8011/builders/clang-x86-windows-msvc2015/builds/13747 I have yet figure out why so reverting to unbreak first. Reviewers: george.karpenkov Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits Differential Revision: https://reviews.llvm.org/D51898 llvm-svn: 341886
* [clang-tidy] ExprMutationAnalyzer: construct from references. Fixes PR38888Roman Lebedev2018-09-102-11/+11
| | | | | | | | | | | | | | | | | | | | | | | | | | | Summary: I have hit this the rough way, while trying to use this in D51870. There is no particular point in storing the pointers, and moreover the pointers are assumed to be non-null, and that assumption is not enforced. If they are null, it won't be able to do anything good with them anyway. Initially i thought about simply adding asserts() that they are not null, but taking/storing references looks like even cleaner solution? Fixes [[ https://bugs.llvm.org/show_bug.cgi?id=38888 | PR38888 ]] Reviewers: JonasToth, shuaiwang, alexfh, george.karpenkov Reviewed By: shuaiwang Subscribers: xazax.hun, a.sidorin, Szelethus, cfe-commits Tags: #clang-tools-extra Differential Revision: https://reviews.llvm.org/D51884 llvm-svn: 341854
OpenPOWER on IntegriCloud