Граф коммитов

2441 Коммитов

Автор SHA1 Сообщение Дата
DeLesley Hutchins dd0a1f58a5 Thread safety analysis: Turn on checking for non-scalar types by default.
These were previously enabled as a "beta" feature, but they have now been
extensively tested.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178478 91177308-0d34-0410-b5e6-96231b3b80d8
2013-04-01 17:47:37 +00:00
Jordan Rose 75f8bd0131 [analyzer] Add debug helper LocationContext::dumpStack().
Sample output:
  #0 void construct(pointer __p, llvm::ImutAVLTree<llvm::ImutContainerInfo<clang::ento::BugType *> > *const &__val)
  #1 void push_back(const value_type &__x)
  #2 void destroy()
  #3 void release()
  #4 void ~ImmutableSet()

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178400 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-30 01:31:35 +00:00
Ted Kremenek 5062bb2270 [cfg] Always guard (when AddStaticInitBranches == true) DeclStmts for static variables, not just ones with explicit initializers
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178322 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-29 00:42:56 +00:00
Ted Kremenek 0f5c5c60e9 Add static analyzer support for conditionally executing static initializers.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178318 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-29 00:09:28 +00:00
Ted Kremenek 02a88c3edf Add configuration plumbing to enable static initializer branching in the CFG for the analyzer.
This setting still isn't enabled yet in the analyzer.  This is
just prep work.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178317 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-29 00:09:22 +00:00
Ted Kremenek fbd4b5dc7f Add CFG logic to create a conditional branch for modeling static initializers.
This is an optional variant of the CFG.  This allows analyses to model whether
or not a static initializer has run, e.g.:

  static Foo x = bar();

For basic dataflow analysis in Sema we will just assume that the initializer
always runs.  For the static analyzer we can use this branch to accurately
track whether or not initializers are on.

This patch just adds the (opt-in) functionality to the CFG.  The
static analyzer still needs to be modified to adopt this feature.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178263 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-28 18:43:15 +00:00
Rafael Espindola 8343f8e00a Add const in preparation for a simplify_type change in llvm.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@178146 91177308-0d34-0410-b5e6-96231b3b80d8
2013-03-27 15:37:54 +00:00
David Blaikie b07805485c Remove the CFGElement "Invalid" state.
Use Optional<CFG*> where invalid states were needed previously. In the one case
where that's not possible (beginAutomaticObjDtorsInsert) just use a dummy
CFGAutomaticObjDtor.

Thanks for the help from Jordan Rose & discussion/feedback from Ted Kremenek
and Doug Gregor.

Post commit code review feedback on r175796 by Ted Kremenek.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175938 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-23 00:29:34 +00:00
David Blaikie fdf6a279c9 Replace CFGElement llvm::cast support to be well-defined.
See r175462 for another example/more details.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175796 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-21 20:58:29 +00:00
David Blaikie 66874fb18a Use None rather than Optional<T>() where possible.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175705 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-21 01:47:18 +00:00
David Blaikie dc84cd5efd Include llvm::Optional in clang/Basic/LLVM.h
Post-commit CR feedback from Jordan Rose regarding r175594.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@175679 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-20 22:23:23 +00:00
Jordan Rose 3f6f51e282 Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.
Nearly all of these changes are one-to-one replacements; the few that
aren't have to do with custom identifier validation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174768 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-08 22:30:41 +00:00
Ted Kremenek b1855de3d6 Add note why we used a switch.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174449 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-05 22:03:14 +00:00
Ted Kremenek 5846720f08 Change subexpressions to be visited in the CFG from left-to-right.
This is a more natural order of evaluation, and it is very important
for visualization in the static analyzer.  Within Xcode, the arrows
will not jump from right to left, which looks very visually jarring.
It also provides a more natural location for dataflow-based diagnostics.

Along the way, we found a case in the analyzer diagnostics where we
needed to indicate that a variable was "captured" by a block.

-fsyntax-only timings on sqlite3.c show no visible performance change,
although this is just one test case.

Fixes <rdar://problem/13016513>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174447 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-05 22:00:19 +00:00
Anna Zaks ef95aea4fe [analyzer] add comment
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174435 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-05 19:52:26 +00:00
NAKAMURA Takumi 22c0cbee5b clang/Analysis: Fix r174245, a valgrind error in AnalysisDeclContext::getBody(bool &IsAutosynthesized), to initialize IsAutosynthesized explicitly.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174303 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-04 05:06:21 +00:00
Anna Zaks 453cb859a3 [analyzer] Always inline functions with bodies generated by BodyFarm.
Inlining these functions is essential for correctness. We often have
cases where we do not inline calls. For example, the shallow mode and
when reanalyzing previously inlined ObjC methods as top level.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@174245 91177308-0d34-0410-b5e6-96231b3b80d8
2013-02-02 00:30:04 +00:00
Ted Kremenek 77fd3c0d78 -Wuninitialized: warn about uninitialized values resulting from ?: that evaluate to lvalues (in C++).
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172875 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-19 00:25:06 +00:00
DeLesley Hutchins 0ecc2e9ce8 Thread-safety analysis: ignore edges from throw expressions in CFG.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172858 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-18 22:15:45 +00:00
Jordan Rose cdbe1e0d85 Format strings: don't ever convert %+d to %lu.
Presumably, if the printf format has the sign explicitly requested, the user
wants to treat the data as signed.

