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

96 Коммитов

Автор SHA1 Сообщение Дата
Argyrios Kyrtzidis 74eed0ea03 [analyzer] Migrate the BasicObjCFoundationChecks to CheckerV2:
NilArgChecker
	CFNumberCreateChecker
	ClassReleaseChecker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 00:16:10 +00:00
Argyrios Kyrtzidis 404fc3ad6b [analyzer] Refactor BugTypes and their ownership model.
-In general, don't have the BugReporter deleting BugTypes, BugTypes will eventually become owned by checkers
 and outlive the BugReporter. In the meantime, there will be some leaks since some checkers assume that
 the BugTypes they create will be destroyed by the BugReporter.
-Have BugReporter::EmitBasicReport create BugTypes that are reused if the same name & category strings
 are passed to EmitBasicReport. These BugTypes are owned and destroyed by the BugReporter.
 This allows bugs reported through EmitBasicReport to be coalesced.
-Remove the llvm::FoldingSet<BugReportEquivClass> from BugType and move it into the BugReporter.
 For uniquing BugReportEquivClass also use the BugType* so that we can iterate over all of them using only one set.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126272 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-23 00:16:01 +00:00
Argyrios Kyrtzidis 769ce3e93a [analyzer] Start moving the path-sensitive checkers to CheckerV2.
-Migrate ObjCSelfInitChecker to CheckerV2. In the process remove the 'preCallSelfFlags' field
 from the checker class and use GRState for storing that info.
-Get ExprEngine to start delegating checker running to CheckerManager.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126229 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 17:30:38 +00:00
Ted Kremenek 0ef473f754 Add CStringChecker support for strncpy. Patch by Lenny Maiorani!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126188 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 04:58:34 +00:00
Ted Kremenek be4242ce03 Add CStringChecker support for strnlen. Patch by Lenny Maiorani!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126187 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-22 04:55:05 +00:00
Oscar Fuentes c8da1ecaf5 New function for tablegenning: clang_tablegen.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126093 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-20 22:06:32 +00:00
Oscar Fuentes b20f5c6f79 Fix some add_dependencies.
The syntax is (add_dependencies target-name depend-target1 ...).

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@126049 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-19 21:38:48 +00:00
Oscar Fuentes 63ba0460da CMake: updated source file list.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125783 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 22:07:39 +00:00
Argyrios Kyrtzidis 2d67b90a21 [analyzer] Use the new registration mechanism for the debugging info "checks".
The relative checker package is 'debug':

'-dump-live-variables' is replaced by '-analyzer-checker=debug.DumpLiveVars'
'-cfg-view' is replaced by '-analyzer-checker=debug.ViewCFG'
'-cfg-dump' is replaced by '-analyzer-checker=debug.DumpCFG'

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125780 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 21:39:39 +00:00
Argyrios Kyrtzidis 7dd445ec20 [analyzer] Use the new registration mechanism on the non-path-sensitive-checkers:
DeadStoresChecker
  ObjCMethSigsChecker
  ObjCUnusedIvarsChecker
  SizeofPointerChecker
  ObjCDeallocChecker
  SecuritySyntaxChecker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125779 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 21:39:33 +00:00
Argyrios Kyrtzidis 9fb9474c5b [analyzer]
-Introduce CheckerV2, a set of templates for convenient declaration & registration of checkers.
 Currently useful just for checkers working on the AST not the path-sensitive ones.
-Enhance CheckerManager to actually collect the checkers and turn it into the entry point for
 running the checkers.
-Use the new mechanism for the LLVMConventionsChecker.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125778 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 21:39:24 +00:00
Argyrios Kyrtzidis 695fb50282 [analyzer] Pass CheckerManager to the registration functions.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125777 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 21:39:17 +00:00
Argyrios Kyrtzidis c869abe2a9 When building StaticAnalyzer/Frontend add -I "<Checkers build dir>" to allow Checkers.inc to be
included without '..', thus being compatible with build systems of *BSDs.

Patch by Joerg Sonnenberger!

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125758 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 18:40:33 +00:00
John McCall 56ca35d396 Change the representation of GNU ?: expressions to use a different expression
class and to bind the shared value using OpaqueValueExpr.  This fixes an
unnoticed problem with deserialization of these expressions where the
deserialized form would lose the vital pointer-equality trait;  or rather,
it fixes it because this patch also does the right thing for deserializing
OVEs.

Change OVEs to not be a "temporary object" in the sense that copy elision is
permitted.

This new representation is not totally unawkward to work with, but I think
that's really part and parcel with the semantics we're modelling here.  In
particular, it's much easier to fix things like the copy elision bug and to
make the CFG look right.

I've tried to update the analyzer to deal with this in at least some          
obvious cases, and I think we get a much better CFG out, but the printing
of OpaqueValueExprs probably needs some work.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125744 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 10:25:35 +00:00
Chris Lattner ad8dcf4a9d Step #1/N of implementing support for __label__: split labels into
LabelDecl and LabelStmt.  There is a 1-1 correspondence between the
two, but this simplifies a bunch of code by itself.  This is because
labels are the only place where we previously had references to random
other statements, causing grief for AST serialization and other stuff.

