Commit Graph

205 Commits

Author SHA1 Message Date
Douglas Gregor ffe14e3712 If we attempt to add a constructor template specialization that looks
like a copy constructor to the overload set, just ignore it. This
ensures that we don't try to use such a constructor as a copy
constructor *without* triggering diagnostics at the point of
declaration.

Note that we *do* diagnose such copy constructors when explicitly
written by the user (e.g., as an explicit specialization).

llvm-svn: 88733
2009-11-14 01:20:54 +00:00
Mike Stump 53f9ded62b Refine volatile handling, specifically, we must have the canonical
type to look at the volatile specifier.  I found these all from just
hand auditing the code.

llvm-svn: 85967
2009-11-03 23:25:48 +00:00
Eli Friedman 06ed2a5c94 Remove default argument for ImpCastExprToType. Add appropriate argument
to all callers.  Switch a few other users of CK_Unknown to proper cast 
kinds.

Note that there are still some situations where we end up with 
CK_Unknown; they're pretty easy to find with grep. There 
are still a few missing conversion kinds, specifically 
pointer/int/float->bool and the various combinations of real/complex 
float/int->real/complex float/int.

llvm-svn: 84623
2009-10-20 08:27:19 +00:00
Edward O'Callaghan 93135aad29 Fix for PR5190, Credit to Zhanyong Wan.
llvm-svn: 84346
2009-10-17 19:32:54 +00:00
Chris Lattner a96d427966 Implement PR4407 - missing warnings on case value overflow,
patch by Zhanyong Wan!

llvm-svn: 84259
2009-10-16 16:45:22 +00:00
Chris Lattner 1a6babf1f4 make the diagnostic in the 'unused result' warning more precise
about the reason, rdar://7186119.

llvm-svn: 83940
2009-10-13 04:53:48 +00:00
John McCall d5707abdfd Implement -Wparentheses: warn about using assignments in contexts that require
conditions.  Add a fixit to insert the parentheses.  Also fix a very minor
possible memory leak in 'for' conditions.

Fixes PR 4876 and rdar://problem/7289172

llvm-svn: 83907
2009-10-12 21:59:07 +00:00
Douglas Gregor 78b691a458 When the return type of a function is dependent, don't perform any
of the flow-control checks for falling off the end of a function,
since the return type may instantiate to void. Similarly, if a
return statement has an expression and the return type of the function
is void, don't complain if the expression is type-dependent, since
that type could instantiate to void.

Fixes PR5071.

llvm-svn: 83222
2009-10-01 23:25:31 +00:00
John McCall 8ccfcb51ee Refactor the representation of qualifiers to bring ExtQualType out of the
Type hierarchy.  Demote 'volatile' to extended-qualifier status.  Audit our
use of qualifiers and fix a few places that weren't dealing with qualifiers
quite right;  many more remain.

llvm-svn: 82705
2009-09-24 19:53:00 +00:00
Mike Stump 11289f4280 Remove tabs, and whitespace cleanups.
llvm-svn: 81346
2009-09-09 15:08:12 +00:00
Fariborz Jahanian f15d4b6050 This patch does the following.
1) Issue digsnostics in non-fragile ABI, when an expression
   evaluates to an interface type (except when it is used to
   access a non-fragile ivar).
2) Issue unsupported error in fragile ABI when an expression
   evaluates to an interface type (except when it is used to
   access a fragile ivar).

llvm-svn: 80860
2009-09-03 00:43:07 +00:00
Fariborz Jahanian 9a84665921 Using "ObjCImplicitSetterGetterRefExpr" instead of "ObjCImplctSetterGetterRefExpr".
A field rename and more comments.

llvm-svn: 79537
2009-08-20 17:02:02 +00:00
Daniel Dunbar 58bc48c14e Switch to SmallString::str from SmallString::c_str.
- Several FIXMEs due to non-Twinification of IRBuilder.

llvm-svn: 79455
2009-08-19 20:04:03 +00:00
Fariborz Jahanian 88cc2340de Renamed ObjCKVCRefExpr to ObjCImplctSetterGetterRefExpr.
Removed an unnecessary loop to get to setters incoming
argument. Added DoxyGen comments. Still more work
to do in this area (WIP).

