summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
* [CallGraph] Make sure the edges are not missed due to re-declarationsAnna Zaks2014-12-171-8/+5
| | | | | | | | | | | | | | A patch by Daniel DeFreez! We were previously dropping edges on re-declarations. Store the canonical declarations in the graph to ensure that different references to the same function end up reflected with the same call graph node. (Note, this might lead to performance fluctuation because call graph is used to determine the function analysis order.) llvm-svn: 224398
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-1/+1
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* When checking for uninitialized values, do not confuse "std::move" with everyRichard Trieu2014-11-271-1/+2
| | | | | | other function named "move". llvm-svn: 222863
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-1/+1
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Thread Safety Analysis: move warnings on range-based for loops out of betaDeLesley Hutchins2014-11-051-11/+9
| | | | | | and into -Wthread-safety. llvm-svn: 221410
* Remove unused member variable.Craig Topper2014-10-211-1/+0
| | | | llvm-svn: 220264
* [Analysis] Add missing newlines at end of file.Daniel Dunbar2014-10-091-1/+1
| | | | llvm-svn: 219439
* Reverting r214064 and r215650 while investigating a pesky performance regressionArtyom Skrobov2014-09-236-143/+134
| | | | llvm-svn: 218296
* Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, whichDeLesley Hutchins2014-09-181-16/+68
| | | | | | | | warns when a guarded variable is passed by reference as a function argument. This is released as a separate warning flag, because it could potentially break existing code that uses thread safety analysis. llvm-svn: 218087
* Fixing a -Woverflow warning from GCC by using a more natural datatype for ↵Aaron Ballman2014-09-121-2/+2
| | | | | | this operation. NFC. llvm-svn: 217670
* Fix a couple of -Wsign-compare warnings introduced in r217556Justin Bogner2014-09-111-3/+2
| | | | llvm-svn: 217569
* Thread Safety Analysis: major update to thread safety TIL.DeLesley Hutchins2014-09-102-99/+252
| | | | | | | | | | | | Numerous changes, including: * Changed the way variables and instructions are handled in basic blocks to be more efficient. * Eliminated SExprRef. * Simplified futures. * Fixed documentation. * Compute dominator and post dominator trees. llvm-svn: 217556
* Objective-C. Under a special flag, -Wcstring-format-directive,Fariborz Jahanian2014-09-091-9/+45
| | | | | | | | off by default, issue a warning if %s directive is used in certain CF/NS formatting APIs, to assist user in deprecating use of such %s in these APIs. rdar://18182443 llvm-svn: 217467
* MS format strings: parse the 'Z' printf conversion specifier (PR20808)Hans Wennborg2014-09-072-2/+13
| | | | llvm-svn: 217326
* MS format strings: allow the 'h' length modifier with C, C, s and S (PR20808)Hans Wennborg2014-09-043-2/+30
| | | | llvm-svn: 217196
* MS format strings: support the 'w' length modifier (PR20808)Hans Wennborg2014-09-043-0/+26
| | | | llvm-svn: 217195
* Allow a scoped lockable object to acquire/release multiple locks.Ed Schouten2014-09-031-125/+162
| | | | | | | | | | | | | | | | | Scoped lockable objects (mutex guards) are implemented as if it is a lock itself that is acquired upon construction and unlocked upon destruction. As it if course needs to be used to actually lock down something else (a mutex), it keeps track of this knowledge through its underlying mutex field in its FactEntry. The problem with this approach is that this only allows us to lock down a single mutex, so extend the code to use a vector of underlying mutexes. This, however, makes the code a bit more complex than necessary, so subclass FactEntry into LockableFactEntry and ScopedLockableFactEntry and move all the logic that differs between regular locks and scoped lockables into member functions. llvm-svn: 217016
* Add a comment, no functional change.Nico Weber2014-08-291-1/+1
| | | | llvm-svn: 216777
* unique_ptrify the result of CFG::buildCFG/CFGBuilder::buildCFGDavid Blaikie2014-08-292-11/+9
| | | | llvm-svn: 216755
* More -Wuninitialized updatesRichard Trieu2014-08-271-3/+18
| | | | | | | | | | | Fix r216438 to catch more complicated self-initialized in std::move. For instance, "Foo f = std::move(cond ? OtherFoo : (UNUSED_VALUE, f));" Make sure that BinaryConditionalOperator, ConditionalOperator, BinaryOperator with comma operator, and OpaqueValueExpr perform the correct usage forwarding across the three uninitialized value checkers. llvm-svn: 216627
* Add support for the static analyzer to synthesize function implementations ↵Ted Kremenek2014-08-275-7/+35
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | from external model files. Currently the analyzer lazily models some functions using 'BodyFarm', which constructs a fake function implementation that the analyzer can simulate that approximates the semantics of the function when it is called. BodyFarm does this by constructing the AST for such definitions on-the-fly. One strength of BodyFarm is that all symbols and types referenced by synthesized function bodies are contextual adapted to the containing translation unit. The downside is that these ASTs are hardcoded in Clang's own source code. A more scalable model is to allow these models to be defined as source code in separate "model" files and have the analyzer use those definitions lazily when a function body is needed. Among other things, it will allow more customization of the analyzer for specific APIs and platforms. This patch provides the initial infrastructure for this feature. It extends BodyFarm to use an abstract API 'CodeInjector' that can be used to synthesize function bodies. That 'CodeInjector' is implemented using a new 'ModelInjector' in libFrontend, which lazily parses a model file and injects the ASTs into the current translation unit. Models are currently found by specifying a 'model-path' as an analyzer option; if no path is specified the CodeInjector is not used, thus defaulting to the current behavior in the analyzer. Models currently contain a single function definition, and can be found by finding the file <function name>.model. This is an initial starting point for something more rich, but it bootstraps this feature for future evolution. This patch was contributed by Gábor Horváth as part of his Google Summer of Code project. Some notes: - This introduces the notion of a "model file" into FrontendAction and the Preprocessor. This nomenclature is specific to the static analyzer, but possibly could be generalized. Essentially these are sources pulled in exogenously from the principal translation. Preprocessor gets a 'InitializeForModelFile' and 'FinalizeForModelFile' which could possibly be hoisted out of Preprocessor if Preprocessor exposed a new API to change the PragmaHandlers and some other internal pieces. This can be revisited. FrontendAction gets a 'isModelParsingAction()' predicate function used to allow a new FrontendAction to recycle the Preprocessor and ASTContext. This name could probably be made something more general (i.e., not tied to 'model files') at the expense of losing the intent of why it exists. This can be revisited. - This is a moderate sized patch; it has gone through some amount of offline code review. Most of the changes to the non-analyzer parts are fairly small, and would make little sense without the analyzer changes. - Most of the analyzer changes are plumbing, with the interesting behavior being introduced by ModelInjector.cpp and ModelConsumer.cpp. - The new functionality introduced by this change is off-by-default. It requires an analyzer config option to enable. llvm-svn: 216550
* Simplify creation of a bunch of ArrayRefs by using None, makeArrayRef or ↵Craig Topper2014-08-271-5/+3
| | | | | | just letting them be implicitly created. llvm-svn: 216528
* Passing a variable to std::move now counts as a use for -WuninitializedRichard Trieu2014-08-261-0/+10
| | | | llvm-svn: 216438
* Adding const-qualifiers to auto declarations. NFC.Aaron Ballman2014-08-151-3/+3
| | | | llvm-svn: 215704
* Thread safety analysis: add -Wthread-safety-verbose flag, which adds ↵DeLesley Hutchins2014-08-141-0/+5
| | | | | | additional notes that are helpful when compiling statistics on thread safety warnings. llvm-svn: 215677
* Thread Safety Analysis: fix to improve handling of references to guardedDeLesley Hutchins2014-08-141-20/+34
| | | | | | data members and range based for loops. llvm-svn: 215671
* Use the proper post-order traversal in LiveVariables analysis,Artyom Skrobov2014-08-145-39/+69
| | | | | | | | | | | | | | | | to recover the performance after r214064. Also sorts out the naming for PostOrderCFGView, ReversePostOrderCFGView, BackwardDataflowWorklist and ForwardDataflowWorklist, to match the accepted terminology. Also unifies BackwardDataflowWorklist and ForwardDataflowWorklist to share the "worklist for prioritization, post-order traversal for fallback" logic, and to avoid repetitive sorting. Also cleans up comments in the affected area. llvm-svn: 215650
* Header guard canonicalization, clang part.Benjamin Kramer2014-08-132-4/+4
| | | | | | Modifications made by clang-tidy with minor tweaks. llvm-svn: 215557
* clangAnalysis: Avoid member initializers in TempDtorContext to appease msc17.NAKAMURA Takumi2014-08-081-5/+8
| | | | llvm-svn: 215193
* Fix branch reachabiliy annotation for temp dtor branches.Manuel Klimek2014-08-081-21/+29
| | | | | | | | | As we only create temp dtor decision branches when a temp dtor needs to be run (as opposed to for each logical branch in the original expression), we must include the information about all previous logical branches when we annotate the temp dtor decision branch. llvm-svn: 215188
* Mark successors as reachable/unreachable instead of changing the CFG.Manuel Klimek2014-08-071-32/+19
| | | | | | As suggested by Ted, this makes a few warnings less aggressive. llvm-svn: 215128
* Fix CFG for temporary dtors when the branch taken is known.Manuel Klimek2014-08-071-14/+18
| | | | | | | Use the parent context when visiting temporaries when we do not insert a temporary dtor decision branch. llvm-svn: 215120
* Model temporary destructors from logical operators with known values.Manuel Klimek2014-08-071-4/+15
| | | | | | | | If the truth value of a LHS is known, we can build the knowledge whether a temporary destructor is executed or not into the CFG. This is needed by the return type analysis. llvm-svn: 215118
* Only have one path in the CFG for ternaries if the condition is known.Manuel Klimek2014-08-071-2/+11
| | | | | | | The return type analysis requires that the CFG is simplified when the truth values of branches are statically known at analysis time. llvm-svn: 215114
* Re-applying r214962.Manuel Klimek2014-08-071-137/+160
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Changes to the original patch: - model the CFG for temporary destructors in conditional operators so that the destructors of the true and false branch are always exclusive. This is necessary because we must not have impossible paths for the path based analysis to work. - add multiple regression tests with ternary operators Original description: Fix modelling of non-lifetime-extended temporary destructors in the analyzer. Changes to the CFG: When creating the CFG for temporary destructors, we create a structure that mirrors the branch structure of the conditionally executed temporary constructors in a full expression. The branches we create use a CXXBindTemporaryExpr as terminator which corresponds to the temporary constructor which must have been executed to enter the destruction branch. 2. Changes to the Analyzer: When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as executed in the state; when we reach a branch that contains the corresponding CXXBindTemporaryExpr as terminator, we branch out depending on whether the corresponding CXXBindTemporaryExpr was marked as executed. llvm-svn: 215096
* Revert "Fix modelling of non-lifetime-extended temporary destructors in the ↵Rui Ueyama2014-08-061-146/+139
| | | | | | | | | | | | | | | | | | | | analyzer." This reverts commit r214962 because after the change the following code doesn't compile with -Wreturn-type -Werror. #include <cstdlib> class NoReturn { public: ~NoReturn() __attribute__((noreturn)) { exit(1); } }; int check() { true ? NoReturn() : NoReturn(); } llvm-svn: 214998
* Fix modelling of non-lifetime-extended temporary destructors in the analyzer.Manuel Klimek2014-08-061-139/+146
| | | | | | | | | | | | | | | | | | | 1. Changes to the CFG: When creating the CFG for temporary destructors, we create a structure that mirrors the branch structure of the conditionally executed temporary constructors in a full expression. The branches we create use a CXXBindTemporaryExpr as terminator which corresponds to the temporary constructor which must have been executed to enter the destruction branch. 2. Changes to the Analyzer: When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as executed in the state; when we reach a branch that contains the corresponding CXXBindTemporaryExpr as terminator, we branch out depending on whether the corresponding CXXBindTemporaryExpr was marked as executed. llvm-svn: 214962
* ThreadSafety.cpp: Prune bogus \param(s). [-Wdocumentation]NAKAMURA Takumi2014-08-041-3/+0
| | | | llvm-svn: 214796
* ThreadSafetyAnalysis: Fix annotations in class members. [-Wdocumentation]NAKAMURA Takumi2014-08-041-5/+5
| | | | llvm-svn: 214795
* Thread Safety Analysis: add a -Wthread-safety-negative flag that warns wheneverDeLesley Hutchins2014-08-041-32/+70
| | | | | | | a mutex is acquired, but corresponding mutex is not provably not-held. This is based on the earlier negative requirements patch. llvm-svn: 214789
* Thread safety analysis: Add support for negative requirements, which areDeLesley Hutchins2014-08-042-280/+267
| | | | | | | capability expressions of the form !expr, and denote a capability that must not be held. llvm-svn: 214725
* Fix some cases of incorrect handling of lifetime extended temporaries.Manuel Klimek2014-07-301-11/+23
| | | | | | | | MaterializeTemporaryExpr already contains information about the lifetime of the temporary; if the lifetime is not the full statement, we do not want to emit a destructor at the end of the full statement for it. llvm-svn: 214292
* Thread Safety Analysis: Replace the old and broken SExpr with the newDeLesley Hutchins2014-07-283-759/+419
| | | | | | | | til::SExpr. This is a large patch, with many small changes to pretty printing and expression lowering to make the new SExpr representation equivalent in functionality to the old. llvm-svn: 214089
* Factoring DataflowWorklist out of LiveVariables and UninitializedValues analysesArtyom Skrobov2014-07-284-117/+96
| | | | llvm-svn: 214064
* When looking for temporary dtors while building the CFG, do not walk intoRichard Smith2014-07-271-1/+26
| | | | | | | | | | lambda expressions (other than their capture initializers) nor blocks. Do walk into default argument expressions and default initializer expressions. These bugs were causing us to produce broken CFGs whenever a lambda expression was used to initialize a libstdc++ std::function object! llvm-svn: 214050
* Prune Redundant libdeps in CMake's target_link_libraries and LLVMBuild.txt.NAKAMURA Takumi2014-07-151-1/+0
| | | | | | I checked this with Release+Asserts on x86_64-mingw32. Please restore partially if this were overkill. llvm-svn: 213064
* [CMake] Update libdeps.NAKAMURA Takumi2014-07-141-0/+1
| | | | llvm-svn: 212920
* [CMake] Reorder libdeps by alphabetical order.NAKAMURA Takumi2014-07-141-1/+1
| | | | llvm-svn: 212919
* Fix a crash in Retain Count checker error reportingAnna Zaks2014-06-131-0/+4
| | | | | | | | | Fixes a crash in Retain Count checker error reporting logic by handing the allocation statement retrieval from a BlockEdge program point. Also added a simple CFG dump routine for debugging. llvm-svn: 210960
* PR19996: don't crash if -Wuninitialized sees a c++1y lambda init-capture.Richard Smith2014-06-111-1/+1
| | | | llvm-svn: 210615
OpenPOWER on IntegriCloud