Commit Graph

2254 Commits

Author SHA1 Message Date
Manuel Klimek b5616c9f8d Re-applying r214962.
Changes to the original patch:
- model the CFG for temporary destructors in conditional operators so that
  the destructors of the true and false branch are always exclusive. This
  is necessary because we must not have impossible paths for the path
  based analysis to work.
- add multiple regression tests with ternary operators

Original description:
Fix modelling of non-lifetime-extended temporary destructors in the
analyzer.

Changes to the CFG:
When creating the CFG for temporary destructors, we create a structure
that mirrors the branch structure of the conditionally executed
temporary constructors in a full expression.
The branches we create use a CXXBindTemporaryExpr as terminator which
corresponds to the temporary constructor which must have been executed
to enter the destruction branch.

2. Changes to the Analyzer:
When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as
executed in the state; when we reach a branch that contains the
corresponding CXXBindTemporaryExpr as terminator, we branch out
depending on whether the corresponding CXXBindTemporaryExpr was marked
as executed.

llvm-svn: 215096
2014-08-07 10:42:17 +00:00
Rui Ueyama a89f9c8fdb Revert "Fix modelling of non-lifetime-extended temporary destructors in the analyzer."
This reverts commit r214962 because after the change the
following code doesn't compile with -Wreturn-type -Werror.

  #include <cstdlib>

  class NoReturn {
  public:
    ~NoReturn() __attribute__((noreturn)) { exit(1); }
  };

  int check() {
    true ? NoReturn() : NoReturn();
  }

llvm-svn: 214998
2014-08-06 22:01:54 +00:00
Manuel Klimek 89df13e913 Remove unnecessary semicolon.
llvm-svn: 214970
2014-08-06 14:21:59 +00:00
Manuel Klimek d9b4ad6e1f Fix modelling of non-lifetime-extended temporary destructors in the analyzer.
1. Changes to the CFG:
When creating the CFG for temporary destructors, we create a structure
that mirrors the branch structure of the conditionally executed
temporary constructors in a full expression.
The branches we create use a CXXBindTemporaryExpr as terminator which
corresponds to the temporary constructor which must have been executed
to enter the destruction branch.

2. Changes to the Analyzer:
When we visit a CXXBindTemporaryExpr we mark the CXXBindTemporaryExpr as
executed in the state; when we reach a branch that contains the
corresponding CXXBindTemporaryExpr as terminator, we branch out
depending on whether the corresponding CXXBindTemporaryExpr was marked
as executed.

llvm-svn: 214962
2014-08-06 12:45:51 +00:00
Anton Yartsev 4e4cb6bc30 [Analyzer] fix for PR19102
Newly-created unconsumed instance is now assumed escaped if an invoked constructor has an argument of a pointer-to-record type.

llvm-svn: 214909
2014-08-05 18:26:05 +00:00
Alexey Bataev 0162e459ef [OPENMP] Initial parsing and sema analysis for 'atomic' directive.
llvm-svn: 213639
2014-07-22 10:10:35 +00:00
Alexey Bataev 9fb6e647e7 [OPENMP] Initial parsing and sema analysis for 'ordered' directive.
llvm-svn: 213616
2014-07-22 06:45:04 +00:00
Alexey Bataev 6125da9258 [OPENMP] Initial parsing and sema analysis for 'flush' directive.
llvm-svn: 213512
2014-07-21 11:26:11 +00:00
Alexander Musman d9ed09f7a5 [OPENMP] Parsing/Sema of the OpenMP directive 'critical'.
llvm-svn: 213510
2014-07-21 09:42:05 +00:00
David Blaikie 3875a82d42 Remove uses of the redundant ".reset(nullptr)" of unique_ptr, in favor of ".reset()"
It's also possible to just write "= nullptr", but there's some question
of whether that's as readable, so I leave it up to authors to pick which
they prefer for now. If we want to discuss standardizing on one or the
other, we can do that at some point in the future.

llvm-svn: 213439
2014-07-19 01:06:45 +00:00
Alexey Bataev 2df347ad96 [OPENMP] Initial parsing and sema analysis for 'taskwait' directive.
llvm-svn: 213363
2014-07-18 10:17:07 +00:00
Alexey Bataev 4d1dfeabc9 [OPENMP] Initial parsing and sema analysis for 'barrier' directive.
llvm-svn: 213360
2014-07-18 09:11:51 +00:00
Alexey Bataev 68446b7253 [OPENMP] Initial parsing and sema analysis of 'taskyield' directive.
llvm-svn: 213355
2014-07-18 07:47:19 +00:00
David Blaikie 62a56f39b7 Revert "unique_ptr-ify ownership of ASTConsumers"
This reverts commit r213307.

