summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/AnalysisBasedWarnings.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Move ThreadSafetyReporter into an anonymous namespace. NFC.Benjamin Kramer2015-03-191-4/+4
| | | | llvm-svn: 232723
* Move helper class into an anonymous namespace.Benjamin Kramer2015-02-161-1/+2
| | | | llvm-svn: 229404
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-031-2/+19
| | | | | | | | | | These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. This patch also replaces calls to getAttrs() with calls to attrs() throughout ThreadSafety.cpp, which fixes the earlier issue that cause assert failures. llvm-svn: 228051
* Revert "Thread Safety Analysis: add support for before/after annotations on ↵Reid Kleckner2015-02-031-19/+2
| | | | | | | | | mutexes." This reverts r227997, as well as r228009. It does not pass check-clang for me locally on Linux. llvm-svn: 228020
* Thread Safety Analysis: add support for before/after annotations on mutexes.DeLesley Hutchins2015-02-031-2/+19
| | | | | | | These checks detect potential deadlocks caused by inconsistent lock ordering. The checks are implemented under the -Wthread-safety-beta flag. llvm-svn: 227997
* Update for LLVM API change to make Small(Ptr)Set::insert return ↵David Blaikie2014-11-191-2/+2
| | | | | | pair<iterator, bool> as per the C++ standard's associative container concept. llvm-svn: 222335
* Report when a function-try-block does not return a value on all control ↵Aaron Ballman2014-10-241-36/+29
| | | | | | paths. Fixed PR14620. llvm-svn: 220557
* Adds 'override' to overriding methods. NFC.Fariborz Jahanian2014-10-011-1/+1
| | | | | | These were uncoveredby my yet undelivered patch. llvm-svn: 218774
* Thread Safety Analysis: add new warning flag, -Wthread-safety-reference, whichDeLesley Hutchins2014-09-181-1/+34
| | | | | | | | 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
* Const-correctness, return-after-else, and formatting updates. NFC.Aaron Ballman2014-08-151-12/+10
| | | | llvm-svn: 215706
* Thread safety analysis: add -Wthread-safety-verbose flag, which adds ↵DeLesley Hutchins2014-08-141-12/+60
| | | | | | additional notes that are helpful when compiling statistics on thread safety warnings. llvm-svn: 215677
* Thread Safety Analysis: add a -Wthread-safety-negative flag that warns wheneverDeLesley Hutchins2014-08-041-0/+9
| | | | | | | 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: Replace the old and broken SExpr with the newDeLesley Hutchins2014-07-281-6/+6
| | | | | | | | 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
* rewrap to 80 cols, no behavior changeNico Weber2014-07-081-2/+3
| | | | llvm-svn: 212574
* Fix "warning: fallthrough annotation does not directly precede switch label" ↵Alexander Kornienko2014-06-241-0/+3
| | | | | | | | | | | | | | | | in lambdas. Summary: This patch fixes http://llvm.org/PR17864 - "warning: fallthrough annotation does not directly precede switch label" in lambdas. Reviewers: rsmith Reviewed By: rsmith Subscribers: rnk, cfe-commits Differential Revision: http://reviews.llvm.org/D4258 llvm-svn: 211599
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-31/+21
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* [C++11] Use 'nullptr'. Sema edition.Craig Topper2014-05-261-6/+6
| | | | llvm-svn: 209613
* Add a check for tautological bitwise comparisons to -Wtautological-compare.Jordan Rose2014-05-201-0/+9
| | | | | | | | | | | This catches issues like: if ((x & 8) == 4) { ... } if ((x | 4) != 3) { ... } Patch by Anders Rönnholm! llvm-svn: 209221
* Refactoring some for loops to use range-based for loops instead. No ↵Aaron Ballman2014-05-151-84/+46
| | | | | | functional changes intended. llvm-svn: 208915
* Fix a bunch of mislayered clang/Lex includes from SemaAlp Toker2014-05-031-3/+3
| | | | llvm-svn: 207896
* Fix a bad interaction between -Wtautological-overlap-compare and delayedRichard Trieu2014-04-151-4/+11
| | | | | | diagnostics which caused delayed diagnostics on dead paths to be emitted. llvm-svn: 206232
* Add a new subgroup to -Wtautological-compare, -Wtautological-overlap-compare,Richard Trieu2014-04-051-0/+39
| | | | | | | | | | | | | | which warns on compound conditionals that always evaluate to the same value. For instance, (x > 5 && x < 3) will always be false since no value for x can satisfy both conditions. This patch also changes the CFG to use these tautological values for better branch analysis. The test for -Wunreachable-code shows how this change catches additional dead code. Patch by Anders Rönnholm. llvm-svn: 205665
* Turn off -Wmissing-noreturn warning for blocks Fariborz Jahanian2014-04-031-6/+2
| | | | | | | as there is no way to attach this attribute to the block literal. // rdar://16274746 llvm-svn: 205580
* Updating the capability attribute diagnostics to be more capability-neutral. ↵Aaron Ballman2014-04-011-35/+46
| | | | | | Instead of using terminology such as "lock", "unlock" and "locked", the new terminology is "acquire", "release" and "held". Additionally, the capability attribute's name argument is now reported as part of the diagnostic, instead of hard coding as "mutex." llvm-svn: 205359
* Improve -Wunreachable-code to provide a means to indicate code is ↵Ted Kremenek2014-03-291-1/+14
| | | | | | | | | | | | | | | | | | intentionally marked dead via if((0)). Taking a hint from -Wparentheses, use an extra '()' as a sigil that a dead condition is intentionally dead. For example: if ((0)) { dead } When this sigil is found, do not emit a dead code warning. When the analysis sees: if (0) it suggests inserting '()' as a Fix-It. llvm-svn: 205069
* The release_capability, release_shared_capability and ↵Aaron Ballman2014-03-211-1/+9
| | | | | | release_generic_capability functions are now functionally distinct for capability analysis. The unlock_function attribute maps directly to release_generic_capability. llvm-svn: 204469
* [-Wunreachable-code] add a specialized diagnostic for unreachable increment ↵Ted Kremenek2014-03-211-1/+5
| | | | | | expressions of loops. llvm-svn: 204430
* [-Wunreachable-code] Simplify and broad -Wunreachable-code-return, including ↵Ted Kremenek2014-03-201-1/+1
| | | | | | | | | | | | | | | | | nontrivial returns. The exception is return statements that include control-flow, which are clearly doing something "interesting". 99% of the cases I examined for -Wunreachable-code that fired on return statements were not interesting enough to warrant being in -Wunreachable-code by default. Thus the move to include them in -Wunreachable-code-return. This simplifies a bunch of logic, including removing the ad hoc logic to look for std::string literals. llvm-svn: 204307
* Further refine -Wunreachable-code groups so that -Wno-unreachable-code-break ↵Ted Kremenek2014-03-151-10/+19
| | | | | | | | | | doesn't turn off all unreachable code warnings. Also relax unreachable 'break' and 'return' to not check for being preceded by a call to 'noreturn'. That turns out to not be so interesting in practice. llvm-svn: 204000
* Start breaking -Wunreachable-code up into different diagnostic groups.Ted Kremenek2014-03-151-2/+15
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Recent work on -Wunreachable-code has focused on suppressing uninteresting unreachable code that center around "configuration values", but there are still some set of cases that are sometimes interesting or uninteresting depending on the codebase. For example, a dead "break" statement may not be interesting for a particular codebase, potentially because it is auto-generated or simply because code is written defensively. To address these workflow differences, -Wunreachable-code is now broken into several diagnostic groups: -Wunreachable-code: intended to be a reasonable "default" for most users. and then other groups that turn on more aggressive checking: -Wunreachable-code-break: warn about dead break statements -Wunreachable-code-trivial-return: warn about dead return statements that return "trivial" values (e.g., return 0). Other return statements that return non-trivial values are still reported under -Wunreachable-code (this is an area subject to more refinement). -Wunreachable-code-aggressive: supergroup that enables all these groups. The goal is to eventually make -Wunreachable-code good enough to either be in -Wall or on-by-default, thus finessing these warnings into different groups helps achieve maximum signal for more users. TODO: the tests need to be updated to reflect this extra control via diagnostic flags. llvm-svn: 203994
* [C++11] Add 'override' keyword to virtual methods that override their base ↵Craig Topper2014-03-121-22/+26
| | | | | | class. llvm-svn: 203640
* [-Wunreachable-code] Handle Objective-C bool literals in 'isConfigurationValue'.Ted Kremenek2014-03-091-1/+1
| | | | | | | This includes special casing 'YES' and 'NO', which are constants defined as macros. llvm-svn: 203380
* [C++11] Replace verbose functors with succinct lambdasBenjamin Kramer2014-03-011-33/+15
| | | | | | No functionality change. llvm-svn: 202590
* As of r202325, CFGBlock predecessors may be NULL. Ignore such preds. Fixes a ↵Nick Lewycky2014-02-271-0/+1
| | | | | | crasher, PR18983. llvm-svn: 202340
* Hoist culling of -Wunreachable-code from headers before we even run the ↵Ted Kremenek2014-02-251-6/+10
| | | | | | analysis. llvm-svn: 202200
* Experiment with making -Wunreachable-code more immediately useful by ↵Ted Kremenek2014-02-181-0/+6
| | | | | | | | | | | | | | | restricting warnings to those issued in the main file. This warning has a whole bunch of known false positives, much of them due to code that is "sometimes unreachable". This can caused by code that is conditionally generated by the preprocessor, branches that are defined in terms of architecture-specific details (e.g., the size of a type), and so on. While these are all good things to address one by one, the reality is that this warning has received little love lately. By restricting its purvue, we can focus on the top issues effecting main files, which should be smaller, and then gradually widen the scope. llvm-svn: 201607
* 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] Add a CFG node for the allocator call in a C++ 'new' expression.Jordan Rose2014-01-131-0/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | 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
* Ignore qualified templated functions for -Winfinite-recursion. This treatsRichard Trieu2014-01-041-0/+12
| | | | | | functions like Foo<5>::run() the same way as run<5>() for this warning. llvm-svn: 198470
* Add -Winfinite-recursion to ClangRichard Trieu2013-12-211-0/+99
| | | | | | | | | | | | | | | | | | | | | | | | | | | This new warning detects when a function will recursively call itself on every code path though that function. This catches simple recursive cases such as: void foo() { foo(); } As well as more complex functions like: void bar() { if (test()) { bar(); return; } else { bar(); } return; } This warning uses the CFG. As with other CFG-based warnings, this is off by default. Due to false positives, this warning is also disabled for templated functions. llvm-svn: 197853
* Consumed analysis: Add param_typestate attribute, which specifies thatDeLesley Hutchins2013-10-171-0/+9
| | | | | | | function parameters must be in a particular state. Patch by chris.wailes@gmail.com. Reviewed by delesley@google.com. llvm-svn: 192934
* Consumed Analysis: Allow parameters that are passed by non-const referenceDeLesley Hutchins2013-10-171-0/+12
| | | | | | | to be treated as return values, and marked with the "returned_typestate" attribute. Patch by chris.wailes@gmail.com; reviewed by delesley@google.com. llvm-svn: 192932
* Move comment to its proper place.Ted Kremenek2013-10-141-2/+2
| | | | llvm-svn: 192613
* Consumed analysis: switch from tests_consumed/unconsumed to a generalDeLesley Hutchins2013-10-111-9/+0
| | | | | | tests_typestate attribute. Patch by chris.wailes@gmail.com. llvm-svn: 192513
* Consumed analysis: improve loop handling. The prior version of the analysisDeLesley Hutchins2013-10-091-0/+7
| | | | | | | | | | | | marked all variables as "unknown" at the start of a loop. The new version keeps the initial state of variables unchanged, but issues a warning if the state at the end of the loop is different from the state at the beginning. This patch will eventually be replaced with a more precise analysis. Initial patch by chris.wailes@gmail.com. Reviewed and edited by delesley@google.com. llvm-svn: 192314
* Consumed Analysis: Change callable_when so that it can take a list of statesDeLesley Hutchins2013-10-041-24/+8
| | | | | | | | that a function can be called in. This reduced the total number of annotations needed and makes writing more complicated behaviour less burdensome. Patch by chriswails@gmail.com. llvm-svn: 191983
* PR17290: Use 'false' macro in fix-it hint for initializing a variable of typeRichard Smith2013-09-201-7/+7
| | | | | | | | | _Bool in C, if the macro is defined. Also teach FixItUtils to look at whether the macro was defined at the source location for which it is creating a fixit, rather than looking at whether it's defined *now*. This is especially relevant for analysis-based warnings which are delayed until end of TU. llvm-svn: 191057
* PR16054: Slight strengthening for -Wsometimes-uninitialized: if we use aRichard Smith2013-09-121-10/+42
| | | | | | | | | | | variable uninitialized every time we reach its (reachable) declaration, or every time we call the surrounding function, promote the warning from -Wmaybe-uninitialized to -Wsometimes-uninitialized. This is still slightly weaker than desired: we should, in general, warn if a use is uninitialized the first time it is evaluated. llvm-svn: 190623
* Fix constructor-related typos.Benjamin Kramer2013-09-091-1/+1
| | | | | | Noticed by Roman Divacky. llvm-svn: 190311
* Consumed analysis: add return_typestate attribute.DeLesley Hutchins2013-09-031-31/+17
| | | | | | | | | | Patch by chris.wailes@gmail.com Functions can now declare what state the consumable type the are returning will be in. This is then used on the caller side and checked on the callee side. Constructors now use this attribute instead of the 'consumes' attribute. llvm-svn: 189843
OpenPOWER on IntegriCloud