summaryrefslogtreecommitdiffstats
path: root/clang/lib/Analysis
Commit message (Collapse)AuthorAgeFilesLines
...
* [C++11] Convert sort predicates into lambdas.Benjamin Kramer2014-03-072-24/+15
| | | | | | No functionality change. llvm-svn: 203289
* [-Wunreachable-code] Treat constant globals as configuration values in ↵Ted Kremenek2014-03-071-2/+14
| | | | | | | | | unreachable code heuristics. This one could possibly be refined even further; e.g. looking at the initializer and see if it is truly a configuration value. llvm-svn: 203283
* Replace OwningPtr with std::unique_ptr.Ahmed Charles2014-03-072-3/+4
| | | | | | This compiles cleanly with lldb/lld/clang-tools-extra/llvm. llvm-svn: 203279
* [C++11] Replacing DeclBase iterators decls_begin() and decls_end() with ↵Aaron Ballman2014-03-071-3/+2
| | | | | | iterator_range decls(). The same is true for the noload versions of these APIs. Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203278
* Change OwningPtr::take() to OwningPtr::release().Ahmed Charles2014-03-072-3/+3
| | | | | | This is a precursor to moving to std::unique_ptr. llvm-svn: 203275
* [C++11] Replacing FunctionDecl iterators param_begin() and param_end() with ↵Aaron Ballman2014-03-071-3/+2
| | | | | | iterator_range params(). Updating all of the usages of the iterators with range-based for loops. llvm-svn: 203248
* Fix recent regressions in -Wreturn-type caused by heuristics to ↵Ted Kremenek2014-03-071-248/+274
| | | | | | | | | | | | | | | | | -Wunreachable-code. I had forgotten that the same reachability code is used by both -Wreturn-type and -Wunreachable-code, so the heuristics applied to the latter were indirectly impacting the former. To address this, the reachability code is more refactored so that whiled the logic at its core is shared, the intention of the clients are better captured and segregated in helper APIs. Fixes PR19074, and also some false positives reported offline to me by Nick Lewycky. llvm-svn: 203209
* [-Wunreachable-code] Correctly expand artificial reachability to pruned '&&' ↵Ted Kremenek2014-03-072-10/+18
| | | | | | and '||' branches involving configuration values. llvm-svn: 203194
* [-Wunreachable-code] Teach reachable code analysis heuristics about more ↵Ted Kremenek2014-03-071-0/+2
| | | | | | literal types. llvm-svn: 203193
* Based on usage, the NamedDecl is always set when constructing a ↵Aaron Ballman2014-03-061-6/+3
| | | | | | | | CallingContext, but none of the other optional parameters are. Removing the optional parameters, and making the NamedDecl required. No functional changes intended. llvm-svn: 203149
* Refactored to use a simple helper function that wraps the logic of creating ↵Aaron Ballman2014-03-061-26/+18
| | | | | | | | an SExprNode and returning the position in which it was inserted. No functional change intended. llvm-svn: 203148
* Very minor simplification and typo correction; no functional changes intended.Aaron Ballman2014-03-061-14/+3
| | | | llvm-svn: 203144
* [-Wunreachable-code] Refine treating all branches of 'switch' as reachable, ↵Ted Kremenek2014-03-061-18/+4
| | | | | | which includes those with all cases covered but with no 'default:'. llvm-svn: 203094
* [-Wunreachable-code] don't warn about dead 'return <string literal>' ↵Ted Kremenek2014-03-061-2/+52
| | | | | | | | | | | | | dominated by a 'noreturn' call, where literal becomes an std::string. I have mixed feelings about this one. It's used all over the codebase, and is analogous to the current heuristic for ordinary C string literals. This requires some ad hoc pattern matching of the AST. While the test case mirrors what we see std::string in libc++, it's not really testing the libc++ headers. llvm-svn: 203091
* [-Wunreachable-code] Handle idiomatic do...while() with an uninteresting ↵Ted Kremenek2014-03-061-7/+4
| | | | | | | | | | condition. Sometimes do..while() is used to create a scope that can be left early. In such cases, the unreachable 'while()' test is not usually interesting unless it actually does something that is observable. llvm-svn: 203051
* [-Wunreachable-code] Handle idiomatic do...while() with an uninteresting ↵Ted Kremenek2014-03-061-7/+17
| | | | | | | | | | condition. Sometimes do..while() is used to create a scope that can be left early. In such cases, the unreachable 'while()' test is not usually interesting unless it actually does something that is observable. llvm-svn: 203036
* [-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
OpenPOWER on IntegriCloud