Chris Lattner [Mon, 20 Oct 2008 07:00:43 +0000 (07:00 +0000)]
significantly simplify and clean up error recovery in
ParseObjCPropertyAttribute. Before, on this code (where
a comma was forgotten):
@property (readonly getter=isAwesome) int _awesome;
we emitted:
crash.m:9:11: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
^
crash.m:9:37: error: type name requires a specifier or qualifier
@property (readonly getter=isAwesome) int _awesome;
^
crash.m:9:37: error: expected identifier or '('
crash.m:9:37: error: expected ';' at end of declaration list
crash.m:9:1: error: @property requires fields to be named
@property (readonly getter=isAwesome) int _awesome;
^
now we emit:
crash.m:9:21: error: expected ')'
@property (readonly getter=isAwesome) int _awesome;
^
crash.m:9:11: error: to match this '('
@property (readonly getter=isAwesome) int _awesome;
^
Chris Lattner [Mon, 20 Oct 2008 06:15:13 +0000 (06:15 +0000)]
simplify some code by using ExpectAndConsume. When an error
occurs, skip to an @ or ; instead of to a } or ;. Properties
don't necessarily live in {}'s.
Chris Lattner [Mon, 20 Oct 2008 05:57:40 +0000 (05:57 +0000)]
fix some minor error recovery bugs in ParseObjCInterfaceDeclList
where it would reject @required in non-protocols, but then go
ahead and tag methods with required anyway. Instead, if we see
this in something other than a protocol, just ignore the request.
Also, improve error recovery a bit when we see something bogus
inside an interface.
Chris Lattner [Mon, 20 Oct 2008 02:05:46 +0000 (02:05 +0000)]
Fix a parser bug where we let attributes interfere with our disambiguation
of whether a '(' was a grouping paren or the start of a function declarator.
This is PR2796.
Now we eat the attribute before deciding whether the paren is grouping or
not, then apply it to the resultant decl or to the first argument as needed.
One somewhat surprising aspect of this is that attributes interact with
implicit int in cases like this:
void a(x, y) // k&r style function
void b(__attribute__(()) x, y); // function with two implicit int arguments
void c(x, __attribute__(()) y); // error, can't have attr in identifier list.
Change a couple of cast<> to reinterpret_cast<>.
The casts<> require that "Decl.h" is included before "Type.h", use reinterpret_cast<> to remove that kind of dependency.
Daniel Dunbar [Sun, 19 Oct 2008 02:04:16 +0000 (02:04 +0000)]
Improve attribute parsing & tests.
- Support noreturn on function-typed variables.
- Extend isFunctionOrMethod to return true for K&R functions and
provide hasFunctionProto to check if a decl has information about
its arguments. This code needs some serious cleaning, but works.
Ted Kremenek [Sat, 18 Oct 2008 04:08:49 +0000 (04:08 +0000)]
Function calls and ObjC message expressions can be used in a lvalue context if they return a structure. E.g foo().x == 1. We don't really support, however, such temporaries yet in the environment or the store.
Ted Kremenek [Sat, 18 Oct 2008 03:49:51 +0000 (03:49 +0000)]
retain/release checker: Check if a tracked value escapes if we also try binding it to the store and the store doesn't support that binding (i.e., it cannot track it). This has the nice feature that the checker will automatically get more powerful if we use a more powerful store model.
Ted Kremenek [Fri, 17 Oct 2008 22:23:12 +0000 (22:23 +0000)]
When conjuring symbols to recover path-sensitivity, don't conjure symbols that represent an entire struct. We need to implement struct temporaries as an actual "region", and then bind symbols to the FieldRegion of those temporaries.
Daniel Dunbar [Fri, 17 Oct 2008 21:58:32 +0000 (21:58 +0000)]
Lift CodeGenFunction::EmitPredefinedFunctioName out of EmitPredefinedLValue.
- Shouldn't assume predefined expr is a function printing one.
- Uses CGM functionality to cache function names per module.
Ted Kremenek [Fri, 17 Oct 2008 21:22:20 +0000 (21:22 +0000)]
Enhance "Assumption" logic in BasicConstraintManager when reasoning about regions and symbolic regions. When assuming whether or not a location is non-null, walk up the region hierarchy until we hit a symbolic region (and test it for null). This may not be the end all solution, as the notion of what a "symbolic region" is really belongs in the specific subclass of StoreManager.
Ted Kremenek [Fri, 17 Oct 2008 20:28:54 +0000 (20:28 +0000)]
- constify some uses of MemRegion* (MemRegion should be immutable).
- Added new region "SymbolicRegion", which maps symbol values to the region domain.
- Enhanced BasicStore::getFieldLValue() to return a FieldRegion (using SymbolicRegion)
- Added some utility methods to GRState for fetch svals from the store.
- Fixed regression in CheckNSError (we weren't getting the value bound to the parameter)
Ted Kremenek [Fri, 17 Oct 2008 17:24:14 +0000 (17:24 +0000)]
"Implement" GRExprEngine::VisitLValue for ObjCPropertyRefExpr. This is only a bandid; we need to properly handle properties by using locv/nonloc objects and specially handling property assignments in the transfer function for BinaryOperator.
Daniel Dunbar [Fri, 17 Oct 2008 07:30:50 +0000 (07:30 +0000)]
Fix bug in Obj-C type encoding for structures.
- Mechanism for detecting if a structure should be expanded wasn't
reliable. Simplified by just keeping track of what we should be
expanding.
- This fixes a bug in using NSInvocation to invoke a method which
returned a structure, which in used by Key Value Observing, which
in the end, caused a miscompile in poor little Sketch.
Daniel Dunbar [Fri, 17 Oct 2008 01:07:56 +0000 (01:07 +0000)]
Quick patch for PR2784, assert genereting debug info for opaque
structure.
- I'm not sure yet about the behavior, but this at least prevents the
crash.
Ted Kremenek [Fri, 17 Oct 2008 00:51:01 +0000 (00:51 +0000)]
Remove lval::FieldOffset, lval::ArrayOffset. These will be replaced with regions.
Remove GRExprEngine::getLVal and RValues::MakeVal.
Enhance StoreManager "GetLValue" methods to dispatch for specific kinds of lvalue queries, as opposed to interogating the expression tree (GRExprEngine already does this).
Added FIXMEs. In particular, we no longer "assume" that a base pointer in a field/array access is null (this logic was removed). Perhaps we should do this when fetching the lvalue for fields and array elements?
Daniel Dunbar [Thu, 16 Oct 2008 16:54:18 +0000 (16:54 +0000)]
Add --disable-free flag to clang.
- Disables the freeing of the ASTContext and the TranslationUnit
after parsing & sema.
- Primarily for timing the impact on -fsyntax-only timings.
Zhongxing Xu [Thu, 16 Oct 2008 06:09:51 +0000 (06:09 +0000)]
This is the first step to build a better evaluation model for GRExprEngine. A
new VisitLValue method is added to replace the old VisitLVal. The semantics
model becomes more explicit to separate rvalue evaluation from lvalue
evaluation.
Daniel Dunbar [Thu, 16 Oct 2008 03:51:50 +0000 (03:51 +0000)]
Teach tryEvaluate that fabs, copysign, and unary +/- are constants for
floats.
- With testcase, which also has some other things GCC folds but we
don't commented out in it.
Daniel Dunbar [Thu, 16 Oct 2008 02:34:03 +0000 (02:34 +0000)]
Implement #pragma pack use in structure packing. The general approach
is to encode the state of the #pragma pack stack as an attribute when
the structure is declared.
- Extend PackedAttr to take an alignment (in bits), and reuse for
both __attribute__((packed)) (which takes no argument, instead
packing tightly (to "minimize the memory required") and for #pragma
pack (which allows specification of the maximum alignment in
bytes). __attribute__((packed)) is just encoded as Alignment=1.
This conflates two related but different mechanisms, but it didn't
seem worth another attribute.
- I have attempted to follow the MSVC semantics as opposed to the gcc
ones, since if I understand correctly #pragma pack originated with
MSVC. The semantics are generally equivalent except when the stack
is altered during the definition of a structure; its not clear if
anyone does this in practice. See testcase if curious.
Issue a warning when there's an ambiguous function declarator (that could be a direct initializer for a variable defition).
Idea originated from here: http://thread.gmane.org/gmane.comp.gcc.devel/101524
Ted Kremenek [Wed, 15 Oct 2008 05:23:41 +0000 (05:23 +0000)]
Enhance dead store checker to not flag preincrements to dead variables where the preincrement is a subexpression, e.g. foo(++x); This can cause false negatives, but will remove a whole class of false positives.
Simplify handling of struct/union/class tags.
Instead of using two sets of Decl kinds (Struct/Union/Class and CXXStruct/CXXUnion/CXXClass), use one 'Record' and one 'CXXRecord' Decl kind and make tag kind a property of TagDecl.
Cleans up the code a bit and better reflects that Decl class structure.
Steve Naroff [Tue, 14 Oct 2008 22:18:38 +0000 (22:18 +0000)]
Downgrade incompatibilities with objc qualified types (e.g. id <P>) to warnings.
Note: One day, we should consider moving the actual diags to ObjCQualifiedIdTypesAreCompatible(), since it has more information on the actual problem. GCC currently emits slightly more instructive errors for some cases involving protocols. I added a FIXME to the code.
Daniel Dunbar [Tue, 14 Oct 2008 05:35:18 +0000 (05:35 +0000)]
Add Sema implementation of #pragma pack stack.
- Follows the MSVC (original) implementation, including support of
pack(show) (useful for testing).
- Implements support for named pack records which gcc seems to
ignore (or implements incorrectly).
- Not currently wired to anything, only functionality change is the
type checking of the pragma.
Ted Kremenek [Mon, 13 Oct 2008 21:46:42 +0000 (21:46 +0000)]
Use 'realpath' to resolve the absolute path to clang and ccc-analyzer.
Add "-analyze-headers" option to scan-build that passes the option -analyzer-opt-analyze-headers to clang.
Daniel Dunbar [Mon, 13 Oct 2008 17:02:26 +0000 (17:02 +0000)]
Lift out ABIInfo abstract base class.
- Currently still lives in CGCall.cpp but is intended to be the
target specific place for hooking ABI information.
- Select ABIInfo to use based on Target's prefix and pointer width.