DeLesley Hutchins
b603192124
Thread Safety Analysis: implement review suggestions from Aaron Ballman.
...
llvm-svn: 209847
2014-05-29 21:24:16 +00:00
DeLesley Hutchins
44be81b5a9
Thread Safety Analysis: update TIL traversal mechanism to allow arbitrary
...
local contexts. Also includes some minor refactoring.
llvm-svn: 209774
2014-05-28 21:28:13 +00:00
Nikola Smiljanic
a9c452121a
Fix line endings.
...
llvm-svn: 209727
2014-05-28 11:19:43 +00:00
Richard Trieu
c771d5d79f
Move the logic for testing for namespace std into one location. This check can
...
be performed by using Decl::isInStdNamespace or DeclContext::isStdNamespace
llvm-svn: 209708
2014-05-28 02:16:01 +00:00
Manuel Klimek
5fbdc93d97
Make dead return statement detection more robust against changes in the CFG.
...
This change is a precondition to the proposed change to handle temporary
dtors correctly.
The idea is to explicitly search for the next return that doesn't have other
paths into it (that is, if the current block is dead, the block containing the
return must be dead, too). Thus, introducing non-control-flow block
transitions will not break the logic.
llvm-svn: 209531
2014-05-23 17:09:56 +00:00
Jordan Rose
7afd71e4ff
Add a check for tautological bitwise comparisons to -Wtautological-compare.
...
This catches issues like:
if ((x & 8) == 4) { ... }
if ((x | 4) != 3) { ... }
Patch by Anders Rönnholm!
llvm-svn: 209221
2014-05-20 17:31:11 +00:00
Craig Topper
2554294321
[C++11] Use 'nullptr'. Analysis edition.
...
llvm-svn: 209191
2014-05-20 04:30:07 +00:00
DeLesley Hutchins
f4b5e7c60f
Thread Safety Analysis: add new node types to thread safety TIL.
...
This fills in a few missing gaps in functionality.
llvm-svn: 208830
2014-05-15 00:50:36 +00:00
Aaron Ballman
9ee54d119c
Converting some for loops to use range-based for loops. No functional changes intended.
...
llvm-svn: 208810
2014-05-14 20:42:13 +00:00
Aaron Ballman
59a72b93a2
Amending r208783 based on a suggestion by David Blaikie.
...
llvm-svn: 208800
2014-05-14 18:32:59 +00:00
Aaron Ballman
42f9a8a7f9
Replacing some manual iterations with standard algorithms. No functional changes intended.
...
llvm-svn: 208783
2014-05-14 15:01:43 +00:00
Aaron Ballman
2f3fc6badd
Formatting and style changes; no functional changes intended.
...
llvm-svn: 208774
2014-05-14 13:03:55 +00:00
Aaron Ballman
0c6a14ca82
Amending r208439 to remove buildLExpr; this code isn't strictly required yet, and fixes a dead code warning.
...
llvm-svn: 208440
2014-05-09 18:44:48 +00:00
Aaron Ballman
7c192b452f
Add the ability to use logical expressions for capability attributes. This is to allow requirements to be expressed not just in terms of lists, but in terms of logical expressions. Eg)
...
void foo(void) __attribute__((requires_capability((FlightControl || Worker) && !Logger)));
This is WIP code.
llvm-svn: 208439
2014-05-09 18:26:23 +00:00
Benjamin Kramer
a7bcab75d2
ThreadSafetyAnalysis: Don't crash when trying to analyze objc methods.
...
The thread safety analysis isn't very useful in ObjC (you can't annotate
ObjC classes or methods) but we can still analyze the actual code and
show violations in usage of C/C++ functions.
Fixes PR19541, which does not use thread safety attributes but crashes
with -Weverything.
llvm-svn: 208436
2014-05-09 17:08:01 +00:00
Manuel Klimek
b33bded176
Explicitly keep track of temporaries during the consumed analysis.
...
This makes the consumed analysis less dependent on the CFG layout and fixes
a bug where we wouldn't warn on an unconsumed value.
llvm-svn: 208300
2014-05-08 11:50:00 +00:00
Manuel Klimek
75f34c1386
Fix handling of condition variables in the face of temp dtors.
...
The assignment needs to be before the destruction of the temporary.
This patch calls out to addStmt, which invokes VisitDeclStmt, which has
all the correct logic for handling temporaries.
llvm-svn: 207985
2014-05-05 18:21:06 +00:00
Nico Weber
b0f9e4ace7
Remove unused typedef found by gcc's -Wunused-local-typedefs.
...
llvm-svn: 207870
2014-05-02 21:22:21 +00:00
Hans Wennborg
802df13e4d
Fix bad comment from r207573.
...
llvm-svn: 207854
2014-05-02 18:12:30 +00:00
Aaron Ballman
a82eaa70f1
Updated the attribute tablegen emitter for variadic arguments to emit a range accessor in addition to the iterators. Updated code using iterators to use range-based for loops.
...
llvm-svn: 207837
2014-05-02 13:35:42 +00:00
Aaron Ballman
73b3651e9d
Renaming the CallableState variadic attribute argument to be CallableStates. No functional changes intended.
...
llvm-svn: 207836
2014-05-02 13:17:57 +00:00
Hans Wennborg
df51ee6c50
scanf analysis: handle scanlists that start with ^] (PR19559)
...
llvm-svn: 207573
2014-04-29 19:42:27 +00:00
Aaron Ballman
35897d97a3
Renaming range-based for loop variables so they don't appear iterator-like.
...
llvm-svn: 207422
2014-04-28 14:56:59 +00:00
Aaron Ballman
fe46e62e99
[C++11] Converting to range-based for loops. No functional changes intended.
...
llvm-svn: 207416
2014-04-28 13:01:32 +00:00
Aaron Ballman
8e8026d5b3
Replacing a naked pointer with a unique_ptr. No functional changes intended.
...
llvm-svn: 206986
2014-04-23 14:26:59 +00:00
Aaron Ballman
bf58a6a892
Updated to be a bit more const friendly. Also switched the linkage to be static since this function is file-local. No functional changes intended.
...
llvm-svn: 206982
2014-04-23 13:58:21 +00:00
DeLesley Hutchins
f1a311653a
Thread safety analysis: add array operations to SExpr.
...
llvm-svn: 206907
2014-04-22 17:31:23 +00:00
DeLesley Hutchins
7834001496
Thread safety analysis: fix warning.
...
llvm-svn: 206899
2014-04-22 14:51:04 +00:00
Chandler Carruth
1034666777
[Modules] Fix potential ODR violations by sinking the DEBUG_TYPE
...
definition below all of the header #include lines, clang edition.
If you want more details about this, you can see some of the commits to
Debug.h in LLVM recently. This is just the clang section of a cleanup
I've done for all uses of DEBUG_TYPE in LLVM.
llvm-svn: 206849
2014-04-22 03:17:02 +00:00
DeLesley Hutchins
f8b412adbb
Thread safety analysis: misc updates to SExpr handling. Fix to minimal SSA,
...
function parameters, and compound assignment.
llvm-svn: 206827
2014-04-21 23:18:18 +00:00
DeLesley Hutchins
a9db0019a2
Thread Safety Analysis: Convert to minimal SSA.
...
llvm-svn: 206681
2014-04-19 03:54:41 +00:00
DeLesley Hutchins
ae497deddf
Thread Safety Analysis: Update SSA pass to handle loops.
...
llvm-svn: 206676
2014-04-19 00:35:54 +00:00
Aaron Ballman
0491afaf5f
Updating to use more range-based for loops, nullptr and auto. No functional changes.
...
llvm-svn: 206590
2014-04-18 13:13:15 +00:00
Aaron Ballman
e80bfcd048
Making some public members into private members. This also introduces a bit more const-correctness, and now uses some range-based for loops. No functional changes intended.
...
llvm-svn: 206503
2014-04-17 21:44:08 +00:00
Aaron Ballman
ed5aced64e
Since the object is new'ed in the enterCFG function, now deleting in the exitCFG function instead of the destructor to ensure proper pairing. This allows reuse of the builder without creating a memory leak.
...
llvm-svn: 206471
2014-04-17 15:23:50 +00:00
Ted Kremenek
6f375e5604
-Wunreachable-code: refine recognition of unreachable "sigil" to cope with implicit casts in C++.
...
Fixes <rdar://problem/16631033>.
llvm-svn: 206360
2014-04-16 07:26:09 +00:00
DeLesley Hutchins
aab9aff058
Thread Safety Analysis: rewrite SSA pass to use the new SExpr and CFG
...
traversal system. The new pass is still undergoing testing; no change in
functionality.
llvm-svn: 206338
2014-04-15 23:23:19 +00:00
Richard Trieu
e729d9b598
Fix typo from r206232
...
llvm-svn: 206234
2014-04-15 01:06:38 +00:00
Richard Trieu
e9fa266cba
Fix a bad interaction between -Wtautological-overlap-compare and delayed
...
diagnostics which caused delayed diagnostics on dead paths to be emitted.
llvm-svn: 206232
2014-04-15 00:57:50 +00:00
DeLesley Hutchins
7e615c2f65
Thread Safety Analysis: reorganized SExpr header files. No change in
...
functionality.
llvm-svn: 205936
2014-04-09 22:39:43 +00:00
Aaron Ballman
28347a72c9
Thread Safety Analysis: now with less includes. No functional changes.
...
llvm-svn: 205929
2014-04-09 21:12:04 +00:00
Aaron Ballman
3f993c1320
Thread Safety Analysis: some minor cleanups to the latest thread safety changes. No functional changes intended.
...
* Adds an iterator_range interface to CallExpr to get the arguments
* Modifies SExpr such that it must be allocated in the Arena, and cannot be deleted
* Minor const-correctness and nullptr updates
* Adds some operator!= implementations to complement operator==
* Removes unused functionality
llvm-svn: 205915
2014-04-09 17:45:44 +00:00
DeLesley Hutchins
f7813c56b4
Thread Safety Analysis. Misc fixes to SExpr code, responding to code review
...
by Aaron Ballman.
llvm-svn: 205809
2014-04-08 22:21:22 +00:00
DeLesley Hutchins
11bb308739
Thread Safety Analysis: various fixes to new SExpr code.
...
Implemented ownership policy, updated to use nullptr, const-cleanup.
llvm-svn: 205745
2014-04-07 22:56:24 +00:00
DeLesley Hutchins
b2213910de
Thread Safety Analysis: update to internal SExpr handling.
...
This patch is the first part of a significant refactoring that seeks to restore
sanity to way thread safety analysis deals with capability expressions. The
current patch merely provides an outline of the structure of the new system.
It's not yet connected to the actual analysis, so there's no change in
functionality.
llvm-svn: 205728
2014-04-07 18:09:54 +00:00
Richard Trieu
f935b562b9
Add a new subgroup to -Wtautological-compare, -Wtautological-overlap-compare,
...
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
2014-04-05 05:17:01 +00:00
Aaron Ballman
e044904301
Updating the capability attribute diagnostics to be more capability-neutral. 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
2014-04-01 21:43:23 +00:00
Jordan Rose
398fb00e1e
[analyzer] Fix a CFG printing bug.
...
Also, add several destructor-related tests. Most of them don't work yet, but it's
good to have them recorded.
Patch by Alex McCarthy!
llvm-svn: 205326
2014-04-01 16:39:33 +00:00
Ted Kremenek
ab57a1555a
[-Wunreachable-code] Expand paren-suppression heuristic to C++/ObjC bools.
...
llvm-svn: 205074
2014-03-29 04:49:20 +00:00
Ted Kremenek
ec3bbf4933
Improve -Wunreachable-code to provide a means to indicate code is 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
2014-03-29 00:35:20 +00:00