llvm-svn: 79365
2009-08-18 20:50:23 +00:00
Anders Carlsson a192947509 Change ActOnReturnStmt to not take a FullExprArg. Instead, Sema will wrap the return expr inside a CXXExprWithTemporaries if needed.
llvm-svn: 79342
2009-08-18 16:11:00 +00:00
Chris Lattner 2ba5ca9d4f Improve the diagnostic emitted when an unused ObjC property getter
is found.  Instead of complaining about a generic "unused expr",
emit:
t.m:7:3: warning: property access result unused - getters should not have side effects

While objc property getters *could* have side effects, according to
the language best practices, they *shouldn't*.  Hopefully the
diagnostic now gets this across.

llvm-svn: 79192
2009-08-16 16:57:27 +00:00
Fariborz Jahanian 2e4a46b745 objc2's foreach statement's selector type can be
a block pointer too.

llvm-svn: 79050
2009-08-14 21:53:27 +00:00
Anders Carlsson 1682af5bac More warnings for unused expressions.
llvm-svn: 77763
2009-08-01 01:39:59 +00:00
Anders Carlsson 5c5f160c7f Diagnose unused expression results for all statements, just not compound statements.
llvm-svn: 77631
2009-07-30 22:39:03 +00:00
Anders Carlsson 59a2ab9720 Factor code out into a DiagnoseUnusedExprResult function.
llvm-svn: 77628
2009-07-30 22:17:18 +00:00
Ted Kremenek c23c7e6a51 Change uses of:
Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsRecordType() -> Type::getAs<RecordType>()
  Type::getAsPointerType() -> Type::getAs<PointerType>()
  Type::getAsBlockPointerType() -> Type::getAs<BlockPointerType>()
  Type::getAsLValueReferenceType() -> Type::getAs<LValueReferenceType>()
  Type::getAsRValueReferenceType() -> Type::getAs<RValueReferenceType>()
  Type::getAsMemberPointerType() -> Type::getAs<MemberPointerType>()
  Type::getAsReferenceType() -> Type::getAs<ReferenceType>()
  Type::getAsTagType() -> Type::getAs<TagType>()
  
And remove Type::getAsReferenceType(), etc.

This change is similar to one I made a couple weeks ago, but that was partly
reverted pending some additional design discussion. With Doug's pending smart
pointer changes for Types, it seemed natural to take this approach.

llvm-svn: 77510
2009-07-29 21:53:49 +00:00
Sebastian Redl 63c4da01c8 Check for identical types in C++ catch expression. Patch by Erik Verbruggen.
llvm-svn: 77475
2009-07-29 17:15:45 +00:00
Ted Kremenek 8a286fbdb9 Per offline discussion with Steve Naroff, add back Type::getAsXXXType() methods
until Doug Gregor's Type smart pointer code lands (or more discussion occurs).
These methods just call the new Type::getAs<XXX> methods, so we still have
reduced implementation redundancy. Having explicit getAsXXXType() methods makes
it easier to set breakpoints in the debugger.

llvm-svn: 76193
2009-07-17 17:50:17 +00:00
Ted Kremenek e3fb4b6524 Add member template 'Type::getAs<T>', which converts a Type* to a respective T*.
This method is intended to eventually replace the individual
Type::getAsXXXType<> methods.

The motivation behind this change is twofold:

1) Reduce redundant implementations of Type::getAsXXXType() methods. Most of
them are basically copy-and-paste.

2) By centralizing the implementation of the getAs<Type> logic we can more
smoothly move over to Doug Gregor's proposed canonical type smart pointer
scheme.

Along with this patch:

a) Removed 'Type::getAsPointerType()'; now clients use getAs<PointerType>.
b) Removed 'Type::getAsBlockPointerTypE()'; now clients use getAs<BlockPointerType>.

llvm-svn: 76098
2009-07-16 19:58:26 +00:00
Steve Naroff 79d1215d83 Remove ASTContext::isObjCObjectPointerType().
Convert all clients to use the new predicate on Type.

llvm-svn: 76076
2009-07-16 15:41:00 +00:00
Argyrios Kyrtzidis b4b64ca752 Remove the ASTContext parameter from the attribute-related methods of Decl.
The implementations of these methods can Use Decl::getASTContext() to get the ASTContext.

