summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Commit message (Collapse)AuthorAgeFilesLines
* [ObjC] Make sure that the implicit arguments for direct methods have been setupAlex Lorenz2019-12-061-7/+0
| | | | | | | | | | | | | | | | | | | | This commit sets the Self and Imp declarations for ObjC method declarations, in addition to the definitions. It also fixes a bunch of code in clang that had wrong assumptions about when getSelfDecl() would be set: - CGDebugInfo::getObjCMethodName and AnalysisConsumer::getFunctionName would assume that it was set for method declarations part of a protocol, which they never were, and that self would be a Class type, which it isn't as it is id for a protocol. Also use the Canonical Decl to index the set of Direct methods so that when calls and implementations interleave, the same llvm::Function is used and the same symbol name emitted. Radar-Id: rdar://problem/57661767 Patch by: Pierre Habouzit Differential Revision: https://reviews.llvm.org/D71091
* [analyzer][NFC] Fix inconsistent references to checkers as "checks"Kristof Umann2019-09-121-1/+1
| | | | | | | | | | | | | | Traditionally, clang-tidy uses the term check, and the analyzer uses checker, but in the very early years, this wasn't the case, and code originating from the early 2010's still incorrectly refer to checkers as checks. This patch attempts to hunt down most of these, aiming to refer to checkers as checkers, but preserve references to callback functions (like checkPreCall) as checks. Differential Revision: https://reviews.llvm.org/D67140 llvm-svn: 371760
* [analyzer] NFC: Move PathDiagnostic classes to libAnalysis.Artem Dergachev2019-09-111-1/+1
| | | | | | | | | | | | At this point the PathDiagnostic, PathDiagnosticLocation, PathDiagnosticPiece structures no longer rely on anything specific to Static Analyzer, so we can move them out of it for everybody to use. PathDiagnosticConsumers are still to be handed off. Differential Revision: https://reviews.llvm.org/D67419 llvm-svn: 371661
* [analyzer] Add minimal support for fix-it hints.Artem Dergachev2019-09-061-18/+42
| | | | | | | | | | | | | | | | | | | | | | | | | | Allow attaching fixit hints to Static Analyzer BugReports. Fixits are attached either to the bug report itself or to its notes (path-sensitive event notes or path-insensitive extra notes). Add support for fixits in text output (including the default text output that goes without notes, as long as the fixit "belongs" to the warning). Add support for fixits in the plist output mode. Implement a fixit for the path-insensitive DeadStores checker. Only dead initialization warning is currently covered. Implement a fixit for the path-sensitive VirtualCall checker when the virtual method is not pure virtual (in this case the "fix" is to suppress the warning by qualifying the call). Both fixits are under an off-by-default flag for now, because they require more careful testing. Differential Revision: https://reviews.llvm.org/D65182 llvm-svn: 371257
* Removed some dead code in BugReporter and related filesDmitri Gribenko2019-08-211-3/+3
| | | | | | | | | | Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D66473 llvm-svn: 369504
* [analyzer] NFC: Remove the BugTypes set from BugReporter.Artem Dergachev2019-08-201-0/+4
| | | | | | | Its only purpose was to avoid a bug that's caused by making a virtual call in BugReporter's destructor. llvm-svn: 369451
* [Clang] Migrate llvm::make_unique to std::make_uniqueJonas Devlieghere2019-08-141-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: 368942
* [CrossTU] Added CTU argument to diagnostic consumer create fn.Balazs Keri2019-07-231-11/+11
| | | | | | | | | | | | | | | | | | Summary: The PListDiagnosticConsumer needs a new CTU parameter that is passed through the create functions. Reviewers: NoQ, Szelethus, xazax.hun, martong Reviewed By: Szelethus Subscribers: rnkovacs, dkrupp, Szelethus, gamesh411, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D64635 llvm-svn: 366782
* [analyzer] Add more timers for performance profiling.Artem Dergachev2019-06-251-9/+34
| | | | | | | | | | | | | The -analyzer-stats flag now allows you to find out how much time was spent on AST-based analysis and on path-sensitive analysis and, separately, on bug visitors, as they're occasionally a performance problem on their own. The total timer wasn't useful because there's anyway a total time printed out. Remove it. Differential Revision: https://reviews.llvm.org/D63227 llvm-svn: 364266
* [analyzer] Add werror flag for analyzer warningsKeno Fischer2019-06-071-4/+13
| | | | | | | | | | | | | | | | | | | | | | | Summary: We're using the clang static analyzer together with a number of custom analyses in our CI system to ensure that certain invariants are statiesfied for by the code every commit. Unfortunately, there currently doesn't seem to be a good way to determine whether any analyzer warnings were emitted, other than parsing clang's output (or using scan-build, which then in turn parses clang's output). As a simpler mechanism, simply add a `-analyzer-werror` flag to CC1 that causes the analyzer to emit its warnings as errors instead. I briefly tried to have this be `Werror=analyzer` and make it go through that machinery instead, but that seemed more trouble than it was worth in terms of conflicting with options to the actual build and special cases that would be required to circumvent the analyzers usual attempts to quiet non-analyzer warnings. This is simple and it works well. Reviewed-By: NoQ, Szelethusw Differential Revision: https://reviews.llvm.org/D62885 llvm-svn: 362855
* [analyzer][CrossTU] Extend CTU to VarDecls with initializerRafael Stahl2019-04-231-0/+29
| | | | | | | | | | | | | | | | | | | | | | Summary: The existing CTU mechanism imports `FunctionDecl`s where the definition is available in another TU. This patch extends that to VarDecls, to bind more constants. - Add VarDecl importing functionality to CrossTranslationUnitContext - Import Decls while traversing them in AnalysisConsumer - Add VarDecls to CTU external mappings generator - Name changes from "external function map" to "external definition map" Reviewers: NoQ, dcoughlin, xazax.hun, george.karpenkov, martong Reviewed By: xazax.hun Subscribers: Charusso, baloghadamsoftware, mikhail.ramalho, Szelethus, donat.nagy, dkrupp, george.karpenkov, mgorny, whisperity, szepet, rnkovacs, a.sidorin, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D46421 llvm-svn: 358968
* Update the file headers across all of the LLVM projects in the monorepoChandler Carruth2019-01-191-4/+3
| | | | | | | | | | | | | | | | | 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
* [analyzer] Evaluate all non-checker config options before analysisKristof Umann2018-11-301-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | In earlier patches regarding AnalyzerOptions, a lot of effort went into gathering all config options, and changing the interface so that potential misuse can be eliminited. Up until this point, AnalyzerOptions only evaluated an option when it was querried. For example, if we had a "-no-false-positives" flag, AnalyzerOptions would store an Optional field for it that would be None up until somewhere in the code until the flag's getter function is called. However, now that we're confident that we've gathered all configs, we can evaluate off of them before analysis, so we can emit a error on invalid input even if that prticular flag will not matter in that particular run of the analyzer. Another very big benefit of this is that debug.ConfigDumper will now show the value of all configs every single time. Also, almost all options related class have a similar interface, so uniformity is also a benefit. The implementation for errors on invalid input will be commited shorty. Differential Revision: https://reviews.llvm.org/D53692 llvm-svn: 348031
* [analyzer] [NFC] Remove unused parameters, as found by -Wunused-parameterGeorge Karpenkov2018-09-281-28/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D52640 llvm-svn: 343353
* [analyzer] Provide an option to dump generated exploded graphs to a given file.George Karpenkov2018-09-281-0/+3
| | | | | | | | | | | Dumping graphs instead of opening them is often very useful, e.g. for transfer or converting to SVG. Basic sanity check for generated exploded graphs. Differential Revision: https://reviews.llvm.org/D52637 llvm-svn: 343352
* [analyzer] Remove traces of ubigraph visualizationGeorge Karpenkov2018-09-061-108/+0
| | | | | | | | | | Ubigraph project has been dead since about 2008, and to the best of my knowledge, no one was using it. Previously, I wasn't able to launch the existing binary at all. Differential Revision: https://reviews.llvm.org/D51655 llvm-svn: 341601
* Port getLocStart -> getBeginLocStephen Kelly2018-08-091-1/+1
| | | | | | | | | | Reviewers: teemperor! Subscribers: jholewinski, whisperity, jfb, cfe-commits Differential Revision: https://reviews.llvm.org/D50350 llvm-svn: 339385
* [analyzer] Add ASTContext to CheckerManagerGeorge Karpenkov2018-08-061-5/+4
| | | | | | | | | Some checkers require ASTContext. Having it in the constructor saves a lot of boilerplate of having to pass it around. Differential Revision: https://reviews.llvm.org/D50111 llvm-svn: 339079
* [analyzer] Allow registering custom statically-linked analyzer checkersAlexander Kornienko2018-06-271-2/+9
| | | | | | | | | | | | | | | | | | Summary: Add an extension point to allow registration of statically-linked Clang Static Analyzer checkers that are not a part of the Clang tree. This extension point employs the mechanism used when checkers are registered from dynamically loaded plugins. Reviewers: george.karpenkov, NoQ, xazax.hun, dcoughlin Reviewed By: george.karpenkov Subscribers: mgorny, mikhail.ramalho, rnkovacs, xazax.hun, szepet, a.sidorin, cfe-commits Differential Revision: https://reviews.llvm.org/D45718 llvm-svn: 335740
* Work around false -Wmissing-braces warning from old clang which has been ↵Fangrui Song2018-06-121-1/+1
| | | | | | fixed in r314838 llvm-svn: 334539
* Refactor ExecuteAndWait to take StringRefs.Zachary Turner2018-06-121-2/+2
| | | | | | | | | | | | | | | | | | | This simplifies some code which had StringRefs to begin with, and makes other code more complicated which had const char* to begin with. In the end, I think this makes for a more idiomatic and platform agnostic API. Not all platforms launch process with null terminated c-string arrays for the environment pointer and argv, but the api was designed that way because it allowed easy pass-through for posix-based platforms. There's a little additional overhead now since on posix based platforms we'll be takign StringRefs which were constructed from null terminated strings and then copying them to null terminate them again, but from a readability and usability standpoint of the API user, I think this API signature is strictly better. llvm-svn: 334518
* [analyzer] Make plist-html diagnostic consumer produce multi-file reports.Artem Dergachev2018-05-161-1/+1
| | | | | | | | | | | Previously plist-html output produced multi-file HTML reports but only single-file Plist reports. Change plist-html output to produce multi-file Plist reports as well. Differential Revision: https://reviews.llvm.org/D46902 llvm-svn: 332417
* Remove \brief commands from doxygen comments.Adrian Prantl2018-05-091-6/+6
| | | | | | | | | | | | | | | | | | | This is similar to the LLVM change https://reviews.llvm.org/D46290. 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 for i in $(git grep -l '\\brief'); do perl -pi -e 's/\\brief //g' $i & done Differential Revision: https://reviews.llvm.org/D46320 llvm-svn: 331834
* [analyzer] Enable analysis of WebKit "unified sources".Artem Dergachev2018-04-251-1/+1
| | | | | | | | | | | | | | | | | | | Normally the analyzer begins path-sensitive analysis from functions within the main file, even though the path is allowed to go through any functions within the translation unit. When a recent version of WebKit is compiled, the "unified sources" technique is used, that assumes #including multiple code files into a single main file. Such file would have no functions defined in it, so the analyzer wouldn't be able to find any entry points for path-sensitive analysis. This patch pattern-matches unified file names that are similar to those used by WebKit and allows the analyzer to find entry points in the included code files. A more aggressive/generic approach is being planned as well. Differential Revision: https://reviews.llvm.org/D45839 llvm-svn: 330876
* Resubmit [analyzer] Support for naive cross translation unit analysisIlya Biryukov2018-03-011-6/+9
| | | | | | | | | | | Originally submitted as r326323 and r326324. Reverted in r326432. Reverting the commit was a mistake. The breakage was due to invalid build files in our internal buildsystem, CMakeLists did not have any cyclic dependencies. llvm-svn: 326439
* Revert "[analyzer] Support for naive cross translation unit analysis"Ilya Biryukov2018-03-011-9/+6
| | | | | | | | | | Also revert "[analyzer] Fix a compiler warning" This reverts commits r326323 and r326324. Reason: the commits introduced a cyclic dependency in the build graph. This happens to work with cmake, but breaks out internal integrate. llvm-svn: 326432
* [analyzer] Support for naive cross translation unit analysisGabor Horvath2018-02-281-6/+9
| | | | | | | | | | | | | | | | | | The aim of this patch is to be minimal to enable incremental development of the feature on the top of the tree. This patch should be an NFC when the feature is turned off. It is turned off by default and still considered as experimental. Technical details are available in the EuroLLVM Talk: http://llvm.org/devmtg/2017-03//2017/02/20/accepted-sessions.html#7 Note that the initial prototype was done by A. Sidorin et al.: http://lists.llvm.org/pipermail/cfe-dev/2015-October/045730.html Contributions to the measurements and the new version of the code: Peter Szecsi, Zoltan Gera, Daniel Krupp, Kareem Khazem. Differential Revision: https://reviews.llvm.org/D30691 llvm-svn: 326323
* [analyzer] Do not analyze bison-generated filesGeorge Karpenkov2018-02-261-37/+61
| | | | | | | | | | | | | | | | | | | | | Bison/YACC generated files result in a very large number of (presumably) false positives from the analyzer. These false positives are "true" in a sense of the information analyzer sees: assuming that the lexer can return any token at any point a number of uninitialized reads does occur. (naturally, the analyzer can not capture a complex invariant that certain tokens can only occur under certain conditions). Current fix simply stops analysis on those files. I have examined a very large number of such auto-generated files, and they do all start with such a comment. Conversely, user code is very unlikely to contain such a comment. rdar://33608161 Differential Revision: https://reviews.llvm.org/D43421 llvm-svn: 326135
* [analyzer] Serialize statistics to plist when serialize-stats=true is setGeorge Karpenkov2018-02-101-13/+13
| | | | | | Differential Revision: https://reviews.llvm.org/D43131 llvm-svn: 324793
* [analyzer] Introduce statistics for the total number of visited basic blocksGeorge Karpenkov2018-02-091-0/+4
| | | | | | Differential Revision: https://reviews.llvm.org/D43133 llvm-svn: 324785
* Update users of llvm::sys::ExecuteAndWait etc.Alexander Kornienko2017-09-131-2/+1
| | | | | | | | | | | | Summary: Clang part of https://reviews.llvm.org/D37563 Reviewers: bkramer Subscribers: vsk, cfe-commits Differential Revision: https://reviews.llvm.org/D37564 llvm-svn: 313156
* [Statistics] Use the new Statistic::updateMax to atomically calculate a ↵Craig Topper2017-05-181-4/+2
| | | | | | maximum value statistic. llvm-svn: 303320
* [AST/ObjC] Make ObjCCategoryImplDecl consistent with ObjCCategoryDecl and ↵Argyrios Kyrtzidis2017-03-071-2/+2
| | | | | | | | use the category name as its DeclName This also addresses the badness in ObjCCategoryImplDecl's API, which was hiding NamedDecl's APIs with different meaning. llvm-svn: 297131
* Adapt to llvm NamedRegionTimer changesMatthias Braun2016-11-181-1/+1
| | | | | | We have to specify a name and description for the timers and groups now. llvm-svn: 287371
* [analyzer] Re-apply r283092, attempt no.4, chunk no.4 (last)Artem Dergachev2016-10-071-6/+18
| | | | | | | The problem that caused the msvc crash has been indentified and fixed in the previous commit. This patch contains the rest of r283092. llvm-svn: 283584
* Revert "[analyzer] Try to re-apply r283092 "Extend bug reports with extra notes"Artem Dergachev2016-10-071-18/+6
| | | | | | Vector of smart pointers wasn't the thing that caused msvc crash. llvm-svn: 283537
* [analyzer] Try to re-apply r283092 "Extend bug reports with extra notes"Artem Dergachev2016-10-071-6/+18
| | | | | | | Replace SmallVector<IntrusiveRefCntPtr> with a vector of plain pointers. Would insignificantly increase memory usage. llvm-svn: 283536
* Revert "[analyzer] Extend bug reports with extra notes" to fix Windows bot.Vitaly Buka2016-10-041-18/+6
| | | | | | This reverts commit r283092. llvm-svn: 283180
* [analyzer] Extend bug reports with extra notesArtem Dergachev2016-10-031-6/+18
| | | | | | | | | | | | | | | | | | | | These diagnostics are separate from the path-sensitive engine's path notes, and can be added manually on top of path-sensitive or path-insensitive reports. The new note diagnostics would appear as note:-diagnostic on console and as blue bubbles in scan-build. In plist files they currently do not appear, because format needs to be discussed with plist file users. The analyzer option "-analyzer-config notes-as-events=true" would convert notes to normal path notes, and put them at the beginning of the path. This is a temporary hack to show the new notes in plist files. A few checkers would be updated in subsequent commits, including tests for this new feature. Differential Revision: https://reviews.llvm.org/D24278 llvm-svn: 283092
* Adapt to LLVM EnableStatistics() change.Matthias Braun2016-09-271-1/+1
| | | | llvm-svn: 282533
* CC1: Add -save-stats optionMatthias Braun2016-09-261-1/+3
| | | | | | | | | This option behaves in a similar spirit as -save-temps and writes internal llvm statistics in json format to a file. Differential Revision: https://reviews.llvm.org/D24820 llvm-svn: 282426
* [analyzer] Fix crash in RetainCountChecker::checkEndFunctionAlexander Shaposhnikov2016-09-231-2/+6
| | | | | | | | | | | | | | | | | The class BodyFarm creates bodies for OSAtomicCompareAndSwap*, objc_atomicCompareAndSwap*, dispatch_sync*, dispatch_once* and for them the flag isBodyAutosynthesized is set to true. This diff 1. makes AnalysisConsumer::HandleCode skip the autosynthesized code 2. replaces assert(LCtx->getParent()) in RetainCountChecker::checkEndFunction by assert(!LCtx->inTopFrame()) (minor cleanup) Test plan: make -j8 check-clang-analysis Differential revision: https://reviews.llvm.org/D24792 llvm-svn: 282293
* [analyzer] Change -analyze-function to accept qualified names.Artem Dergachev2016-08-081-22/+60
| | | | | | | | | | | | | | | Both -analyze-function and -analyzer-display-progress now share the same convention for naming functions, which allows discriminating between methods with the same name in different classes, C++ overloads, and also presents Objective-C instance and class methods in the convenient notation. This also allows looking up the name for the particular function you're trying to restrict analysis to in the -analyzer-display-progress output, in case it was not instantly obvious. Differential Revision: https://reviews.llvm.org/D22856 llvm-svn: 278018
* [analyzer] Add checker modeling potential C++ self-assignmentDevin Coughlin2016-07-211-3/+8
| | | | | | | | | | | | | | | | | | | | | This checker checks copy and move assignment operators whether they are protected against self-assignment. Since C++ core guidelines discourages explicit checking for `&rhs==this` in general we take a different approach: in top-frame analysis we branch the exploded graph for two cases, where &rhs==this and &rhs!=this and let existing checkers (e.g. unix.Malloc) do the rest of the work. It is important that we check all copy and move assignment operator in top frame even if we checked them already since self-assignments may happen undetected even in the same translation unit (e.g. using random indices for an array what may or may not be the same). This reapplies r275820 after fixing a string-lifetime issue discovered by the bots. A patch by Ádám Balogh! Differential Revision: https://reviews.llvm.org/D19311 llvm-svn: 276365
* [NFC] Header cleanupMehdi Amini2016-07-181-5/+0
| | | | | | | | | | Summary: Removed unused headers, replaced some headers with forward class declarations Patch by: Eugene <claprix@yandex.ru> Differential Revision: https://reviews.llvm.org/D20100 llvm-svn: 275882
* Revert "[analyzer] Add checker modeling potential C++ self-assignment"Devin Coughlin2016-07-181-8/+3
| | | | | | This reverts commit r275820. It is failing on the bots. llvm-svn: 275880
* [analyzer] Add checker modeling potential C++ self-assignmentDevin Coughlin2016-07-181-3/+8
| | | | | | | | | | | | | | | | | | This checker checks copy and move assignment operators whether they are protected against self-assignment. Since C++ core guidelines discourages explicit checking for `&rhs==this` in general we take a different approach: in top-frame analysis we branch the exploded graph for two cases, where &rhs==this and &rhs!=this and let existing checkers (e.g. unix.Malloc) do the rest of the work. It is important that we check all copy and move assignment operator in top frame even if we checked them already since self-assignments may happen undetected even in the same translation unit (e.g. using random indices for an array what may or may not be the same). A patch by Ádám Balogh! Differential Revision: https://reviews.llvm.org/D19311 llvm-svn: 275820
* Use arrays or initializer lists to feed ArrayRefs instead of SmallVector ↵Benjamin Kramer2016-07-021-4/+1
| | | | | | | | where possible. No functionality change intended llvm-svn: 274432
* Prune away some unused using decls. NFC.Benjamin Kramer2016-06-081-1/+0
| | | | | | Found by clang's misc-unused-using-decls. llvm-svn: 272156
* Apply clang-tidy's misc-move-constructor-init throughout Clang.Benjamin Kramer2016-05-271-7/+7
| | | | | | No functionality change intended, maybe a tiny performance improvement. llvm-svn: 270996
OpenPOWER on IntegriCloud