Reverting to have some on-list discussion/confirmation about the ongoing
direction of smart pointer usage in the LLVM project.

llvm-svn: 213325
2014-07-17 22:34:12 +00:00
David Blaikie a51666a4d6 unique_ptr-ify ownership of ASTConsumers
(after fixing a bug in MultiplexConsumer I noticed the ownership of the
nested consumers was implemented with raw pointers - so this fixes
that... and follows the source back to its origin pushing unique_ptr
ownership up through there too)

llvm-svn: 213307
2014-07-17 20:40:36 +00:00
Alexander Musman 80c2289a03 [OPENMP] Parsing/Sema analysis of directive 'master'
llvm-svn: 213237
2014-07-17 08:54:58 +00:00
Alp Toker 0621cb2e7d Make clang's rewrite engine a core feature
The rewrite facility's footprint is small so it's not worth going to these
lengths to support disabling at configure time, particularly since key compiler
features now depend on it.

Meanwhile the Objective-C rewriters have been moved under the
ENABLE_CLANG_ARCMT umbrella for now as they're comparatively heavy and still
potentially worth excluding from lightweight builds.

Tests are now passing with any combination of feature flags. The flags
historically haven't been tested by LLVM's build servers so caveat emptor.

llvm-svn: 213171
2014-07-16 16:48:33 +00:00
Alexey Bataev 9c2e8ee72f [OPENMP] Parsing and sema analysis for 'omp task' directive.
llvm-svn: 212804
2014-07-11 11:25:16 +00:00
NAKAMURA Takumi 5787cc2ccf TestAfterDivZeroChecker.cpp: Avoid member initializer. It is unsupported in msc17.
llvm-svn: 212789
2014-07-11 00:32:35 +00:00
Jordan Rose dc352bb82b [analyzer] Check for code testing a variable for 0 after using it as a denominator.
This new checker, alpha.core.TestAfterDivZero, catches issues like this:

  int sum = ...
  int avg = sum / count; // potential division by zero...
  if (count == 0) { ... } // ...caught here

Because the analyzer does not necessarily explore /all/ paths through a program,
this check is restricted to only work on zero checks that immediately follow a
division operation (/ % /= %=). This could later be expanded to handle checks
dominated by a division operation but not necessarily in the same CFG block.

Patch by Anders Rönnholm! (with very minor modifications by me)

llvm-svn: 212731
2014-07-10 16:10:52 +00:00
Alexey Bataev 84d0b3efee [OPENMP] Parsing and sema analysis for 'omp parallel sections' directive.
llvm-svn: 212516
2014-07-08 08:12:03 +00:00
Alexey Bataev 4acb859fbd [OPENMP] Added initial support for 'omp parallel for'.
llvm-svn: 212453
2014-07-07 13:01:15 +00:00
David Majnemer f456e44211 StaticAnalyzer: Silence a warning
ExprEngine wasn't ready for SEHLeaveStmtClass.  Handle it like all the
other SEH constructs by aborting.

llvm-svn: 212436
2014-07-07 06:20:50 +00:00
Alp Toker 452bfcf00c PlistSupport.h: avoid gcc 'defined but not used' warning
llvm-svn: 212396
2014-07-06 07:59:14 +00:00
Alp Toker dbb0c75977 Modernize a couple of loops
llvm-svn: 212394
2014-07-06 06:09:20 +00:00
Alp Toker 525fdfc11e Use PlistSupport in a few more places
Switch over LogDiagnosticPrinter and introduce an integer helper.

llvm-svn: 212384
2014-07-06 04:26:52 +00:00
Alp Toker f994cef836 Track IntrusiveRefCntPtr::get() changes from LLVM r212366
llvm-svn: 212369
2014-07-05 03:08:06 +00:00
Craig Topper 00bbdcf9b3 Remove llvm:: from uses of ArrayRef.
llvm-svn: 211987
2014-06-28 23:22:23 +00:00
Anna Zaks b8de0c4278 Do not inline methods of C++ containers (coming from headers).
This silences false positives (leaks, use of uninitialized value) in simple
code that uses containers such as std::vector and std::list. The analyzer
cannot reason about the internal invariances of those data structures which
leads to false positives. Until we come up with a better solution to that
problem, let's just not inline the methods of the containers and allow objects
to escape whenever such methods are called.

This just extends an already existing flag "c++-container-inlining" and applies
the heuristic not only to constructors and destructors of the containers, but
to all of their methods.

We have a bunch of distinct user reports all related to this issue
(radar://16058651, radar://16580751, radar://16384286, radar://16795491
[PR19637]).