This commit touches a lot of files since call sites for these methods are everywhere.
I used pre-tokenized "carbon.h" and "cocoa.h" headers to do some timings, and there was no real time difference between before the commit and after it.

llvm-svn: 74501
2009-06-30 02:34:44 +00:00
Anders Carlsson d2e8adfc75 Support for [class.local]p4.
llvm-svn: 74030
2009-06-24 00:28:53 +00:00
Anders Carlsson 946b86d91a [class.local] p1 and p3. Also, add back the xcodeproj file.
llvm-svn: 74027
2009-06-24 00:10:43 +00:00
Fariborz Jahanian 3fd7310d70 Use QualType to represent block's implicit return type as
to not lose its 'const/volatile' qualifier.

llvm-svn: 73795
2009-06-19 23:37:08 +00:00
Douglas Gregor 78bd61f661 Move the static DeclAttrs map into ASTContext. Fixes <rdar://problem/6983177>.
llvm-svn: 73702
2009-06-18 16:11:24 +00:00
Chris Lattner 815b70efcd add the location of the ')' in a do/while statement to DoStmt.
This fixes a source range problem reported by Olaf Krzikalla.

llvm-svn: 73266
2009-06-12 23:04:47 +00:00
Chris Lattner 6e127a6d86 Downgrade an error about "return in a no-return function" from being
an error to being a warning that defaults to error.  If you want this to
be a warning, you have to explicitly pass -Winvalid-noreturn to clang to
map it back to a warning.

llvm-svn: 72669
2009-05-31 19:32:13 +00:00
Anders Carlsson 5de832ecfa ActOnReturnStmt should also take a FullExprArg.
llvm-svn: 72641
2009-05-30 21:42:34 +00:00
Jay Foad 7d0479f2c2 Use v.data() instead of &v[0] when SmallVector v might be empty.
llvm-svn: 72210
2009-05-21 09:52:38 +00:00
Anders Carlsson ee13926fbe Make ActOnWhileStmt take a FullExprArg for the condition expr.
llvm-svn: 71990
2009-05-17 21:22:26 +00:00
Anders Carlsson 24824e5009 Make ActOnExprStmt take a FullExprArg.
llvm-svn: 71989
2009-05-17 21:11:30 +00:00
Anders Carlsson 5262746c28 Add the FullExprArg wrapper and use it for if statement conditions.
llvm-svn: 71982
2009-05-17 18:26:53 +00:00
Mike Stump 87c57acfb7 Reflow some comments.
llvm-svn: 71936
2009-05-16 07:39:55 +00:00
Douglas Gregor 30776d419f Template instantiation for IndirectGotoStmt. Now my life is complete.
llvm-svn: 71917
2009-05-16 00:20:29 +00:00
Douglas Gregor 2a2d00f041 Template instantiation for switch statements
llvm-svn: 71916
2009-05-15 23:57:33 +00:00
Douglas Gregor 5d13868263 Template instantiation for "for" loops
llvm-svn: 71901
2009-05-15 22:12:32 +00:00
Douglas Gregor 3daa82dba0 Template instantiation for do-while statements.
llvm-svn: 71899
2009-05-15 21:56:04 +00:00
Douglas Gregor 8a930c3b73 Template instantiation for WhileStmt and CXXConditionDeclExpr.
llvm-svn: 71896
2009-05-15 21:45:53 +00:00
Douglas Gregor 9d73cabf22 Template instantiation for "if" statements. Also:
- Skip semantic analysis of the "if" condition if it is type-dependent.
  - Added the location of the "else" keyword into IfStmt, so that we can
    provide it for type-checking after template instantiation.

llvm-svn: 71875
2009-05-15 18:53:42 +00:00
Anders Carlsson 19b8c4ce36 Instantiate return statements.
llvm-svn: 71825
2009-05-15 00:48:27 +00:00
Chris Lattner cc1cde9c57 allow references to the larger value in a tied constraint
from the asm string, but reject references to the smaller one.