This is a fix-up for r172739, and also includes several test changes that
didn't make it into that commit.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172762 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 22:34:10 +00:00
Jordan Rose 242ae3d680 Format strings: correct signedness if already correcting width (%d,%u).
It is valid to do this:
  printf("%u", (int)x);

But if we see this:
  printf("%lu", (int)x);

...our fixit should suggest %d, not %u.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172739 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 18:47:16 +00:00
Richard Smith cd8ab51a44 Implement C++11 semantics for [[noreturn]] attribute. This required splitting
it apart from [[gnu::noreturn]] / __attribute__((noreturn)), since their
semantics are not equivalent (for instance, we treat [[gnu::noreturn]] as
affecting the function type, whereas [[noreturn]] does not).


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172691 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-17 01:30:42 +00:00
Dmitri Gribenko cfa88f8939 Remove useless 'llvm::' qualifier from names like StringRef and others that are
brought into 'clang' namespace by clang/Basic/LLVM.h


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172323 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-12 19:30:44 +00:00
Enea Zaffanella 67d472c193 Test commit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@172195 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-11 11:37:08 +00:00
Will Dietz dac62528c1 CFG.cpp: Fix wrapping logic when printing block preds/succs.
First check only wrapped with i==8, second wrapped at i==2,8,18,28,...
This fix restores the intended behavior: i==8,18,28,...

Found with -fsanitize=integer.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171718 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-07 09:51:17 +00:00
Richard Smith 80ad52f327 s/CPlusPlus0x/CPlusPlus11/g
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171367 91177308-0d34-0410-b5e6-96231b3b80d8
2013-01-02 11:42:31 +00:00
Nico Weber d36aa359e2 ArrayRefize a CompoundStmt constructor.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@171238 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-29 20:03:39 +00:00
Anna Zaks 08165d8c9e [analyzer] Fix typos.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170907 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 17:27:04 +00:00
Anna Zaks bd80231672 [analyzer] Re-apply r170826 and make the dumping of the GallGraph
deterministic.

Commit message for r170826:

[analyzer] Traverse the Call Graph in topological order.

Modify the call graph by removing the parentless nodes. Instead all
nodes are children of root to ensure they are all reachable. Remove the
tracking of nodes that are "top level" or global. This information is
not used and can be obtained from the Decls stored inside
CallGraphNodes.

Instead of existing ordering hacks, analyze the functions in topological
order over the Call Graph.

Together with the addition of devirtualizable ObjC message sends and
blocks to the call graph, this gives around 6% performance improvement
on several large ObjC benchmarks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170906 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 17:27:01 +00:00
Rafael Espindola 6d42f4d8b8 Revert r170826. The output of
./bin/clang -cc1 -internal-isystem /home/espindola/llvm/build/lib/clang/3.3/include/ -analyze -analyzer-checker=debug.DumpCallGraph /home/espindola/llvm/clang/test/Analysis/debug-CallGraph.c -fblocks

changes in each run.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170829 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 01:30:23 +00:00
Anna Zaks e34e1939ad [analyzer] Traverse the Call Graph in topological order.
Modify the call graph by removing the parentless nodes. Instead all
nodes are children of root to ensure they are all reachable. Remove the
tracking of nodes that are "top level" or global. This information is
not used and can be obtained from the Decls stored inside
CallGraphNodes.

Instead of existing ordering hacks, analyze the functions in topological
order over the Call Graph.

Together with the addition of devirtualizable ObjC message sends and
blocks to the call graph, this gives around 6% performance improvement
on several large ObjC benchmarks.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170826 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 01:19:22 +00:00
Anna Zaks 4f858dfd42 [analyzer] Add blocks and ObjC messages to the call graph.
This paves the road for constructing a better function dependency graph.
If we analyze a function before the functions it calls and inlines,
there is more opportunity for optimization.

