Douglas Gregor [Wed, 22 Oct 2008 14:17:15 +0000 (14:17 +0000)]
Implement ranking of standard conversion sequences by their qualification
conversions (e.g., comparing int* -> const int* against
int* -> const volatile int*); see C++ 13.3.3.2p3 bullet 3.
Add Sema::UnwrapSimilarPointerTypes to simplify the control flow of
IsQualificationConversion and CompareQualificationConversion (and fix
the handling of the int* -> volatile int* conversion in the former).
Chris Lattner [Wed, 22 Oct 2008 03:52:06 +0000 (03:52 +0000)]
some minor cleanups to ParseObjCTypeName:
1. Remove a bogus assertion, clients other than sema can return a
null pointer from actions that result in ParseTypeName returning null.
2. Remove dead RParenLoc variable.
3. Simplify control flow handling error conditions.
4. On a major failure, we should skip until ')' not until '}'.
Douglas Gregor [Wed, 22 Oct 2008 00:38:21 +0000 (00:38 +0000)]
Fix a thinko in the qualification-conversion check when the qualificaitons are disjoint, and add some overloading-based tests of qualification conversions
Daniel Dunbar [Tue, 21 Oct 2008 23:49:24 +0000 (23:49 +0000)]
[LLVM up] Add basic -S option to clang.
- Split backend related consumer out into Backend.cpp, replaces
LLVMCodeGenWriter.
- Structure follows llvm-gcc to some extent.
- Still need to implement all the options which impact code
generation and the optimization passes which llvm-gcc uses at
various levels.
Changes:
- Sema::IsQualificationConversion determines whether we have a qualification
conversion.
- Sema::CheckSingleAssignment constraints now follows the C++ rules in C++,
performing an implicit conversion from the right-hand side to the type of
the left-hand side rather than checking based on the C notion of
"compatibility". We now rely on the implicit-conversion code to
determine whether the conversion can happen or
not. Sema::TryCopyInitialization has an ugly reference-related
hack to cope with the initialization of references, for now.
- When building DeclRefExprs, strip away the reference type, since
there are no expressions whose type is a reference. We'll need to
do this throughout Sema.
- Expr::isLvalue now permits functions to be lvalues in C++ (but not
in C).
Steve Naroff [Tue, 21 Oct 2008 10:37:50 +0000 (10:37 +0000)]
Fix <rdar://problem/6261178> clang-on-xcode: [sema] multiple method warning is over enthusiastic.
Fix <rdar://problem/6265257> warnings for ambiguous message send swamp other warnings.
Reworked Sema::MatchTwoMethodDeclarations() to optionally match based on method size and alignment (the default in GCC). Changed Sema::LookupInstanceMethodInGlobalPool() to use this feature.
Added -Wno-struct-selector-match to driver, however didn't hook it up yet. Added a FIXME that says this.
Zhongxing Xu [Tue, 21 Oct 2008 06:54:23 +0000 (06:54 +0000)]
Localize the special processing of array variable inside
GRExprEngine::VisitCast() so that other parts of the analyzer can be ignorant.
When we cast "array of type T" to "pointer to T", we get the loc::MemRegionVal
corresponding to the array variable. This is sufficient for BasicStore, but not
for RegionStore. RegionStore should get the element region for the first array
element in the cast. So next comes to the revamping of transfer functions for
different store model.
Ted Kremenek [Mon, 20 Oct 2008 23:40:25 +0000 (23:40 +0000)]
Further improve path-sensitivity with divide-by-zero checking by assuming that a denominator cannot be zero even when the result of an '/' or '%' expression is unknown.
Steve Naroff [Mon, 20 Oct 2008 18:19:10 +0000 (18:19 +0000)]
Sema::CheckCompareOperands() and ASTContext::mergeTypes(): Change handling of ObjC qualified id types to be consistent with gcc. This changes a handful of test case errors into warnings (diff will tell you which cases have changed).
Chris Lattner [Mon, 20 Oct 2008 07:15:22 +0000 (07:15 +0000)]
More property attribute recovery improvements. Instead of this:
crash.m:8:12: error: type name requires a specifier or qualifier
@property (readonlyx, getter=isAwesome) int _awesome;
^
crash.m:8:29: error: expected ';' at end of declaration list
@property (readonlyx, getter=isAwesome) int _awesome;
^
crash.m:8:39: error: expected identifier or '('
@property (readonlyx, getter=isAwesome) int _awesome;
^
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.