llvm-svn: 70679
2009-05-03 08:32:32 +00:00
Chris Lattner 97de21f754 code cleanup, avoid shadowing i.
llvm-svn: 70678
2009-05-03 08:24:16 +00:00
Eli Friedman 47e785783c Don't insert an extra ParenExpr around asm operands.
llvm-svn: 70673
2009-05-03 07:49:42 +00:00
Chris Lattner cb66c73a48 If we have mismatched integer tied operands, but the operand
number is not mentioned in the asm string, let it past sema. 
Right now these are currently rejected by the llvm code generator
but this will be fixed next.

llvm-svn: 70670
2009-05-03 07:04:21 +00:00
Chris Lattner 28b05c8249 avoid a crash when we encounter a implicit cast of the paren expr due to
promotions.  This should be fixed by not modeling asm operands (which 
require the ()'s according to the grammar) as not being paren exprs.

llvm-svn: 70668
2009-05-03 06:50:40 +00:00
Chris Lattner 2c295cfee8 rename some variables, improve comments.
llvm-svn: 70663
2009-05-03 05:59:17 +00:00
Chris Lattner 34b51e88ec refactor matched operand type checking to happen after the AsmStmt is created,
no functionality change.

llvm-svn: 70662
2009-05-03 05:55:43 +00:00
Anders Carlsson b781bcdc30 Replace more release+static_cast with takeAs.
llvm-svn: 70567
2009-05-01 19:49:17 +00:00
Anders Carlsson 3cbc85985a Replace a bunch of static_cast + release with takeAs.
llvm-svn: 70566
2009-05-01 19:30:39 +00:00
Mike Stump 56ed2eab9e Fixup Sema and CodeGen for block literal attributes when the return
type and argument types are missing, and let return type deduction
happen before we give errors for returning from a noreturn block.
Radar 6441502

llvm-svn: 70413
2009-04-29 21:40:37 +00:00
Mike Stump 88788feddd Sema and CodeGen support for attributes on blocks. Radar 6441502
llvm-svn: 70403
2009-04-29 19:03:13 +00:00
Mike Stump d00bc1a275 Implement sema checking for noreturn.
llvm-svn: 70353
2009-04-29 00:43:21 +00:00
Sebastian Redl 4de47b445b Improve validation of C++ exception handling: diagnose throwing incomplete types and jumps into protected try-catch scopes.
llvm-svn: 70242
2009-04-27 20:27:31 +00:00
Chris Lattner 574428e4db implement PR4077: [Linux kernel] inscrutable error on inline asm input/output constraint mismatch
Before we emitted:

$ clang t.c -S -m64 
llvm: error: Unsupported asm: input constraint with a matching output constraint of incompatible type!

Now we produce:
$ clang t.c -S -m64 
t.c:5:40: error: unsupported inline asm: input with type 'unsigned long' matching output with type 'int'
  asm volatile("foo " : "=a" (a) :"0" (b));
                             ~~~      ~^~

llvm-svn: 70142
2009-04-26 18:22:24 +00:00
Chris Lattner 4c92b51089 in a tied operand, don't copy over the name or constraint string, just the flags.
llvm-svn: 70137
2009-04-26 18:05:25 +00:00
Chris Lattner c16d476b30 pull operands names "[foo]" into ConstraintInfo.
llvm-svn: 70136
2009-04-26 17:57:12 +00:00
Chris Lattner c3f4c7b1c5 pull the constraint string into the ConstraintInfo struct
instead of passing it around in addition to it.

llvm-svn: 70135
2009-04-26 17:19:08 +00:00
Chris Lattner d9725f7041 change TargetInfo::ConstraintInfo to be a struct that contains
the enum along with some other data.

llvm-svn: 70114
2009-04-26 07:16:29 +00:00
Chris Lattner f0b64d73a8 split ObjC and C++ Statements out into their own headers.
llvm-svn: 70105
2009-04-26 01:32:48 +00:00
Chris Lattner 3501d43a10 implement semantic analysis for @synchronized, fixing a crash on invalid
rdar://6810940 - @synchronized has no sema checks

llvm-svn: 69670
2009-04-21 06:11:25 +00:00
Chris Lattner c70dd56477 add support for goto checking and @synchronized blocks,
rdar://6810106

llvm-svn: 69667
2009-04-21 06:01:00 +00:00
Chris Lattner 9fecd743ca add a new Sema::CurFunctionNeedsScopeChecking bool that is used to avoid
calling into the jump checker when a function or method is known to contain
no VLAs or @try blocks.

llvm-svn: 69509
2009-04-19 05:21:20 +00:00
Chris Lattner 34d9a51892 Add location info for indirect goto.
llvm-svn: 69497
2009-04-19 01:04:21 +00:00
Chris Lattner 96b3139773 abstract the SwitchStack for blocks just like we do the goto labels.
This fixes a crash on invalid (test10). rdar://6805469

llvm-svn: 69465
2009-04-18 20:10:59 +00:00
Chris Lattner 3318e86541 refactor some code, adding a new getLabelMap() accessor method
so that clients can't poke the function-local one when they really
want the current block label.  No functionality change.

llvm-svn: 69463
2009-04-18 20:01:55 +00:00
Chris Lattner a2ca03a908 if we already know that a decl is invalid in an @catch, don't verify its type.
llvm-svn: 68925
2009-04-12 23:26:56 +00:00
Chris Lattner cbafe8d75c add a new isNull() method to DeclGroupRef.
llvm-svn: 68909
2009-04-12 20:13:14 +00:00
Sebastian Redl 42e92c4bc3 Parse deleted member functions. Parsing member declarations goes through a different code path that I forgot previously.
Implement the rvalue reference overload dance for returning local objects. Returning a local object first tries to find a move constructor now.
The error message when no move constructor is defined (or is not applicable) and the copy constructor is deleted is quite ugly, though.

llvm-svn: 68902
2009-04-12 17:16:29 +00:00
Chris Lattner 5bbb3c8ad9 Push DeclGroup much farther throughout the compiler. Now the various
productions (except the already broken ObjC cases like @class X,Y;) in 
the parser that can produce more than one Decl return a DeclGroup instead
of a Decl, etc.

This allows elimination of the Decl::NextDeclarator field, and exposes
various clients that should look at all decls in a group, but which were
only looking at one (such as the dumper, printer, etc).  These have been
fixed.

Still TODO:

1) there are some FIXME's in the code about potentially using
DeclGroup for better location info.
2) ParseObjCAtDirectives should return a DeclGroup due to @class etc.
3) I'm not sure what is going on with StmtIterator.cpp, or if it can
   be radically simplified now.
