Steve Naroff [Wed, 2 Apr 2008 18:30:49 +0000 (18:30 +0000)]
Change ObjCInterfaceDecl to inherit from NamedDecl (not TypeDecl). While ObjCInterfaceDecl is arguably a TypeDecl, it isn't a ScopedDecl. Since TypeDecl's are scoped, it makes sense to simply treat them as NamedDecl's. I could have fiddled a bit more with the hierarchy (in terms of creating a non-scoped TypeDecl), however this probably isn't worth the effort.
I also finished unifying access to scope decl change by converting Sema::getObjCInterfaceDecl() to use Sema::LookupDecl(). This is much cleaner now:-)
Chris Lattner [Wed, 2 Apr 2008 17:35:06 +0000 (17:35 +0000)]
add a common base class "PointerLikeType" for PointerType and ReferenceType,
allowing them to be treated the same in some contexts. A suggestion for a
better name is welcome :)
Do equality testing, not regex, when the build command is gcc. This matches
better with what compiler invocations that ccc-analyzer actually intercepts.
Steve Naroff [Wed, 2 Apr 2008 14:35:35 +0000 (14:35 +0000)]
Two changes to Sema::LookupDecl() interface.
(1) Remove IdLoc (it's never used).
(2) Add a bool to enable/disable lazy builtin creaation (defaults to true).
This enables us to use LookupDecl() in Sema::isTypeName(), which is also part of this commit.
To make this work, I changed isTypeName() to be a non-const member function. I'm not happy with this, however I fiddled with making LookupDecl() and friends const and it got ugly pretty quickly. We can certainly add it back if/when someone has time to fiddle with it. For now, I thought this simplification was more important than retaining the const-ness.
Chris Lattner [Wed, 2 Apr 2008 06:59:01 +0000 (06:59 +0000)]
Various parts of the standard require something to be an "incomplete or
object type". Add a predicate that checks exactly this, as it is equivalent
to checking ot see if the type is *not* a function type, which is faster
to check.
Chris Lattner [Wed, 2 Apr 2008 06:50:17 +0000 (06:50 +0000)]
1) Enforce C99 6.7.3p2: "Types other than pointer types derived from
object or incomplete types shall not be restrict-qualified."
2) Warn about qualifiers on function types: C99 6.7.3p8: "If the
specification of a function type includes any type qualifiers, the
behavior is undefined."
3) Implement restrict on C++ references.
4) fix some locations for various C++ reference diagnostics.
Added initial hacked support for display path diagnostics with
GRSimpleVals warnings. Cleaning up, but now we get multiple bubbles (branches are annotated).
Steve Naroff [Tue, 1 Apr 2008 23:04:06 +0000 (23:04 +0000)]
Fairly large "cleaup" related to changing ObjCCompatibleAliasDecl superclass (to inherit from NamedDecl, instead of ScopedDecl).
- Added a DenseMap to associate an IdentifierInfo with the ObjCCompatibleAliasDecl.
- Renamed LookupScopedDecl->LookupDecl and changed it's return type to Decl. Also added lookup for ObjCCompatibleAliasDecl's.
- Removed Sema::LookupInterfaceDecl(). Converted clients to used LookupDecl().
- Some minor indentation changes.
Will deal with ObjCInterfaceDecl and getObjCInterfaceDecl() in a separate commit...
Chris Lattner [Tue, 1 Apr 2008 06:06:37 +0000 (06:06 +0000)]
MemoryBuffer::getFile got smarter, obviating the need for readfilefast.
The new MemoryBuffer doesn't "leak" file descriptors and handles the
small file case efficiently.
Steve Naroff [Mon, 31 Mar 2008 18:44:59 +0000 (18:44 +0000)]
Hack ReadFileFast() to raise the threshold of memory mapped files (from 4->12 pages).
This is a temporary solution to avoid running out of file descriptors (which defaults to 256).
Need to benchmark to understand the speed benefit. If the benefit is small, the simple solution is to avoid memory mapping files. If the benefit is significant, more thought is necessary.
Ted Kremenek [Mon, 31 Mar 2008 18:26:32 +0000 (18:26 +0000)]
Inlined clang/Analysis/Analyses/GRSimpleVals.h into LocalCheckers.h and removed
GRSimpleVals.h
Added a PathDiagnosticClient option to the driver functions for the
CFRefCountChecker and the GRSimpleVals analysis. Both analyses now accept a "-o"
argument from the driver that specifies where HTML reports should be dumped.
Ted Kremenek [Mon, 31 Mar 2008 18:23:15 +0000 (18:23 +0000)]
Added variation of the "Report" method in the class Diagnostic that takes
an optional DiagnosticClient argument that differs from the client stored
internally in the Diagnostic object.
Ted Kremenek [Mon, 31 Mar 2008 15:02:58 +0000 (15:02 +0000)]
Added path-sensitive check for return statements that return the address
of a stack variable. This is the path-sensitive version of a check that
is already done during semantic analysis.
Fix objc ivar lookup. Ivar lookup should occur between lookup
of method-local values and lookup of globals. Emulate this with
some logic in the handling of Sema::ActOnIdentifierExpr.
Two todo's left:
1) sema shouldn't turn a bare reference to an ivar into "self->ivar"
in the AST. This is a hack.
2) The new ScopedDecl::isDefinedOutsideFunctionOrMethod method does
not correctly handle typedefs and enum constants yet.
Chris Lattner [Sun, 30 Mar 2008 23:25:33 +0000 (23:25 +0000)]
some cleanups on top of David's patch. There are still two
remaining open issues I've communicated to him:
1) self can be assigned to, and his patch didn't handle it correctly.
2) CollectObjCIvarTypes is N^2 (because each subclass reprocesses
all parent class ivars) and flattens classes. If A derives from B,
and both have an int, I'd expect to get { {i32}, i32}, not { i32, i32}.
Ted Kremenek [Fri, 28 Mar 2008 16:09:38 +0000 (16:09 +0000)]
Added skeleton checking for NSString's method initWithFormat: (do not pass nil). This won't be useful in most cases right now
because the analyzer isn't tracking expected types for an object, and [NSString alloc] just runs "id".
Ted Kremenek [Thu, 27 Mar 2008 07:25:52 +0000 (07:25 +0000)]
Added "GRAuditor" and "GRSimpleAPICheck" interface to allow simple stateless checkers to be injected into the analyzer.
Added "AnnotatedPath" class to record an annotated path that will be useful for inspecting paths.
Added some boilerplate code for simple checks of Apple's Foundation API.
Ted Kremenek [Thu, 27 Mar 2008 06:17:42 +0000 (06:17 +0000)]
Added "HTMLDiagnostic", a generic DiagnosticClient (that also implements PathDiagnostic)
so that all diagnostics can be piped to HTML files instead of as text diagnostics using --html-diags.
Steve Naroff [Wed, 26 Mar 2008 22:28:40 +0000 (22:28 +0000)]
Fix rewriter tests to work with new output file logic. This changes forces the output to standard out (rather than generate a .cpp file, which is the new default for the rewriter).
Ted Kremenek [Wed, 26 Mar 2008 21:51:44 +0000 (21:51 +0000)]
Added test case for static analyzer to detect uses of uninitialized pointers as receivers in Objective-C message expressions.
Added test case directory "Analysis-Apple" which is only run on Apple (darwin) machines.
Ted Kremenek [Tue, 25 Mar 2008 22:35:32 +0000 (22:35 +0000)]
Added hacked version of ccc script used to invoke the static analyzer. This
will gradually get pruned down, as it doesn't need to be as functional as
'ccc'.