This does cause one regression (attr(unused) doesn't silence unused
label warnings) which I'll address next.

This does fix some minor bugs:
1. "The only valid attribute " diagnostic was capitalized.
2. Various diagnostics printed as ''labelname'' instead of 'labelname'
3. This reduces duplication of label checking between functions and blocks.

Review appreciated, particularly for the cindex and template bits.



git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125733 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 07:39:24 +00:00
Chris Lattner 6810630bb0 simplify a bit.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125724 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-17 05:38:27 +00:00
Zhanyong Wan 7dfc9420ba Makes most methods in SVals.h conform to the naming guide. Reviewed
by kremenek.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125687 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 21:13:32 +00:00
Nick Lewycky 2dbf07d095 Revert r125642. This broke the build? It should be a no-op.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125645 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 02:34:28 +00:00
Nick Lewycky 864b9830f3 Don't use "../foo" to return to the current directory.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125642 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 02:10:49 +00:00
Argyrios Kyrtzidis 0b1ba6227c [analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker
  CFNumberCreateChecker
  NSAutoreleasePoolChecker
  CFRetainReleaseChecker
  ClassReleaseChecker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125636 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-16 01:40:52 +00:00
Argyrios Kyrtzidis 23ade507ce [analyzer] Use the new registration mechanism on some of the experimental internal checkers:
CastToStructChecker
  FixedAddressChecker
  PointerArithChecker
  PointerSubChecker

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125612 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 22:55:20 +00:00
Argyrios Kyrtzidis c9f2e0f286 [analyzer] Use the new registration mechanism on the IdempotentOperationChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125611 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 22:55:14 +00:00
Argyrios Kyrtzidis a0decc9a24 [analyzer] Use the new registration mechanism on some of the experimental checks. These are:
CStringChecker
   ChrootChecker
   MallocChecker
   PthreadLockChecker
   StreamChecker
   UnreachableCodeChecker

MallocChecker creates implicit dependencies between checkers and needs to be handled differently.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125598 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 21:25:03 +00:00
Douglas Gregor 6cd370cc31 Add missing CMake dependency
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125566 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 17:09:56 +00:00
Argyrios Kyrtzidis 26c05b11dc [analyzer] Reflect changes for tablegen'ing the checkers.
-Update tablegen files for checkers, use the tablegen class name for the checker class name.
-Update ClangSACheckersProvider to not look into hidden checker packages.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125560 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 07:42:38 +00:00
Argyrios Kyrtzidis 027a6abdd6 [analyzer] Use the new registration mechanism on some of the internal checks. These are:
StackAddrLeakChecker
ObjCAtSyncChecker
UnixAPIChecker
MacOSXAPIChecker

The rest have/create implicit dependencies between checkers and need to be handled differently.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125559 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 07:42:33 +00:00
Ted Kremenek b53189160c IdempotentOperationChecker: don't repeatedly recompute block reachability.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125548 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-15 02:20:03 +00:00
Oscar Fuentes b641f08cbe Add current binary and source directories to the header search list
for all compiler invocations.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125514 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 20:14:11 +00:00
Argyrios Kyrtzidis 7fa4f62979 Remove left-over #include.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125507 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 19:02:35 +00:00
Argyrios Kyrtzidis 43dee22025 [analyzer] Overhauling of the checker registration mechanism.
-Checkers will be defined in the tablegen file 'Checkers.td'.
-Apart from checkers, we can define checker "packages" that will contain a collection of checkers.
-Checkers can be enabled with -analyzer-checker=<name> and disabled with -analyzer-disable-checker=<name> e.g:
	Enable checkers from 'cocoa' and 'corefoundation' packages except the self-initialization checker:
	-analyzer-checker=cocoa -analyzer-checker=corefoundation -analyzer-disable-checker=cocoa.SelfInit
-Introduces CheckerManager and CheckerProvider. CheckerProviders get the set of checker names to enable/disable and
 register them with the CheckerManager which will be the entry point for all checker-related functionality.

Currently only the self-initialization checker takes advantage of the new mechanism.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125503 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 18:13:31 +00:00
Argyrios Kyrtzidis f49a009c18 [analyzer] Move Checkers/FrontendActions.cpp -> Frontend/FrontendActions.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125500 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 18:13:06 +00:00
Argyrios Kyrtzidis e817771c57 [analyzer] Introduce libclangStaticAnalyzerFrontend and move Checkers/AnalysisConsumer.cpp into Frontend lib.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125499 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 18:13:01 +00:00
Ted Kremenek 6a6d9a8ece Remove dead code in IdempotentOperationChecker.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125497 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 18:05:07 +00:00
Ted Kremenek e8350c6996 Fix edge case where we don't cull warnings in IdempotentOperationsChecker due to incomplete analysis of loops.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125495 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 17:59:23 +00:00
Ted Kremenek 8e3767711f Use 'BitVector' instead of SmallPtrSet<CFGBlock*> in IdempotentOperationsChecker. No real functionality change.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125494 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-14 17:59:20 +00:00
Ted Kremenek 020c374273 Teach the IdempotentOperations checker to ignore property setters.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125443 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-12 18:50:03 +00:00
Ted Kremenek b715a7cef1 Weaken the ObjCSelfInitChecker to only warn when one calls an 'init' method within an 'init' method. This is a temporary stop gap to avoid false positives while we investigate how to make it smarter.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125427 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-12 03:03:54 +00:00
Ted Kremenek f4e532b5a1 Don't emit a dead store for '++' operations unless it occurs with a return statement. We've never seen any other cases that were real bugs.
Fixes <rdar://problem/6962292>.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125419 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-12 00:17:19 +00:00
Ted Kremenek 848ec83483 Don't report dead stores on unreachable code paths. Fixes <rdar://problem/8405222>.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125415 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 23:24:26 +00:00
Ted Kremenek 2534528c22 Rename 'InvalidateRegions()' to 'invalidateRegions()'.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125395 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-11 19:48:15 +00:00
NAKAMURA Takumi 886e1606c2 CMake: LLVM_NO_RTTI must be obsolete now!
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125275 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-10 09:15:32 +00:00
Ted Kremenek 9b66371644 Split 'include/clang/StaticAnalyzer' into 'include/clang/StaticAnalyzer/Core' and 'include/clang/StaticAnalyzer/Checkers'.
This layout matches lib/StaticAnalyzer, which corresponds to two StaticAnalyzer libraries.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125251 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-10 01:03:03 +00:00
Peter Collingbourne e08ce650a2 AST, Sema, Serialization: add CUDAKernelCallExpr and related semantic actions
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125217 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-09 21:07:24 +00:00
John McCall 63c00d7f35 Remove vtables from the Stmt hierarchy; this was pretty easy as
there were only three virtual methods of any significance.

The primary way to grab child iterators now is with
  Stmt::child_range children();
  Stmt::const_child_range children() const;
where a child_range is just a std::pair of iterators suitable for
being llvm::tie'd to some locals.  I've left the old child_begin()
and child_end() accessors in place, but it's probably a substantial
penalty to grab the iterators individually now, since the
switch-based dispatch is kindof inherently slower than vtable
dispatch.  Grabbing them together is probably a slight win over the
status quo, although of course we could've achieved that with vtables, too.

I also reclassified SwitchCase (correctly) as an abstract Stmt
class, which (as the first such class that wasn't an Expr subclass)
required some fiddling in a few places.

There are somewhat gross metaprogramming hooks in place to ensure
that new statements/expressions continue to implement
getSourceRange() and children().  I had to work around a recent clang
bug;  dgregor actually fixed it already, but I didn't want to
introduce a selfhosting dependency on ToT.


git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125183 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-09 08:16:59 +00:00
Ted Kremenek d767d81290 static analyzer: Further reduce the analyzer's memory usage when analyzing sqlite3 by 7-10% by recylcing "uninteresting" ExplodedNodes.
The optimization involves eagerly pruning ExplodedNodes from the ExplodedGraph that contain
practically no difference between the predecessor and successor nodes.  For example, if
the state is different between a predecessor and a node, the node is left in.  Only for
the 'environment' component of the state do we not care if the ExplodedNodes are different.
This paves the way for future optimizations where we can reclaim the environment objects.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125154 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-09 01:27:33 +00:00
Argyrios Kyrtzidis 811d75ee35 [analyzer] Move the files in lib/StaticAnalyzer to lib/StaticAnalyzer/Core.
Eventually there will also be a lib/StaticAnalyzer/Frontend that will handle initialization and checker registration.
Yet another library to avoid cyclic dependencies between Core and Checkers.

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125124 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 22:30:36 +00:00
Argyrios Kyrtzidis a12a517017 [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineExperimentalChecks.cpp -> lib/StaticAnalyzer/Checkers/ExperimentalChecks.cpp
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125123 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 22:30:15 +00:00
Argyrios Kyrtzidis af1a9330ff [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineExperimentalChecks.h -> lib/StaticAnalyzer/Checkers/ExperimentalChecks.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125122 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 22:30:11 +00:00
Argyrios Kyrtzidis 04291a7c76 [analyzer] lib/StaticAnalyzer/Checkers/ExprEngineInternalChecks.h -> lib/StaticAnalyzer/Checkers/InternalChecks.h
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@125121 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-08 22:30:02 +00:00
Argyrios Kyrtzidis 0ca1040a96 [analyzer] Fix a false positive of the 'self' initialization checker.
A common pattern in classes with multiple initializers is to put the
subclass's common initialization bits into a static function that receives
the value of 'self', e.g:

   if (!(self = [super init]))
     return nil;
   if (!(self = _commonInit(self)))
     return nil;

It was reported that 'self' was not set to the result of [super init].
Until we can use inter-procedural analysis, in such a call, transfer the
ObjCSelfInitChecker flags associated with 'self' to the result of the call.

Fixes rdar://8937441 & http://llvm.org/PR9094

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@124940 91177308-0d34-0410-b5e6-96231b3b80d8
2011-02-05 05:54:53 +00:00