4) I put a truly horrible hack in ParseTemplate.cpp.

I plan to bring up #3/4 on the mailing list, but don't plan to tackle
#1/2 in the short term.

llvm-svn: 68002
2009-03-29 16:50:03 +00:00
Chris Lattner 83f095cc7e Introduce a new OpaquePtr<N> struct type, which is a simple POD wrapper for a
pointer.  Its purpose in life is to be a glorified void*, but which does not
implicitly convert to void* or other OpaquePtr's with a different UID.

Introduce Action::DeclPtrTy which is a typedef for OpaquePtr<0>.  Change the 
entire parser/sema interface to use DeclPtrTy instead of DeclTy*.  This
makes the C++ compiler enforce that these aren't convertible to other opaque
types.

We should also convert ExprTy, StmtTy, TypeTy, AttrTy, BaseTy, etc,
but I don't plan to do that in the short term.

The one outstanding known problem with this patch is that we lose the 
bitmangling optimization where ActionResult<DeclPtrTy> doesn't know how to
bitmangle the success bit into the low bit of DeclPtrTy.  I will rectify
this with a subsequent patch.

llvm-svn: 67952
2009-03-28 19:18:32 +00:00
Chris Lattner 529efc74ad rename some methods.
llvm-svn: 67923
2009-03-28 06:33:19 +00:00
Eli Friedman 6568eef9f9 Sanity-check argument to indirect goto.
llvm-svn: 67746
2009-03-26 07:32:37 +00:00
Eli Friedman 8d7ff4098c Fix for PR3869: actually enforce that the argument of an indirect goto
is of type void*.  I'll try to add the appropriate checking later.

llvm-svn: 67721
2009-03-26 00:18:06 +00:00
Chris Lattner cda4d7e196 introduce a new -fheinous-gnu-extensions flag that enables really
really horrible extensions that are disabled by default but that can
be accepted by -fheinous-gnu-extensions (but which always emit a 
warning when enabled).

