summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* [-Wunreachable-code] generalize pruning out warning on trivial returns.Ted Kremenek2014-03-051-9/+6
| | | | | | | | Previously we only pruned dead returns preceded by a call to a 'noreturn' function. After looking at the results of the LLVM codebase, there are many others that should be pruned as well. llvm-svn: 203029
* [-Wunreachable-code] include some enum constants in "configuration value" ↵Ted Kremenek2014-03-051-0/+5
| | | | | | heuristic llvm-svn: 203026
* [-Wunreachable-code] generalize configuration value checking to all ↵Ted Kremenek2014-03-051-1/+1
| | | | | | comparison operators. llvm-svn: 203016
* [-Wunreachable-code] Don't warn about dead code guarded by a "configuration ↵Ted Kremenek2014-03-051-9/+73
| | | | | | | | | | | | | | | value". Some unreachable code is only "sometimes unreachable" because it is guarded by a configuration value that is determined at compile time and is always constant. Sometimes those represent real bugs, but often they do not. This patch causes the reachability analysis to cover such branches even if they are technically unreachable in the CFG itself. There are some conservative heuristics at play here to determine a "configuration value"; these are intended to be refined over time. llvm-svn: 202912
* Remove some unnecessary qualificationDavid Blaikie2014-03-041-2/+2
| | | | llvm-svn: 202909
* [CFG] Tweak "?:" CFG construction to record the unreachable blocks.Ted Kremenek2014-03-041-4/+5
| | | | llvm-svn: 202898
* [-Wunreachable-code] handle cases where a dead 'return' may have a valid ↵Ted Kremenek2014-03-041-0/+5
| | | | | | | | predecessor. Fies PR19040. llvm-svn: 202892
* [C++11] Replace llvm::tie with std::tie.Benjamin Kramer2014-03-022-6/+5
| | | | llvm-svn: 202639
* [-Wunreachable-code] always treat 'case:' and 'default:' cases as reachable.Ted Kremenek2014-02-271-8/+27
| | | | | | | | | | | This is a heuristic. Many switch statements, although they look covered over an enum, may actually handle at runtime more values than in the enum. This is overly conservative, as there are some cases that clearly can be ruled as being clearly unreachable, e.g. 'switch (42) { case 1: ... }'. We can refine this later. llvm-svn: 202436
* [CFG] record the original (now unreachable) block of 'case:' and 'default:' ↵Ted Kremenek2014-02-271-10/+21
| | | | | | cases. llvm-svn: 202435
* [-Wunreachable-code] Don't warn about trivially unreachable return ↵Ted Kremenek2014-02-271-4/+57
| | | | | | statements preceded by 'noreturn' functions. llvm-svn: 202352
* [-Wunreachable-code] Don't warn about unreachable 'default:' cases.Ted Kremenek2014-02-271-0/+6
| | | | | | They are covered by -Wcovered-switch-default. llvm-svn: 202349
* [-Wunreachable-code] Prune out unreachable warnings where a 'break' is ↵Ted Kremenek2014-02-271-7/+43
| | | | | | | | | | | | | | | preceded by a call to a 'noreturn' function. For example: unreachable(); break; This code is idiomatic and defensive. The fact that 'break' is unreachable here is not interesting. This occurs frequently in LLVM/Clang itself. llvm-svn: 202328
* [CFG] encode unreachable block information for would-have-been successors ↵Ted Kremenek2014-02-271-1/+1
| | | | | | for calls to 'noreturn' functions. llvm-svn: 202327
* [CFG] Encode unreachable block information for successors when visiting 'if' ↵Ted Kremenek2014-02-271-3/+4
| | | | | | statements. llvm-svn: 202326
* Rework CFG edges to encode potentially unreachable edges, instead of just ↵Ted Kremenek2014-02-273-6/+53
| | | | | | | | | | | | | | | | | | | | | | | | | | making them NULL. This is to support some analyses, like -Wunreachable-code, that will need to recover the original unprunned CFG edges in order to suppress issues that aren't really bugs in practice. There are two important changes here: - AdjacentBlock replaces CFGBlock* for CFG successors/predecessors. This has the size of 2 pointers, instead of 1. This is unlikely to have a significant memory impact on Sema since a single CFG usually exists at one time, but could impact the memory usage of the static analyzer. This could possibly be optimized down to a single pointer with some cleverness. - Predecessors can now contain null predecessors, which means some analyses doing a reverse traversal will need to take into account. This already exists for successors, which contain successor slots for specific branch kinds (e.g., 'if') that expect a fixed number of successors, even if a branch is not reachable. llvm-svn: 202325
* [CMake] Use LINK_LIBS instead of target_link_libraries().NAKAMURA Takumi2014-02-261-2/+1
| | | | llvm-svn: 202238
* [CMake] Get rid of explicit dependencies to include/clang/*.inc and ↵NAKAMURA Takumi2014-02-211-10/+0
| | | | | | | | | | | | | | | | | | | introduce CLANG_TABLEGEN_TARGETS. This does; - clang_tablegen() adds each tblgen'd target to global property CLANG_TABLEGEN_TARGETS as list. - List of targets is added to LLVM_COMMON_DEPENDS. - all clang libraries and targets depend on generated headers. You might wonder this would be regression, but in fact, this is little loss. - Almost all of clang libraries depend on tblgen'd files and clang-tblgen. - clang-tblgen may cause short stall-out but doesn't cause unconditional rebuild. - Each library's dependencies to tblgen'd files might vary along headers' structure. It made hard to track and update *really optimal* dependencies. Each dependency to intrinsics_gen and ClangSACheckers is left as DEPENDS. llvm-svn: 201842
* Use llvm::DeleteContainerSeconds when possibleReid Kleckner2014-02-192-13/+4
| | | | llvm-svn: 201739
* DeLesley Hutchins (who wrote the original thread-safety attribute ↵Aaron Ballman2014-02-181-19/+8
| | | | | | | | | | | | | | | functionality) and I have agreed to start migrating from lock-specific terminology to "capability"-specific terminology. This opens the door for future threading-related analysis passes so that a common nomenclature can be used. The following attributes have been (silently) deprecated, with their replacements listed: lockable => capability exclusive_locks_required => requires_capability shared_locks_required => requires_shared_capability locks_excluded => requires_capability There are no functional changes intended. llvm-svn: 201585
* [analyzer] Improved checker naming in CFG dump.Anton Yartsev2014-02-171-3/+4
| | | | | | This implements FIXME from Checker.cpp (FIXME: We want to return the package + name of the checker here.) and replaces hardcoded checker names with the new ones obtained via getCheckName().getName(). llvm-svn: 201525
* Rename getResultType() on function and method declarations to getReturnType()Alp Toker2014-01-251-3/+3
| | | | | | | | | | | | | | | A return type is the declared or deduced part of the function type specified in the declaration. A result type is the (potentially adjusted) type of the value of an expression that calls the function. Rule of thumb: * Declarations have return types and parameters. * Expressions have result types and arguments. llvm-svn: 200082
* [analyzer] Tighten up sanity checks on Objective-C property getter synthesis.Jordan Rose2014-01-232-6/+23
| | | | | | | | | | | If there are non-trivially-copyable types /other/ than C++ records, we won't have a synthesized copy expression, but we can't just use a simple load/return. Also, add comments and shore up tests, making sure to test in both ARC and non-ARC. llvm-svn: 199869
* Rename FunctionProtoType accessors from 'arguments' to 'parameters'Alp Toker2014-01-201-2/+1
| | | | | | | | | | | | | | | | | Fix a perennial source of confusion in the clang type system: Declarations and function prototypes have parameters to which arguments are supplied, so calling these 'arguments' was a stretch even in C mode, let alone C++ where default arguments, templates and overloading make the distinction important to get right. Readability win across the board, especially in the casting, ADL and overloading implementations which make a lot more sense at a glance now. Will keep an eye on the builders and update dependent projects shortly. No functional change. llvm-svn: 199686
* Consumed analysis: bugfix for operator calls. Also fixes some formattingDeLesley Hutchins2014-01-161-16/+12
| | | | | | issues, a few testcases, and kills fish. llvm-svn: 199436
* CFG: use Visit instead of VisitStmt to look through parens.Jordan Rose2014-01-141-3/+4
| | | | | | PR18472 llvm-svn: 199227
* [analyzer] Use synthesized ASTs for property getters when available.Jordan Rose2014-01-141-6/+18
| | | | | | | This allows the analyzer to handle properties with C++ class type, finishing up the FIXME from r198953. llvm-svn: 199226
* Consumed analysis: add two new attributes which fine-tune the behavior ofDeLesley Hutchins2014-01-141-221/+222
| | | | | | | | consumable objects. These are useful for implementing error codes that must be checked. Patch also includes some significant refactoring, which was necesary to implement the new behavior. llvm-svn: 199169
* [analyzer] Add a CFG node for the allocator call in a C++ 'new' expression.Jordan Rose2014-01-132-1/+32
| | | | | | | | | | | | | | | | | | | | | | | | | | In an expression like "new (a, b) Foo(x, y)", two things happen: - Memory is allocated by calling a function named 'operator new'. - The memory is initialized using the constructor for 'Foo'. Currently the analyzer only models the second event, though it has special cases for both the default and placement forms of operator new. This patch is the first step towards properly modeling both events: it changes the CFG so that the above expression now generates the following elements. 1. a 2. b 3. (CFGNewAllocator) 4. x 5. y 6. Foo::Foo The analyzer currently ignores the CFGNewAllocator element, but the next step is to treat that as a call like any other. The CFGNewAllocator element is not added to the CFG for analysis-based warnings, since none of them take advantage of it yet. llvm-svn: 199123
* [analyzer] Model getters of known-@synthesized Objective-C properties.Jordan Rose2014-01-103-6/+88
| | | | | | | | | | | | | | | | | | | | | ...by synthesizing their body to be "return self->_prop;", with an extra nudge to RetainCountChecker to still treat the value as +0 if we have no other information. This doesn't handle weak properties, but that's mostly correct anyway, since they can go to nil at any time. This also doesn't apply to properties whose implementations we can't see, since they may not be backed by an ivar at all. And finally, this doesn't handle properties of C++ class type, because we can't invoke the copy constructor. (Sema has actually done this work already, but the AST it synthesizes is one the analyzer doesn't quite handle -- it has an rvalue DeclRefExpr.) Modeling setters is likely to be more difficult (since it requires handling strong/copy), but not impossible. <rdar://problem/11956898> llvm-svn: 198953
* Sort all the #include lines with LLVM's utils/sort_includes.py whichChandler Carruth2014-01-072-3/+3
| | | | | | | encodes the canonical rules for LLVM's style. I noticed this had drifted quite a bit when cleaning up LLVM, so wanted to clean up Clang as well. llvm-svn: 198686
* Only mark dump() function definitions 'used' in debug buildsAlp Toker2014-01-041-1/+1
| | | | | | | | | | | | | | | | This has the dual effect of (1) enabling more dead-stripping in release builds and (2) ensuring that debug helper functions aren't stripped away in debug builds, as they're intended to be called from the debugger. Note that the attribute is applied to definitions rather than declarations in headers going forward because it's now conditional on NDEBUG: /// \brief Mark debug helper function definitions like dump() that should not be /// stripped from debug builds. Requires corresponding macro added in LLVM r198456. llvm-svn: 198489
* Switching getAttrs calls over to using a specific_attr_iterator. No ↵Aaron Ballman2013-12-191-8/+8
| | | | | | functional changes intended. llvm-svn: 197681
* Switched code from using hasAttr followed by getAttr to simply call getAttr ↵Aaron Ballman2013-12-191-74/+43
| | | | | | | | directly and check the resulting value. Also fixes some minor formatting issues surrounding the getAttr code. No functional changes intended. llvm-svn: 197649
* Replacing calls to getAttr with calls to hasAttr for clarity. No functional ↵Aaron Ballman2013-12-191-4/+4
| | | | | | change intended -- this only replaces Boolean uses of getAttr. llvm-svn: 197648
* For -Wconsumed, walk the namespaces to find if the top most namespace is "std"Richard Trieu2013-12-171-2/+13
| | | | | | | to determine if a move function is the std::move function. This allows functions like std::__1::move to also be treated a the move function. llvm-svn: 197445
* Fix PR18260 - Make std::move handling in -Wconsumed only trigger on std::moveRichard Trieu2013-12-161-1/+2
| | | | llvm-svn: 197428
* Add CFG tests for switch's involving "extended" enum.Ted Kremenek2013-12-111-1/+3
| | | | llvm-svn: 197094
* [CMake] clang/lib: Satisfy dependencies to add *actually used* libraries on ↵NAKAMURA Takumi2013-12-091-0/+5
| | | | | | | | target_link_libraries() and LLVM_LINK_COMPONENTS. I will prune redundant dependencies later. llvm-svn: 196800
* Revert "[analyzer] Refactor conditional expression evaluating code"Anna Zaks2013-12-061-18/+0
| | | | | | | | | | This reverts commit r189090. The original patch introduced regressions (see the added live-variables.* tests). The patch depends on the correctness of live variable analyses, which are not computed correctly. I've opened PR18159 to track the proper resolution to this problem. The patch was a stepping block to r189746. This is why part of the patch reverts temporary destructor tests that started crashing. The temporary destructors feature is disabled by default. llvm-svn: 196593
* Fix a tranche of comment, test and doc typosAlp Toker2013-12-051-1/+1
| | | | llvm-svn: 196510
* Correct hyphenations in comments and assert messagesAlp Toker2013-12-051-1/+1
| | | | | | | This patch tries to avoid unrelated changes other than fixing a few hyphen-related ambiguities in nearby lines. llvm-svn: 196466
* Thread safety analysis: fix ICE due to missing null check on dyn_cast.DeLesley Hutchins2013-11-261-6/+9
| | | | llvm-svn: 195777
* The code using the StmtPrinterHelper object failed to account for a null ↵Aaron Ballman2013-11-181-44/+39
| | | | | | object in many cases, which could have led to crashes were it ever to be null. Now passing the object by reference instead of by pointer because it is never null in practice. No functional changes intended. llvm-svn: 195043
* Consumed analysis: track state of temporary objects.DeLesley Hutchins2013-11-161-152/+190
| | | | | | | | Earlier versions discarded the state too soon, and did not track state changes, e.g. when passing a temporary to a move constructor. Patch by chris.wailes@gmail.com; review and minor fixes by delesley. llvm-svn: 194900
* Thread-safety analysis: check guarded_by and pt_guarded_by on array access.DeLesley Hutchins2013-11-081-2/+31
| | | | | | Currently supported only with -Wthread-safety-beta. llvm-svn: 194275
* Thread safety analysis: minor bugfix to smart pointer handling, and expandedDeLesley Hutchins2013-11-061-4/+5
| | | | | | test case. llvm-svn: 194157
* Thread safety analysis: check pt_guarded_by attribute when calling -> and *DeLesley Hutchins2013-11-051-0/+8
| | | | | | on smart pointers. -Wthread-safety-beta only. llvm-svn: 194103
* Fixed bug with checking the kind of types.Chris Wailes2013-10-311-4/+8
| | | | | | | | | | | | | | The isLValueReferenceType function checks to see if the QualType's canonical type is an LValue reference, and not if the QualType itself is an LValue reference. This caused a segfault when trying to cast the QualType's Type to a LValueReference. This is now fixed by casting the result of getCanonicalType(). In addition, a test was added to isConsumableType to prevent segfaults when a type being tested by the analysis is a reference to a pointer or a pointer to a reference. llvm-svn: 193751
* Changed tests_typestate to test_typestate for consistency.Chris Wailes2013-10-291-4/+4
| | | | llvm-svn: 193648
OpenPOWER on IntegriCloud