Commit Graph

108 Commits

Author SHA1 Message Date
Argyrios Kyrtzidis 4769e9376e [analyzer] Remove unused functions from CheckerManager.
llvm-svn: 126352
2011-02-24 01:05:37 +00:00
Argyrios Kyrtzidis 785459a2a9 [analyzer] Migrate StreamChecker to CheckerV2.
llvm-svn: 126351
2011-02-24 01:05:33 +00:00
Argyrios Kyrtzidis c26f15dbad [analyzer] Migrate CStringChecker to CheckerV2.
llvm-svn: 126350
2011-02-24 01:05:30 +00:00
Argyrios Kyrtzidis 506220fef7 [analyzer] Migrate StackAddrLeakChecker to CheckerV2.
llvm-svn: 126333
2011-02-23 21:04:54 +00:00
Argyrios Kyrtzidis f1b5d1f01b [analyzer] Refactor EndOfFunctionNodeBuilder.
-Introduce EndOfFunctionNodeBuilder::withCheckerTag to allow it be "specialized" with a
 checker tag and not require the checkers to pass a tag.
-For EndOfFunctionNodeBuilder::generateNode, reverse the order of tag/P parameters since
 there are actual calls that assume the second parameter is ExplodedNode.

llvm-svn: 126332
2011-02-23 21:04:49 +00:00
Argyrios Kyrtzidis 66b38c2261 [analyzer] Migrate IdempotentOperationChecker to CheckerV2.
llvm-svn: 126331
2011-02-23 21:04:44 +00:00
Argyrios Kyrtzidis da02a25ae6 [analyzer] Migrate ChrootChecker to CheckerV2.
llvm-svn: 126324
2011-02-23 19:38:39 +00:00
Argyrios Kyrtzidis bf61d97a98 [analyzer] Migrate UnreachableCodeChecker to CheckerV2.
llvm-svn: 126308
2011-02-23 07:19:23 +00:00
Argyrios Kyrtzidis aad8372516 [analyzer] Migrate to CheckerV2:
NSAutoreleasePoolChecker
	ObjCAtSyncChecker

llvm-svn: 126307
2011-02-23 07:19:18 +00:00
Ted Kremenek 80861ca9b5 Migrate CFGReachabilityAnalysis out of the IdempotentOperationsChecker and into its own analysis file.
llvm-svn: 126289
2011-02-23 01:51:59 +00:00
Ted Kremenek cc7f1f8c2e Have IdempotentOperationsChecker pull its CFGStmtMap from AnalysisContext.
llvm-svn: 126288
2011-02-23 01:51:53 +00:00
Argyrios Kyrtzidis dff865d10b [analyzer] Migrate to CheckerV2:
CastToStructChecker
	FixedAddressChecker
	MacOSXAPIChecker
	PointerArithChecker
	PointerSubChecker
	PthreadLockChecker
	UnixAPIChecker

llvm-svn: 126284
2011-02-23 01:05:36 +00:00
Argyrios Kyrtzidis dd058d8a50 [analyzer] Migrate the BasicObjCFoundationChecks to CheckerV2:
NilArgChecker
	CFNumberCreateChecker
	ClassReleaseChecker