As our first instance of this, implement PR3788/PR3794, which allows
non-lvalues in inline asms in contexts where lvalues are required. bleh.

llvm-svn: 66910
2009-03-13 17:38:01 +00:00
Steve Naroff cfb6cf4c02 Reimplement fix for <rdar://problem/6451399> problems with labels and blocks.
This solution is much simpler (and doesn't add any per-scope overhead, which concerned Chris). 

The only downside is the LabelMap is now declared in two places (Sema and BlockSemaInfo). My original fix tried to unify the LabelMap in "Scope" (which would support nested functions in general). In any event, this fixes the bug given the current language definition. If/when we decide to support GCC style nested functions, this will need to be tweaked.

llvm-svn: 66896
2009-03-13 16:03:38 +00:00
Steve Naroff 846b1ec40f Remove ActiveScope (revert http://llvm.org/viewvc/llvm-project?view=rev&revision=65694 and http://llvm.org/viewvc/llvm-project?view=rev&revision=66741).
Will replace with something better today...

llvm-svn: 66893
2009-03-13 15:38:40 +00:00
Chris Lattner 0cdaa2e525 position the caret properly on asm string diagnostics, e.g.:
Sema/asm.c:64:9: error: invalid % escape in inline assembly string
  asm("%!" : );   // expected-error {{invalid % escape in inline assembly string}}
      ~~^~

llvm-svn: 66606
2009-03-10 23:57:07 +00:00
Chris Lattner d8c7ba278e add plumbing to report diagnostics back through sema for malformed asmstrings.
llvm-svn: 66598
2009-03-10 23:41:04 +00:00
Chris Lattner 34a2209177 Change Parser::ParseCaseStatement to use an iterative approach to parsing
multiple sequential case statements instead of doing it with recursion.  This
fixes a problem where we run out of stack space parsing 100K directly nested
cases.

There are a couple other problems that prevent this from being useful in 
practice (right now the example only parses correctly with -disable-free and
doesn't work with -emit-llvm), but this is a start.

I'm not including a testcase because it is large and uninteresting for 
regtesting.

Sebastian, I would appreciate it if you could scrutinize the smart pointer 
gymnastics I do.

llvm-svn: 66011
2009-03-04 04:23:07 +00:00
Steve Naroff 013813dd5d Change a warning to an error...
llvm-svn: 65978
2009-03-03 23:13:51 +00:00
Steve Naroff 27ed6f6766 Fix <rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements.
llvm-svn: 65969
2009-03-03 21:16:54 +00:00
Steve Naroff 39d6fba0d6 Fix <rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements.
llvm-svn: 65968
2009-03-03 20:59:06 +00:00
Steve Naroff 371b8fb4c3 Fix <rdar://problem/6640991> Exception handling executes wrong clause (Daniel, please verify).
Also necessary to fix:

<rdar://problem/6632061> [sema] non object types should not be allowed in @catch statements
<rdar://problem/6252237> [sema] qualified id should be disallowed in @catch statements

llvm-svn: 65964
2009-03-03 19:52:17 +00:00
Steve Naroff f3833d70be Fix <rdar://problem/6635908> crash on invalid
llvm-svn: 65909
2009-03-03 00:45:38 +00:00
Daniel Dunbar 947bca2cc9 ObjCAtCatchStmt's ParamStmt is always a DeclStmt.
llvm-svn: 65759
2009-03-01 04:28:32 +00:00
Steve Naroff d123bd05ca Fix <rdar://problem/6451399> problems with labels and blocks.
- Move the 'LabelMap' from Sema to Scope. To avoid layering problems, the second element is now a 'StmtTy *', which makes the LabelMap a bit more verbose to deal with.
- Add 'ActiveScope' to Sema. Managed by ActOnStartOfFunctionDef(), ObjCActOnStartOfMethodDef(), ActOnBlockStmtExpr().
- Changed ActOnLabelStmt(), ActOnGotoStmt(), ActOnAddrLabel(), and ActOnFinishFunctionBody() to use the new ActiveScope.
- Added FIXME to workaround in ActOnFinishFunctionBody() (for dealing with C++ nested functions).  

llvm-svn: 65694
2009-02-28 16:48:43 +00:00
Anders Carlsson b8482c5d5d Match gcc and always perform array/function conversion for asm input exprs. Fixes PR3641.
llvm-svn: 65256
2009-02-22 02:11:23 +00:00
Chris Lattner 237f27573f Several related changes:
1) implement parser and sema support for reading and verifying attribute(warnunusedresult).
2) rename hasLocalSideEffect to isUnusedResultAWarning, inverting the sense
   of its result.
3) extend isUnusedResultAWarning to directly return the loc and range 
   info that should be reported to the user.  Make it substantially more
   precise in some cases than what was previously reported.