Note, we add call edges to the called methods that correspond to
function definitions (declarations with bodies).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@170825 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-21 01:19:15 +00:00
DeLesley Hutchins 93699d23cd Thread-safety analysis: check member access on guarded non-primitive types.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169669 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-08 03:46:30 +00:00
Ted Kremenek b929f6636c Use the BlockDecl captures list to infer the direct captures for a BlockDataRegion. Fixes <rdar://problem/12415065>.
We still need to do a recursive walk to determine all static/global variables
referenced by a block, which is needed for region invalidation.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169481 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-06 07:17:26 +00:00
Jordan Rose 2cd3440369 Format strings: offer a cast to 'unichar' for %C in Objective-C contexts.
For most cases where a conversion specifier doesn't match an argument,
we usually guess that the conversion specifier is wrong. However, if
the argument is an integer type and the specifier is %C, it's likely
the user really did mean to print the integer as a character.

(This is more common than %c because there is no way to specify a unichar
literal -- you have to write an integer literal, such as '0x2603',
and then cast it to unichar.)

This does not change the behavior of %S, since there are fewer cases
where printing a literal Unicode *string* is necessary, but this could
easily be changed in the future.

<rdar://problem/11982013>

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169400 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:49 +00:00
Jordan Rose ff7be48165 Format strings: the correct conversion for 'char' is %c, not %d or %hhd.
We tried to account for 'uint8_t' by saying that /typedefs/ of 'char'
should be corrected as %hhd rather than %c, but the condition was wrong.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169397 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 18:44:37 +00:00
DeLesley Hutchins 91e2061763 Thread-safety analysis: check locks on method calls, operator=, and
copy constructors.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169350 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 01:20:45 +00:00
DeLesley Hutchins 47715cc201 Thread Safety Analysis: refactor to make more methods accept const pointers,
adjust checkAccess.  No change in functionality.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169348 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-05 00:52:33 +00:00
Chandler Carruth 55fc873017 Sort all of Clang's files under 'lib', and fix up the broken headers
uncovered.

This required manually correcting all of the incorrect main-module
headers I could find, and running the new llvm/utils/sort_includes.py
script over the files.

I also manually added quite a few missing headers that were uncovered by
shuffling the order or moving headers up to be main-module-headers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169237 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-04 09:13:33 +00:00
Benjamin Kramer a93d0f2806 Include pruning and general cleanup.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169095 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 17:12:56 +00:00
Benjamin Kramer 2fa67efeaf Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't pull in all the generated Attr code.
Required to pull some functions out of line, but this shouldn't have a perf impact.
No functionality change.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@169092 91177308-0d34-0410-b5e6-96231b3b80d8
2012-12-01 15:09:41 +00:00
Ted Kremenek eba76a4379 Further reduce "-fsyntax-only -Wuninitialized" time on sqlite3.c by another 2.5% using intelligent pruning of blocks during the final reporting pass.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168257 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 07:18:30 +00:00
Ted Kremenek c1602581f7 Switch -Wuninitialized to use a reverse-post order traversal as
an initial baseline for enqueued blocks, but use a simple DFS stack
for propagating changes quickly up back edges.

This provides a 3.5% reduction in -fsyntax-only time on sqlite3.c.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@168241 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-17 02:00:00 +00:00
Ted Kremenek 8f81acfa95 Fix bad CFG construction bug when handling C++ 'try' statements.
This code assigned the last created CFGBlock* to the variable 'Block',
which is a scratch variable which is null'ed out after a block is
completed.  By assigning the last created block to 'Block', we start
editing a completed block, inserting CFGStmts that should be in
another block.  This was the case with 'try'.  The test case that
showed this had a while loop inside a 'try', and the logic before
the while loop was being included as part of the "condition block"
for the loop.  This showed up as a bogus dead store, but could
have lots of implications.

Turns out this bug was replicated a few times within CFG.cpp, so
I went and fixed up those as well.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167788 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-13 00:12:13 +00:00
Anna Zaks fadcd5d5bb [analyzer] add LocationContext::inTopFrame() helper.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@167351 91177308-0d34-0410-b5e6-96231b3b80d8
2012-11-03 02:54:16 +00:00
Ted Kremenek 507d106c75 Fix potential null deference in CFG printer.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165836 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 22:56:31 +00:00
Ted Kremenek 857f5681f5 Remove dead store.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165835 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 22:56:26 +00:00
Ted Kremenek 5dbd990d79 Conditionally use an integral cast for BodyFarm support for OSAtomicCompareAndSwap if the return type is not a boolean.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165774 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-12 00:18:19 +00:00
Ted Kremenek 48fa136150 Switch over to BodyFarm implementation of OSAtomicCompareAndSwap and
objc_atomicCompareAndSwap.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165743 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-11 20:58:18 +00:00
DeLesley Hutchins ef2388b10c Thread-safety analysis: allow attributes on constructors to refer to 'this'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@165339 91177308-0d34-0410-b5e6-96231b3b80d8
2012-10-05 22:38:19 +00:00