llvm-svn: 126275
2011-02-23 00:16:10 +00:00
Argyrios Kyrtzidis a1540db6e4 [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.

llvm-svn: 126272
2011-02-23 00:16:01 +00:00
Argyrios Kyrtzidis ed35cf271d [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.

llvm-svn: 126229
2011-02-22 17:30:38 +00:00
Ted Kremenek fb1a79af7a Add CStringChecker support for strncpy. Patch by Lenny Maiorani!
llvm-svn: 126188
2011-02-22 04:58:34 +00:00
Ted Kremenek 280a01fa1b Add CStringChecker support for strnlen. Patch by Lenny Maiorani!
llvm-svn: 126187
2011-02-22 04:55:05 +00:00
Oscar Fuentes 6f72540e46 New function for tablegenning: clang_tablegen.
llvm-svn: 126093
2011-02-20 22:06:32 +00:00
Oscar Fuentes f7fa56f25f Fix some add_dependencies.
The syntax is (add_dependencies target-name depend-target1 ...).

llvm-svn: 126049
2011-02-19 21:38:48 +00:00
Oscar Fuentes 79b52bfc46 CMake: updated source file list.
llvm-svn: 125783
2011-02-17 22:07:39 +00:00
Argyrios Kyrtzidis 57d736fd46 [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'

llvm-svn: 125780
2011-02-17 21:39:39 +00:00
Argyrios Kyrtzidis af45aca670 [analyzer] Use the new registration mechanism on the non-path-sensitive-checkers:
DeadStoresChecker
  ObjCMethSigsChecker
  ObjCUnusedIvarsChecker
  SizeofPointerChecker
  ObjCDeallocChecker
  SecuritySyntaxChecker

llvm-svn: 125779
2011-02-17 21:39:33 +00:00
Argyrios Kyrtzidis 24ffc08f39 [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.

llvm-svn: 125778
2011-02-17 21:39:24 +00:00
Argyrios Kyrtzidis 507ff53e39 [analyzer] Pass CheckerManager to the registration functions.
llvm-svn: 125777
2011-02-17 21:39:17 +00:00
Argyrios Kyrtzidis 9d5235d527 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!

llvm-svn: 125758
2011-02-17 18:40:33 +00:00
John McCall c07a0c7e48 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.

llvm-svn: 125744
2011-02-17 10:25:35 +00:00
Chris Lattner c8e630e4db 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.

llvm-svn: 125733
2011-02-17 07:39:24 +00:00
Chris Lattner 5a9b1ec94c simplify a bit.
llvm-svn: 125724
2011-02-17 05:38:27 +00:00
Zhanyong Wan 85a203ebdd Makes most methods in SVals.h conform to the naming guide. Reviewed
by kremenek.

llvm-svn: 125687
2011-02-16 21:13:32 +00:00
Nick Lewycky bb1e5079b2 Revert r125642. This broke the build? It should be a no-op.
llvm-svn: 125645
2011-02-16 02:34:28 +00:00
Nick Lewycky 757515588a Don't use "../foo" to return to the current directory.
llvm-svn: 125642
2011-02-16 02:10:49 +00:00
Argyrios Kyrtzidis 9d4d4f9104 [analyzer] Use the new registration mechanism on the apple checkers:
NilArgChecker
  CFNumberCreateChecker
  NSAutoreleasePoolChecker
  CFRetainReleaseChecker
  ClassReleaseChecker

llvm-svn: 125636
2011-02-16 01:40:52 +00:00
Argyrios Kyrtzidis a9215281de [analyzer] Use the new registration mechanism on some of the experimental internal checkers:
CastToStructChecker
  FixedAddressChecker
  PointerArithChecker
  PointerSubChecker

llvm-svn: 125612
2011-02-15 22:55:20 +00:00
Argyrios Kyrtzidis b2400924d9 [analyzer] Use the new registration mechanism on the IdempotentOperationChecker.
llvm-svn: 125611
2011-02-15 22:55:14 +00:00
Argyrios Kyrtzidis 2d3905ffac [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.

llvm-svn: 125598
2011-02-15 21:25:03 +00:00
Douglas Gregor 9892e3545a Add missing CMake dependency
llvm-svn: 125566
2011-02-15 17:09:56 +00:00
Argyrios Kyrtzidis 4e52527c28 [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.

llvm-svn: 125560
2011-02-15 07:42:38 +00:00
Argyrios Kyrtzidis a6d04d541d [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.

llvm-svn: 125559
2011-02-15 07:42:33 +00:00
Ted Kremenek 4ea9004fe8 IdempotentOperationChecker: don't repeatedly recompute block reachability.
llvm-svn: 125548
2011-02-15 02:20:03 +00:00
Oscar Fuentes c9987fbbfe Add current binary and source directories to the header search list
for all compiler invocations.

llvm-svn: 125514
2011-02-14 20:14:11 +00:00
Argyrios Kyrtzidis f0619868ae Remove left-over #include.
llvm-svn: 125507
2011-02-14 19:02:35 +00:00
Argyrios Kyrtzidis 556c45e9c5 [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.

llvm-svn: 125503
2011-02-14 18:13:31 +00:00
Argyrios Kyrtzidis ae92c95d34 [analyzer] Move Checkers/FrontendActions.cpp -> Frontend/FrontendActions.cpp
llvm-svn: 125500
2011-02-14 18:13:06 +00:00
Argyrios Kyrtzidis ecd3334dac [analyzer] Introduce libclangStaticAnalyzerFrontend and move Checkers/AnalysisConsumer.cpp into Frontend lib.
llvm-svn: 125499
2011-02-14 18:13:01 +00:00
Ted Kremenek 3374e03344 Remove dead code in IdempotentOperationChecker.
llvm-svn: 125497
2011-02-14 18:05:07 +00:00
Ted Kremenek 5794ef6950 Fix edge case where we don't cull warnings in IdempotentOperationsChecker due to incomplete analysis of loops.
llvm-svn: 125495
2011-02-14 17:59:23 +00:00
Ted Kremenek a71d5d31a1 Use 'BitVector' instead of SmallPtrSet<CFGBlock*> in IdempotentOperationsChecker. No real functionality change.
llvm-svn: 125494
2011-02-14 17:59:20 +00:00
Ted Kremenek c059798756 Teach the IdempotentOperations checker to ignore property setters.
llvm-svn: 125443
2011-02-12 18:50:03 +00:00
Ted Kremenek 70aeefa17e 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.
llvm-svn: 125427
2011-02-12 03:03:54 +00:00
Ted Kremenek b1c392aa56 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>.

llvm-svn: 125419
2011-02-12 00:17:19 +00:00