4) teach isUnusedResultAWarning about CallExpr to decls that are 
   pure/const/warnunusedresult, fixing a fixme.
5) change warn_attribute_wrong_decl_type to not pass in english strings, instead,
   pass in integers and use %select.

llvm-svn: 64543
2009-02-14 07:37:35 +00:00
Douglas Gregor 4feb36de04 Remove DeclGroupOwningRef, since we intend for declarations to be owned
by DeclContexts (always) rather than by statements. 

DeclContext currently goes out of its way to avoid destroying any
Decls that might be owned by a DeclGroupOwningRef. However, in an
error-recovery situation, a failure in a declaration statement can
cause all of the decls in a DeclGroupOwningRef to be destroyed after
they've already be added into the DeclContext. Hence, DeclContext is
left with already-destroyed declarations, and bad things happen. This
problem was causing failures that showed up as assertions on x86 Linux
in test/Parser/objc-forcollection-neg-2.m.

llvm-svn: 64474
2009-02-13 19:06:18 +00:00
Steve Naroff c49b22a5c8 Sema::ActOnObjCAtThrowStmt(): return from recently added errors. Thanks Chris!
llvm-svn: 64389
2009-02-12 18:09:32 +00:00
Steve Naroff 0fa412cc6d Turn warning into error. Minor incompatibility with GCC (for scalar types, GCC only produces a warning).
llvm-svn: 64375
2009-02-12 15:54:59 +00:00
Steve Naroff 5ee2c02ac6 Fix <rdar://problem/6243503> [sema] @throw; accepted outside catch block.
llvm-svn: 64318
2009-02-11 20:05:44 +00:00
Steve Naroff d5581d2af1 Fix <rdar://problem/6206858> [sema] type check @throw statements.
Added a FIXME to handle 'rethrow' check.

llvm-svn: 64308
2009-02-11 17:45:08 +00:00
Ted Kremenek 5a201951ca Overhaul of Stmt allocation:
- Made allocation of Stmt objects using vanilla new/delete a *compiler
  error* by making this new/delete "protected" within class Stmt.
- Now the only way to allocate Stmt objects is by using the new
  operator that takes ASTContext& as an argument.  This ensures that
  all Stmt nodes are allocated from the same (pool) allocator.
- Naturally, these two changes required that *all* creation sites for
  AST nodes use new (ASTContext&).  This is a large patch, but the
  majority of the changes are just this mechanical adjustment.
- The above changes also mean that AST nodes can no longer be
  deallocated using 'delete'.  Instead, one most do
  StmtObject->Destroy(ASTContext&) or do
  ASTContextObject.Deallocate(StmtObject) (the latter not running the
  'Destroy' method).

Along the way I also...
- Made CompoundStmt allocate its array of Stmt* using the allocator in
  ASTContext (previously it used std::vector).  There are a whole
  bunch of other Stmt classes that need to be similarly changed to
  ensure that all memory allocated for ASTs comes from the allocator
  in ASTContext.
- Added a new smart pointer ExprOwningPtr to Sema.h.  This replaces
  the uses of llvm::OwningPtr within Sema, as llvm::OwningPtr used
  'delete' to free memory instead of a Stmt's 'Destroy' method.

Big thanks to Doug Gregor for helping with the acrobatics of making
'new/delete' private and the new smart pointer ExprOwningPtr!

llvm-svn: 63997
2009-02-07 01:47:29 +00:00
Mike Stump 82f071faa7 Add support for blocks with explicit return types.
llvm-svn: 63784
2009-02-04 22:31:32 +00:00