llvm-svn: 211832
2014-06-27 01:03:05 +00:00
Alexey Bataev d1e40fbfe1 [OPENMP] Initial parsing and sema analysis for 'single' directive.
llvm-svn: 211774
2014-06-26 12:05:45 +00:00
Alexey Bataev 1e0498a92d [OPENMP] Initial parsing and sema analysis for 'section' directive.
llvm-svn: 211767
2014-06-26 08:21:58 +00:00
Alexey Bataev d3f8dd2d15 [OPENMP] Initial support for 'sections' directive.
llvm-svn: 211685
2014-06-25 11:44:49 +00:00
David Majnemer fa1d3e35e1 StaticAnalyzer: Switch a loop to a range-based for
Merely a code simplification, no functionality change.

llvm-svn: 211484
2014-06-23 02:16:38 +00:00
Jordan Rose e3f310f3bd [analyzer] Check for NULL passed to CFAutorelease.
Patch by Sean McBride, tests adjusted by me.

llvm-svn: 211453
2014-06-21 23:50:40 +00:00
Jordan Rose 6914e2f339 [analyzer] Don't create new PostStmt nodes if we don't have to.
Doing this caused us to mistakenly think we'd seen a particular state before
when we actually hadn't, which resulted in false negatives. Credit to
Rafael Auler for discovering this issue!

llvm-svn: 211209
2014-06-18 19:23:30 +00:00
Alexey Bataev f29276edb7 [OPENMP] Initial support for '#pragma omp for' (fixed incompatibility with MSVC).
llvm-svn: 211140
2014-06-18 04:14:57 +00:00
Rafael Espindola a566efbec9 Revert "[OPENMP] Initial support for '#pragma omp for'."
This reverts commit r211096. Looks like it broke the msvc build:

SemaOpenMP.cpp(140) : error C4519: default template arguments are only allowed on a class template

llvm-svn: 211113
2014-06-17 17:20:53 +00:00
Alexey Bataev c77dd5257a [OPENMP] Initial support for '#pragma omp for'.
llvm-svn: 211096
2014-06-17 11:49:22 +00:00
Sylvestre Ledru 06aebc4d69 One of our buildbot for FreeBSD does not support std::to_string.
Use stringstream instead to convert int to string

llvm-svn: 210972
2014-06-14 09:28:27 +00:00
Sylvestre Ledru ac5a08a56a List the function/method name in the index page of scan-build
llvm-svn: 210971
2014-06-14 08:49:40 +00:00
Sylvestre Ledru 9882e1a52c With the option '-analyzer-config stable-report-filename=true',
instead of report-XXXXXX.html, scan-build/clang analyzer generate
report-<filename>-<function, method name>-<function position>-<id>.html.
(id = i++ for several issues found in the same function/method)

llvm-svn: 210970
2014-06-14 08:45:32 +00:00
Anna Zaks a6fea1386f Fix a crash in Retain Count checker error reporting
Fixes a crash in Retain Count checker error reporting logic by handing
the allocation statement retrieval from a BlockEdge program point.

Also added a simple CFG dump routine for debugging.

llvm-svn: 210960
2014-06-13 23:47:38 +00:00
Rafael Espindola c080917ec2 Replace llvm::error_code with std::error_code.
llvm-svn: 210780
2014-06-12 14:02:15 +00:00
Richard Trieu ddd01cec0e Removing an "if (this == nullptr)" check from two print methods. The condition
will never be true in a well-defined context.  The checking for null pointers
has been moved into the caller logic so it does not rely on undefined behavior.

llvm-svn: 210498
2014-06-09 22:53:25 +00:00
Rafael Espindola 507f1bc37e Don't assume an implicit IntrusiveRefCntPtr -> bool operator.
llvm-svn: 210075
2014-06-03 05:04:52 +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
Craig Topper 0dbb783c7b [C++11] Use 'nullptr'. StaticAnalyzer edition.
llvm-svn: 209642
2014-05-27 02:45:47 +00:00
Sylvestre Ledru e8103abdbc revert "r209526 List the function/method name in the index page of scan-build "
Depends on http://reviews.llvm.org/D3762

llvm-svn: 209527
2014-05-23 16:47:42 +00:00
Sylvestre Ledru 970d3189e6 List the function/method name in the index page of scan-build
llvm-svn: 209526
2014-05-23 16:40:46 +00:00
Eric Christopher c9e2a68905 Clean up language and grammar.
Based on a patch by jfcaron3@gmail.com!
PR19806

llvm-svn: 209215
2014-05-20 17:10:39 +00:00