summaryrefslogtreecommitdiffstats
path: root/clang/lib/StaticAnalyzer/Frontend/AnalysisConsumer.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* [analyzer] Make shallow mode more shallow.Anna Zaks2013-01-301-1/+1
| | | | | | | | | | | | | | | | Redefine the shallow mode to inline all functions for which we have a definite definition (ipa=inlining). However, only inline functions that are up to 4 basic blocks large and cut the max exploded nodes generated per top level function in half. This makes shallow faster and allows us to keep inlining small functions. For example, we would keep inlining wrapper functions and constructors/destructors. With the new shallow, it takes 104s to analyze sqlite3, whereas the deep mode is 658s and previous shallow is 209s. llvm-svn: 173958
* Re-sort #include lines using the llvm/utils/sort_includes.py script.Chandler Carruth2013-01-021-1/+1
| | | | | | | Removes a duplicate #include as well as cleaning up some sort order regressions since I last ran the script over Clang. llvm-svn: 171364
* [analyzer] Re-apply r170826 and make the dumping of the GallGraphAnna Zaks2012-12-211-44/+18
| | | | | | | | | | | | | | | | | | | | | | | deterministic. Commit message for r170826: [analyzer] Traverse the Call Graph in topological order. Modify the call graph by removing the parentless nodes. Instead all nodes are children of root to ensure they are all reachable. Remove the tracking of nodes that are "top level" or global. This information is not used and can be obtained from the Decls stored inside CallGraphNodes. Instead of existing ordering hacks, analyze the functions in topological order over the Call Graph. Together with the addition of devirtualizable ObjC message sends and blocks to the call graph, this gives around 6% performance improvement on several large ObjC benchmarks. llvm-svn: 170906
* Revert r170826. The output ofRafael Espindola2012-12-211-18/+44
| | | | | | | | ./bin/clang -cc1 -internal-isystem /home/espindola/llvm/build/lib/clang/3.3/include/ -analyze -analyzer-checker=debug.DumpCallGraph /home/espindola/llvm/clang/test/Analysis/debug-CallGraph.c -fblocks changes in each run. llvm-svn: 170829
* [analyzer] Traverse the Call Graph in topological order.Anna Zaks2012-12-211-44/+18
| | | | | | | | | | | | | | | | | Modify the call graph by removing the parentless nodes. Instead all nodes are children of root to ensure they are all reachable. Remove the tracking of nodes that are "top level" or global. This information is not used and can be obtained from the Decls stored inside CallGraphNodes. Instead of existing ordering hacks, analyze the functions in topological order over the Call Graph. Together with the addition of devirtualizable ObjC message sends and blocks to the call graph, this gives around 6% performance improvement on several large ObjC benchmarks. llvm-svn: 170826
* [analyzer] Add blocks and ObjC messages to the call graph.Anna Zaks2012-12-211-30/+18
| | | | | | | | | | | This paves the road for constructing a better function dependency graph. If we analyze a function before the functions it calls and inlines, there is more opportunity for optimization. Note, we add call edges to the called methods that correspond to function definitions (declarations with bodies). llvm-svn: 170825
* Pass AnalyzerOptions to PathDiagnosticConsumer to make analyzer options ↵Ted Kremenek2012-12-191-5/+8
| | | | | | | | accessible there. This is plumbing needed for later functionality changes. llvm-svn: 170488
* [analyzer] Tweak the NumFunctionsAnalyzed stat so that it's more useful.Anna Zaks2012-12-171-3/+5
| | | | llvm-svn: 170362
* [analyzer] Refactor: Store visited Decls instead of CallGraphNodes.Anna Zaks2012-12-141-24/+22
| | | | llvm-svn: 170231
* [analyzer] Optimization heuristic: do not reanalyze every ObjC method asAnna Zaks2012-12-071-17/+61
| | | | | | | | | | | | | | | | | | top level. This heuristic is already turned on for non-ObjC methods (inlining-mode=noredundancy). If a method has been previously analyzed, while being inlined inside of another method, do not reanalyze it as top level. This commit applies it to ObjCMethods as well. The main caveat here is that to catch the retain release errors, we are still going to reanalyze all the ObjC methods but without inlining turned on. Gives 21% performance increase on one heavy ObjC benchmark, which suffered large performance regressions due to ObjC inlining. llvm-svn: 169639
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-15/+13
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* [analyzer] Don't run non-path-sensitive checks on system headers...Jordan Rose2012-10-101-24/+40
| | | | | | | | | | | | | | | ...but do run them on user headers. Previously, we were inconsistent here: non-path-sensitive checks on code /bodies/ were only run in the main source file, but checks on /declarations/ were run in /all/ headers. Neither of those is the behavior we want. Thanks to Sujit for pointing this out! <rdar://problem/12454226> llvm-svn: 165635
* [analyzer] Fix typo: s/HandleDeclsGallGraph/HandleDeclsCallGraph/gJordan Rose2012-10-101-3/+3
| | | | | | No functionality change. llvm-svn: 165634
* [analyzer] Do not visit ObjCMethodDecl twice in the AST checkers.Anna Zaks2012-09-291-1/+0
| | | | llvm-svn: 164869
* Make AnalyzerOptions a shared object between CompilerInvocation andTed Kremenek2012-08-311-16/+16
| | | | | | | AnalysisManager, allowing the StringMap of configuration values to be propagated. llvm-svn: 162978
* Move AnalyzerOptions.h into 'Core' StaticAnalyzer sub-library.Ted Kremenek2012-08-311-4/+4
| | | | llvm-svn: 162977
* [analyzer] Ensure that PathDiagnostics profile the same regardless of path.Jordan Rose2012-08-311-2/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | PathDiagnostics are actually profiled and uniqued independently of the path on which the bug occurred. This is used to merge diagnostics that refer to the same issue along different paths, as well as by the plist diagnostics to reference files created by the HTML diagnostics. However, there are two problems with the current implementation: 1) The bug description is included in the profile, but some PathDiagnosticConsumers prefer abbreviated descriptions and some prefer verbose descriptions. Fixed by including both descriptions in the PathDiagnostic objects and always using the verbose one in the profile. 2) The "minimal" path generation scheme provides extra information about which events came from macros that the "extensive" scheme does not. This resulted not only in different locations for the plist and HTML diagnostics, but also in diagnostics being uniqued in the plist output but not in the HTML output. Fixed by storing the "end path" location explicitly in the PathDiagnostic object, rather than trying to find the last piece of the path when the diagnostic is requested. This should hopefully finish unsticking our internal buildbot. llvm-svn: 162965
* [analyzer] Refactor the logic that determines if a functions should beAnna Zaks2012-08-301-2/+18
| | | | | | | | | | | | reanalyzed. The policy on what to reanalyze should be in AnalysisConsumer with the rest of visitation order logic. There is no reason why ExprEngine needs to pass the Visited set to CoreEngine, it can populate it itself. llvm-svn: 162957
* Rename 'VisualizeEGUbi' and 'VisualizeEGDot' to ↵Ted Kremenek2012-08-301-2/+2
| | | | | | | | 'visualizeExplodedGraphWithUbigGraph' and 'visualizeExplodedGraphWithGraphViz' respectively. llvm-svn: 162931
* Store const& to AnalyzerOptions in AnalysisManager instead of copyingTed Kremenek2012-08-301-21/+6
| | | | | | individual flags. llvm-svn: 162929
* Move AnalyzerOptions.h to include/clang/StaticAnalyzer.Ted Kremenek2012-08-301-1/+1
| | | | llvm-svn: 162928
* Move Analyses.def to include/clang/StaticAnalyzer.Ted Kremenek2012-08-301-3/+3
| | | | llvm-svn: 162927
* Add new -cc1 driver option -analyzer-config, which allows one to specifyTed Kremenek2012-08-291-4/+9
| | | | | | | | | a comma separated collection of key:value pairs (which are strings). This allows a general way to provide analyzer configuration data from the command line. No clients yet. llvm-svn: 162827
* Allow multiple PathDiagnosticConsumers to be used with a BugReporter at the ↵Ted Kremenek2012-08-161-14/+60
| | | | | | | | | | | | | | | | | | | | | | | | | | | same time. This fixes several issues: - removes egregious hack where PlistDiagnosticConsumer would forward to HTMLDiagnosticConsumer, but diagnostics wouldn't be generated consistently in the same way if PlistDiagnosticConsumer was used by itself. - emitting diagnostics to the terminal (using clang's diagnostic machinery) is no longer a special case, just another PathDiagnosticConsumer. This also magically resolved some duplicate warnings, as we now use PathDiagnosticConsumer's diagnostic pruning, which has scope for the entire translation unit, not just the scope of a BugReporter (which is limited to a particular ExprEngine). As an interesting side-effect, diagnostics emitted to the terminal also have their trailing "." stripped, just like with diagnostics emitted to plists and HTML. This required some tests to be updated, but now the tests have higher fidelity with what users will see. There are some inefficiencies in this patch. We currently generate the report graph (from the ExplodedGraph) once per PathDiagnosticConsumer, which is a bit wasteful, but that could be pulled up higher in the logic stack. There is some intended duplication, however, as we now generate different PathDiagnostics (for the same issue) for different PathDiagnosticConsumers. This is necessary to produce the diagnostics that a particular consumer expects. llvm-svn: 162028
* [analyzer] Turn -cfg-add-initializers on by default, and remove the flag.Jordan Rose2012-07-311-1/+0
| | | | llvm-svn: 161060
* [analyzer] Add a statistic for maximum CFG size and a script to summarize ↵Anna Zaks2012-07-051-0/+7
| | | | | | analyzer stats from scan-build output. llvm-svn: 159776
* Bail out the LiveVariables analysis when the CFG is very large, asTed Kremenek2012-07-021-0/+4
| | | | | | | | | we are encountering some scalability issues with memory usage. The appropriate long term fix is to make the analysis more scalable, but this will at least prevent the analyzer swapping when analyzing very large functions. llvm-svn: 159578
* Fix subtle bug in AnalysisConsumer where we would not analyze functions ↵Ted Kremenek2012-07-021-7/+9
| | | | | | | | | | | | whose parent in the call graph had been inlined but for whatever reason we did not inline some of its callees. Also, fix a related traversal bug where we meant to do a BFS of the callgraph but instead were doing a DFS. llvm-svn: 159577
* [analyzer] Cleanup for r157721.Anna Zaks2012-05-311-11/+9
| | | | | | | | | | We should lock the number of elements after the initial parsing is complete. Recursive AST visitors in AnalyzesConsumer and CallGarph can trigger lazy pch deserialization resulting in more calls to HandleTopLevelDecl and appending to the LocalTUDecls list. We should ignore those. llvm-svn: 157762
* [analyzer]Fix another occurrence of iterator invalidation (LocalTUDecls)Anna Zaks2012-05-301-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | Follow up in r155693, r155680. Prevents a hard to reproduce crash with the following stack trace: 3 libsystem_c.dylib 0x00007ff55a835050 _sigtramp + 18446744029881443184 4 clang 0x0000000106218e97 (anonymous namespace)::AnalysisConsumer::HandleTranslationUnit(clang::ASTContext&) + 519 5 clang 0x0000000105cf3002 clang::ParseAST(clang::Sema&, bool, bool) + 690 6 clang 0x00000001059a41d8 clang::ASTFrontendAction::ExecuteAction() + 312 7 clang 0x00000001059a3df7 clang::FrontendAction::Execute() + 231 8 clang 0x00000001059b0ecc clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 860 9 clang 0x000000010595e451 clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 961 10 clang 0x0000000105947f29 cc1_main(char const**, char const**, char const*, void*) + 969 11 clang 0x0000000105958259 main + 473 12 clang 0x0000000105947b34 start + 52 llvm-svn: 157721
* [analyzer] Do not walk the types for call graph construction.Anna Zaks2012-05-111-0/+1
| | | | llvm-svn: 156661
* [analyzer] Remove references to idx::TranslationUnit. Index is dead, ↵Jordy Rose2012-04-281-1/+1
| | | | | | cross-TU inlining never panned out. llvm-svn: 155751
* Use a deque instead of an ImmutableList in AnalysisConsumer to preserve the ↵Ted Kremenek2012-04-271-14/+8
| | | | | | file order that functions are visited. Should fix the buildbots. llvm-svn: 155693
* Change FunctionSummary.h's definition of SetOfDecls to be an ImmutableList ↵Ted Kremenek2012-04-271-8/+20
| | | | | | | | | | | | | instead of a mutable SmallPtrSet. While iterating over LocalTUDecls, there were cases where we could modify LocalTUDecls, which could result in invalidating an iterator and an analyzer crash. Along the way, switch some uses of std::queue to std::dequeue, which should be slightly more efficient. Unfortunately, this is a difficult case to create a test case for. llvm-svn: 155680
* Remove the unused, unmaintained, incomplete 'Index' library.Douglas Gregor2012-04-131-1/+0
| | | | llvm-svn: 154672
* [analyzer] PCH deserialization optimization.Anna Zaks2012-04-121-19/+67
| | | | | | | | | | | | | | | | We should not deserialize unused declarations from the PCH file. Achieve this by storing the top level declarations during parsing (HandleTopLevelDecl ASTConsumer callback) and analyzing/building a call graph only for those. Tested the patch on a sample ObjC file that uses PCH. With the patch, the analyzes is 17.5% faster and clang consumes 40% less memory. Got about 10% overall build/analyzes time decrease on a large Objective C project. A bit of CallGraph refactoring/cleanup as well.. llvm-svn: 154625
* [analyzer] Move stats calculation out of AnalysisConsumer destructor.Anna Zaks2012-04-051-7/+8
| | | | | | | The ASTConsumer does not get deleted with clang --analyze (for performance reasons), we still want the diagnostics to work. llvm-svn: 154078
* [analyzer] Record the basic blocks covered by the analyzes run.Anna Zaks2012-04-031-0/+10
| | | | | | | | Store this info inside the function summary generated for all analyzed functions. This is useful for coverage stats and can be helpful for analyzer state space search strategies. llvm-svn: 153923
* [analyzer] Do not inline functions which previously reached max blockAnna Zaks2012-03-301-1/+5
| | | | | | | | | | | | | | | count. This is an optimization for "retry without inlining" option. Here, if we failed to inline a function due to reaching the basic block max count, we are going to store this information and not try to inline it again in the translation unit. This can be viewed as a function summary. On sqlite, with this optimization, we are 30% faster then before and cover 10% more basic blocks (partially because the number of times we reach timeout is decreased by 20%). llvm-svn: 153730
* [analyzer] Enable retry exhausted without inlining by default.Anna Zaks2012-03-281-1/+1
| | | | llvm-svn: 153591
* [analyzer] Add an option to re-analyze a dead-end path without inlining.Anna Zaks2012-03-271-1/+2
| | | | | | | | | | | | | | | | | | | | | The analyzer gives up path exploration under certain conditions. For example, when the same basic block has been visited more than 4 times. With inlining turned on, this could lead to decrease in code coverage. Specifically, if we give up inside the inlined function, the rest of parent's basic blocks will not get analyzed. This commit introduces an option to enable re-run along the failed path, in which we do not inline the last inlined call site. This is done by enqueueing the node before the processing of the inlined call site with a special policy encoded in the state. The policy tells us not to inline the call site along the path. This lead to ~10% increase in the number of paths analyzed. Even though we expected a much greater coverage improvement. The option is turned off by default for now. llvm-svn: 153534
* [analyzer] Stats: Only count the number of times we run path sensitiveAnna Zaks2012-03-271-2/+3
| | | | | | | | analyzes. (This method can be called twice on the same function.) llvm-svn: 153531
* [analyzer] Change the order in which we analyze the functions underAnna Zaks2012-03-131-7/+11
| | | | | | | | | | | inlining to be the reverse of their declaration. This optimizes running time under inlining up to 20% since we do not re-analyze the utility functions which are usually defined first in the translation unit if they have already been analyzed while inlined into the root functions. llvm-svn: 152653
* [analyzer] Use BFS over call graph when analysing functions.Anna Zaks2012-03-131-22/+38
| | | | | | | | | | | BFS should give slightly better performance. Ex: Suppose, we have two roots R1 and R2. A callee function C is reachable through both. However, C is not inlined when analyzing R1 due to inline stack depth limit. With DFS, C will be analyzed as top level even though it would be analyzed as inlined through R2. On the other hand, BFS could avoid analyzing C as top level. llvm-svn: 152652
* [analyzer] Refactor CallGraph to use Recursive AST visitor whenAnna Zaks2012-03-131-6/+5
| | | | | | collecting function Decls. llvm-svn: 152651
* [analyzer] Use recursive AST visitor to drive simple visitation order inAnna Zaks2012-03-131-106/+95
| | | | | | | | | | | | | AnalysisConsumer. As a result: - We now analyze the C++ methods which are defined within the class body. These were completely skipped before. - Ensure that AST checkers are called on functions in the order they are defined in the Translation unit. llvm-svn: 152650
* [analyzer] Minor: factor out logic for determining if we should skip aAnna Zaks2012-03-131-4/+13
| | | | | | function. llvm-svn: 152649
* [analyzer] Move the check for parser errors out of the loop over Decls.Anna Zaks2012-03-131-5/+5
| | | | llvm-svn: 152648
* Unify naming of LangOptions variable/get function across the Clang stack ↵David Blaikie2012-03-111-3/+3
| | | | | | | | | | (Lex to AST). The member variable is always "LangOpts" and the member function is always "getLangOpts". Reviewed by Chris Lattner llvm-svn: 152536
* [analyzer] Add support for NoRedundancy inlining mode.Anna Zaks2012-03-091-28/+42
| | | | | | | | | | | We do not reanalyze a function, which has already been analyzed as an inlined callee. As per PRELIMINARY testing, this gives over 50% run time reduction on some benchmarks without decreasing of the number of bugs found. Turning the mode on by default. llvm-svn: 152440
OpenPOWER on IntegriCloud