Commit Graph

1887 Commits

Author SHA1 Message Date
Daniel Dunbar d5420e3bef Move Type::EmitImpl into header, add FIXME to make abstract.
llvm-svn: 57501
2008-10-14 16:55:17 +00:00
Daniel Dunbar 1be9f88a2f Fix test suite regression, getFloatTypeSemantics shouldn't be called
on non-float types.

llvm-svn: 57477
2008-10-14 05:41:12 +00:00
Daniel Dunbar 5460374cd9 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.

llvm-svn: 57476
2008-10-14 05:35:18 +00:00
Daniel Dunbar d9eff3d4e4 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.

llvm-svn: 57445
2008-10-13 17:02:26 +00:00
Argyrios Kyrtzidis 01622642d3 Improve the const-ness of a few methods.
No functionality change.

llvm-svn: 57417
2008-10-12 18:40:01 +00:00
Argyrios Kyrtzidis 3768ad6d58 Implement more efficient Decl <-> DeclContext conversions.
When the static type on the Decl side is a subclass of DeclContext the compiler will use a "inlinable" static_cast, instead of always using an out-of-line function call.

Note, though, that the isa<> check still uses an out-of-line function call.

llvm-svn: 57415
2008-10-12 16:14:48 +00:00
Chris Lattner f6a3bda65e make the -rewrite-test a bit more interesting: it now
wraps comments in <i> tags.  Extend rewrite tokens to support
this minimal functionality.

llvm-svn: 57409
2008-10-12 06:09:52 +00:00
Chris Lattner b6aa53b7de start implementing a token rewriter. At this point, it just reads in a file
and lets a client iterate over it. 

llvm-svn: 57407
2008-10-12 05:44:03 +00:00
Chris Lattner b11c3233d8 Change FormTokenWithChars to take the token kind to form, since all clients
were setting a kind and then forming it.  This is just a minor API cleanup, 
no functionality change.

llvm-svn: 57404
2008-10-12 04:51:35 +00:00
Chris Lattner 99e7d23455 When in keep whitespace mode, make sure to return block comments that are
unterminated.

llvm-svn: 57403
2008-10-12 04:19:49 +00:00
Chris Lattner e01e758e11 Change SkipBlockComment and SkipBCPLComment to return true when in
keep comment mode, instead of returning false.  This matches SkipWhitespace.

llvm-svn: 57402
2008-10-12 04:15:42 +00:00
Chris Lattner 4d96344c19 Add a new mode to the lexer which enables it to return all characters,
even whitespace, as tokens from the file.  This is enabled with
L->SetKeepWhitespaceMode(true) on a raw lexer.  In this mode, you too
can use clang as a really complex version of 'cat' with code like this:

  Lexer RawLex(SourceLocation::getFileLoc(SM.getMainFileID(), 0),
               PP.getLangOptions(), File.first, File.second);
  
  RawLex.SetKeepWhitespaceMode(true);
  
  Token RawTok;
  RawLex.LexFromRawLexer(RawTok);
  while (RawTok.isNot(tok::eof)) {
    std::cout << PP.getSpelling(RawTok);
    RawLex.LexFromRawLexer(RawTok);
  }

This will emit exactly the input file, with no canonicalization or other
translation.  Realistic clients actually do something with the tokens of
course :)

llvm-svn: 57401
2008-10-12 04:05:48 +00:00
Chris Lattner 924efdf623 Stop the preprocessor from poking the lexer's private parts.
llvm-svn: 57399
2008-10-12 03:31:33 +00:00
Chris Lattner 097a8b8777 Fix a couple more places that poke KeepCommentMode unnecesarily.
llvm-svn: 57398
2008-10-12 03:27:19 +00:00
Chris Lattner 8637abd333 add a new inKeepCommentMode() accessor to abstract the KeepCommentMode
ivar.

llvm-svn: 57397
2008-10-12 03:22:02 +00:00
Chris Lattner e3f863a388 fix misleading comment.
llvm-svn: 57396
2008-10-12 01:34:51 +00:00
Chris Lattner 7c2e9809b1 Simplify raw mode lexing by treating an unterminate /**/ comment the
same we we do an unterminated string or character literal.  This makes
it so we can guarantee that the lexer never calls into the 
preprocessor (which would be suicide for a raw lexer).

llvm-svn: 57395
2008-10-12 01:31:51 +00:00
Chris Lattner 6b0c5ad096 add a comment.
llvm-svn: 57394
2008-10-12 01:23:27 +00:00
Chris Lattner 50c9050037 Change how raw lexers are handled: instead of creating them and then
using LexRawToken, create one and use LexFromRawLexer.  This avoids
twiddling the RawLexer flag around and simplifies some code (even 
speeding raw lexing up a tiny bit).

This change also improves the token paster to use a Lexer on the stack
instead of new/deleting it. 

llvm-svn: 57393
2008-10-12 01:15:46 +00:00
Chris Lattner 5d3e26a4f6 silence release-assert warnings.
llvm-svn: 57392
2008-10-12 00:31:50 +00:00
Chris Lattner 79ef843533 silence some release-assert warnings.
llvm-svn: 57391
2008-10-12 00:28:42 +00:00
Chris Lattner e05f534628 silence a bunch of warnings in a release-assert build.
llvm-svn: 57390
2008-10-12 00:26:57 +00:00
Chris Lattner 87e97ea7b8 improve a comment.
llvm-svn: 57389
2008-10-12 00:23:07 +00:00
Steve Naroff 1d95e5a531 Final phase of converting BlockDecls over to DeclContext. This is unfortunately a largish/complex diff, however it was necessry to pass all the current block tests.
llvm-svn: 57337
2008-10-10 01:28:17 +00:00
Daniel Dunbar eca513d945 Lift EmitTargetBuiltinExpr out of EmitBuiltinExpr.
llvm-svn: 57335
2008-10-10 00:24:54 +00:00
Dale Johannesen c48814bc98 Adjust calls to APFloat conversion for new interface.
llvm-svn: 57332
2008-10-09 23:02:32 +00:00
Zhongxing Xu cc06b463f5 Check some cases for previous patch. Make the code more robust.
llvm-svn: 57317
2008-10-09 03:19:06 +00:00
Argyrios Kyrtzidis 1207d31952 Fix a bug that crashed clang when parsing this:
class C {
  static const int number = 50;
  static int arr[number];
};

Here's how it worked:
-GetTypeForDeclarator was called from both Sema::ActOnCXXMemberDeclarator and Sema::ActOnDeclarator.
-VariableArrayTypes are not uniqued so two VariableArrayTypes were created with the same DeclRefExpr.
-On exit they both tried to destroy that one DeclRefExpr.

The fix is not to use GetTypeForDeclarator from the Sema::ActOnCXXMemberDeclarator.

llvm-svn: 57313
2008-10-08 22:20:31 +00:00
Steve Naroff 44078b95ee Instantiate the BlockDecl in ActOnBlockStart() so we can use it as a DeclContext.
This required changes to attach the compound statement later on (like we do for functions).

llvm-svn: 57304
2008-10-08 18:44:00 +00:00
Steve Naroff 415d3d570a - Add BlockDecl AST node.
- Modify BlockExpr to reference the BlockDecl.

This is "cleanup" necessary to improve our lookup semantics for blocks (to fix <rdar://problem/6272905> clang block rewriter: parameter to function not imported into block?).

Still some follow-up work to finish this (forthcoming).

llvm-svn: 57298
2008-10-08 17:01:13 +00:00
Zhongxing Xu d9959aee34 This is the first step to implement a field-sensitive store model. Other things are simplified: no heap shape assumption, no parameter alias assumption, etc.
llvm-svn: 57285
2008-10-08 02:50:44 +00:00
Ted Kremenek 587a44fe3d A little more tweaking with StmtIterator and SizeOfAlignofExpr. A recent commit actually introduced a regression, not fixed a bug.
llvm-svn: 57282
2008-10-07 23:35:42 +00:00
Ted Kremenek 9bb286ff43 Migrate DeclStmt over to using a DeclGroup instead of a pointer to a ScopedDecl*.
This also removes the ugly hack needed in CFG.cpp for subclassing DeclStmt to create a DeclStmt with one Decl*.

llvm-svn: 57275
2008-10-07 23:09:49 +00:00
Ted Kremenek 5ee6292e32 Add #include (introduced by dependence on DeclGroup)
llvm-svn: 57274
2008-10-07 23:08:39 +00:00
Ted Kremenek 4faf673d7f Fixed a masked bug when iterating over the child expressions of SizeOfAlignOfTypeExpr. This bug was unmasked by recent changes to StmtIterator.
llvm-svn: 57273
2008-10-07 23:07:10 +00:00
Ted Kremenek 12183e25aa Add const_iterator to DeclGroup.
Serialization for OwningDeclGroupRefs now works.

llvm-svn: 57272
2008-10-07 23:06:01 +00:00
Ted Kremenek f9638bac59 Add StmtIterator support for DeclGroups.
llvm-svn: 57271
2008-10-07 23:04:14 +00:00
Argyrios Kyrtzidis 8ae3684aa9 In ParseParenDeclarator match "D.setGroupingParens(true);" with another setGroupingParens call after the ')' is parsed.
Fixes this bug:
  int (x)(0); // error, expected function declarator where the '(0)' initializer is

llvm-svn: 57241
2008-10-07 10:21:57 +00:00
Zhongxing Xu de7509f01a Added a function call case that generates sink nodes.
llvm-svn: 57240
2008-10-07 10:06:03 +00:00
Zhongxing Xu f5e7c90c46 Migrate MemRegionManager from StateManager to StoreManager.
llvm-svn: 57225
2008-10-07 01:31:04 +00:00
Ted Kremenek 6553748599 Added prototype serialization code for DeclGroup.
llvm-svn: 57222
2008-10-06 23:49:24 +00:00
Argyrios Kyrtzidis 7b41f721b4 Use getCustomDiagID() instead of specifying the diagnostic in the 'DiagnosticKinds.def' file.
llvm-svn: 57220
2008-10-06 23:16:35 +00:00
Argyrios Kyrtzidis 997d00dd13 Simplify handling of direct initializers by letting Sema::AddInitializerToDecl handle conversions, instead of using Sema::ActOnCXXTypeConstructExpr.
Additional benefit is that diagnostics are the same for both direct-initialization and copy-initialization.

In the case of "int x( expression );":
-The Init expression of VarDecl 'x' will be the expression inside the parentheses.
-VarDecl::hasCXXDirectInitializer for VarDecl 'x' will return true to let clients distinguish from "int x = expression ;".

llvm-svn: 57219
2008-10-06 23:08:37 +00:00
Ted Kremenek 6d60a4ec19 Modified DeclGroupRef to always load/store the internal pointer value as Decl*. This hopefully will obviate any concerns with violating strict type-aliasing issues.
llvm-svn: 57213
2008-10-06 22:17:16 +00:00
Ted Kremenek 3fef35736e Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of an Objective-C foreach statement.
llvm-svn: 57209
2008-10-06 20:59:48 +00:00
Ted Kremenek a7297be859 Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when processing the Decl of a @catch statement.
llvm-svn: 57208
2008-10-06 20:58:56 +00:00
Ted Kremenek 11b004216c When processing Objective-C foreach statements, first check to see if the statement has a DeclStmt with a single Decl. Afterwards, use DeclStmt::getSolitaryDecl() to access that Decl (thus avoiding an assertion being triggered). These changes remove an unneeded use of ScopedDecl::getNextDeclarator() and DeclStmt::getDecl().
llvm-svn: 57207
2008-10-06 20:58:11 +00:00
Ted Kremenek ef52c641e7 Use DeclStmt::decl_iterator to walk a group of Decl*'s instead of using the ScopedDecl chain.
llvm-svn: 57206
2008-10-06 20:56:19 +00:00
Ted Kremenek a86db10563 Don't use DeclStmt::getDecl() to serialize out DeclStmt; use TheDecl directly.
This patch precedes removing getDecl() DeclStmt::entirely.

llvm-svn: 57205
2008-10-06 20:55:44 +00:00
Ted Kremenek acf920dd39 Add DeclStmt::hasSolitaryDecl() and DeclStmt::getSolitaryDecl()
llvm-svn: 57204
2008-10-06 20:54:44 +00:00
Ted Kremenek 7c2d69f007 Use "unsigned" instead of "int" for i to remove a "comparison between unsigned and signed" warning (potential integer overflow).
llvm-svn: 57201
2008-10-06 20:35:04 +00:00
Anders Carlsson 5f7ee680f8 Add 'x' constraint character.
llvm-svn: 57198
2008-10-06 19:17:39 +00:00
Ted Kremenek dcd6632463 Use the DeclStmt::decl_iterator to get the first decl in a DeclStmt instead of using DeclStmt::getDecl().
llvm-svn: 57196
2008-10-06 18:48:35 +00:00
Ted Kremenek 4db44b62ad Don't use DeclStmt::getDecl(); this will eventually disappear. Just fetch the first decl using the DeclStmt::decl_iterator.
llvm-svn: 57194
2008-10-06 18:43:53 +00:00
Ted Kremenek 704a2505db In EmitDeclStmt: use DeclStmt::const_decl_iterator instead of walking the scoped decl chain.
llvm-svn: 57192
2008-10-06 18:42:27 +00:00
Ted Kremenek 15e6b40832 Added PrintRawDeclStmt; use this method to print out DeclStmt instead of using PrintRawDecl (which falsely assumes DeclStmts have only one Decl).
llvm-svn: 57191
2008-10-06 18:39:36 +00:00
Ted Kremenek 62408480d9 Use Decl::decl_iterator instead of walking the ScopedDecl chain (which will soon be removed).
llvm-svn: 57190
2008-10-06 18:38:35 +00:00
Ted Kremenek fae8cb0736 Use DeclStmt::decl_iterator instead of using Decl::getDecl(). Soon DeclStmts will wrap group of Decls.
Added FIXME.

llvm-svn: 57189
2008-10-06 18:37:46 +00:00
Argyrios Kyrtzidis 153d967d14 The current semantic process for direct initializers won't work properly for class types.
Add a FIXME until class constructors are supported.

llvm-svn: 57188
2008-10-06 18:37:09 +00:00
Argyrios Kyrtzidis 9a1191c047 Implement support for C++ direct initializers in declarations, e.g. "int x(1);".
This is how this kind of initializers appear in the AST:
-The Init expression of the VarDecl is a functional type construction (of the VarDecl's type).
-The new VarDecl::hasCXXDirectInitializer() returns true.

e.g, for "int x(1);":
-VarDecl 'x' has Init with expression "int(1)" (CXXFunctionalCastExpr).
-hasCXXDirectInitializer() of VarDecl 'x' returns true.

A major benefit is that clients that don't particularly care about which exactly form was the initializer can handle both cases without special case code.
Note that codegening works now for "int x(1);" without any changes to CodeGen.

llvm-svn: 57178
2008-10-06 17:10:33 +00:00
Chris Lattner 1b0a00a4c9 __CONSTANT_CFSTRINGS__ should be defined even in C mode, otherwise the CFSTR
won't expand to the builtin.  This fixes rdar://6248329

llvm-svn: 57164
2008-10-06 07:43:09 +00:00
Chris Lattner a97132a9c4 Make sema and codegen allow __builtin___CFStringMakeConstantString as a valid
constant lvalue.  Implement this in codegen by moving the code out of CGBuiltin
into EmitConstantExpr.

llvm-svn: 57163
2008-10-06 07:26:43 +00:00
Chris Lattner 2c091b1ead ExprConstant should not abort when it sees a pointer constant that isn't.
llvm-svn: 57162
2008-10-06 07:20:11 +00:00
Chris Lattner 24355b5240 always try to fold a builtin before emitting it. In the future
it is possible that a builtin could sometimes be folded (e.g. __builtin_clz)
if it's operand is a constant.

llvm-svn: 57161
2008-10-06 06:56:41 +00:00
Chris Lattner cb13691a62 Add a Expr::isEvaluatable method, eliminate isBuiltinConstantExpr
which is checking for something that can be inconsistent with
what we can constant fold.

llvm-svn: 57159
2008-10-06 06:49:02 +00:00
Chris Lattner 86ee286b09 Move folding of __builtin_classify_type out of the CallExpr
interface into the constant folding interface.

llvm-svn: 57158
2008-10-06 06:40:35 +00:00
Chris Lattner 0b7282eafc Move handling of __builtin_nan("") out of CGBuiltin.cpp into ExprConstant.cpp
llvm-svn: 57157
2008-10-06 06:31:58 +00:00
Chris Lattner a1518b1dfe remove some code where CGBuiltin folds constants, and use tryEvaluate to
do it instead.  We should still handle __builtin_nan etc, but don't yet.
This fixes incorrect evaluation of __builtin_constant_p, a FIXME.

llvm-svn: 57156
2008-10-06 06:09:18 +00:00
Chris Lattner e50e90142e instead of making codegen try to know about all of the builtins to generate
constants for them, just use the constant evaluator to do the job.  This
also fixes crashes on 'unknown constant builtins'.

llvm-svn: 57155
2008-10-06 05:59:01 +00:00
Chris Lattner 37346e081c Teach FloatExprEvaluator to evaluate __builtin_huge_val and inf.
llvm-svn: 57154
2008-10-06 05:53:16 +00:00
Chris Lattner c43467526d "Enhance" CheckArithmeticConstantExpression to accept ?: with a constant
condition as a constant even if the unevaluated side is a not a constant.
We don't do this when extensions are off, and we emit a warning when this 
happens:

t.c:22:11: warning: expression is not a constant, but is accepted as one by GNU extensions
short t = __builtin_constant_p(5353) ? 42 : somefunc();
          ^                                 ~~~~~~~~~~

suggestions for improvement are welcome.  This is obviously horrible, but
is required for real-world code.

llvm-svn: 57153
2008-10-06 05:42:39 +00:00
Chris Lattner 4deaa4ea24 Add a comment that describes tryEvaluate. Make tryEvaluate fold
__builtin_constant_p properly, and add some scaffolding for
FloatExprEvaluator to eventually handle huge_val and inf.

llvm-svn: 57152
2008-10-06 05:28:25 +00:00
Chris Lattner 01ff98a48a add a new CallExpr::isBuiltinCall() method, and use it to simplify some existing
code.

llvm-svn: 57151
2008-10-06 05:00:53 +00:00
Anders Carlsson 1e18220dc4 Actually use the mmintrin.h header, it's good enough now.
llvm-svn: 57150
2008-10-06 04:49:00 +00:00
Chris Lattner d1d152a613 a more efficient test for __builtin_classify_type
llvm-svn: 57149
2008-10-06 04:48:17 +00:00
Zhongxing Xu a4bbcd302e Fix typos.
llvm-svn: 57146
2008-10-06 03:03:33 +00:00
Anders Carlsson f407150c06 Apparently gcc uses pi64 for the shift intrinsics.
llvm-svn: 57145
2008-10-06 02:07:50 +00:00
Anders Carlsson 83661acf30 Add the 'y' assembler constraint.
llvm-svn: 57144
2008-10-06 00:41:45 +00:00
Argyrios Kyrtzidis e8addf5e04 Allow variadic arguments without named ones for C++, e.g. "void(...);"
llvm-svn: 57143
2008-10-06 00:07:55 +00:00
Anders Carlsson b83162840f Implement support for the const and pure attributes.
llvm-svn: 57142
2008-10-05 23:32:53 +00:00
Argyrios Kyrtzidis 4217c7ec81 A tiny optimization; use isCXXFunctionDeclarator only when it's appropriate.
llvm-svn: 57141
2008-10-05 23:15:41 +00:00
Chris Lattner 09d98f5d8a miscellaneous cleanups
llvm-svn: 57140
2008-10-05 21:50:58 +00:00
Chris Lattner ac7ed9a71a move __FLT_EVAL_METHOD__, __FLT_RADIX__, and __DECIMAL_DIG__ into
target indep code.

llvm-svn: 57139
2008-10-05 21:49:27 +00:00
Chris Lattner c34a35d56f it helps when I save the file before testing and committing.
llvm-svn: 57138
2008-10-05 21:42:17 +00:00
Chris Lattner 6da2f0dd2e suck the rest of the FP macros out of the targets into the PP
llvm-svn: 57137
2008-10-05 21:40:58 +00:00
Argyrios Kyrtzidis 279d9814e5 Add some text from the C++ standard and additional ambiguity resolution tests.
No funcitonality change.

llvm-svn: 57136
2008-10-05 21:10:08 +00:00
Chris Lattner 5cd8351808 start moving fp macros over
llvm-svn: 57134
2008-10-05 20:40:30 +00:00
Chris Lattner 6512a88984 move a bunch more integer sizing out of target-specific code into
target indep code.  

Note that this changes functionality on PIC16: it defines __INT_MAX__
correctly for it, and it changes sizeof(long) to 16-bits (to match
the size of pointer).

llvm-svn: 57132
2008-10-05 20:06:37 +00:00
Argyrios Kyrtzidis 2b1ef227f5 Handle ambiguities between expressions and type-ids that occur inside parentheses, e.g.:
sizeof(int()) -> "int()" is type-id
sizeof(int()+1) -> "int()+1" is expression.

llvm-svn: 57131
2008-10-05 19:56:22 +00:00
Chris Lattner 4ecd753486 eliminate __USER_LABEL_PREFIX__ from the Targets.cpp file, start moving
integer size #defines over to the Preprocessor.

llvm-svn: 57130
2008-10-05 19:44:25 +00:00
Chris Lattner 248d3c4192 gcc no longer defines __block to nothing when blocks aren't enabled.
llvm-svn: 57129
2008-10-05 19:32:52 +00:00
Chris Lattner 1f7e2d5430 rearrange preprocessor macro definitions into language-specific
then target specific.

llvm-svn: 57128
2008-10-05 19:32:22 +00:00
Chris Lattner f37bafc5ca Implement PR2773, support for __USER_LABEL_PREFIX__
llvm-svn: 57127
2008-10-05 19:22:37 +00:00
Argyrios Kyrtzidis df788f4eea Found a subtle bug caused by an implicit enum-to-bool conversion (of the TentativeParsingResult enum).
This was the motivation of the following changes:

-'TentativeParsingResult' enum is replaced by a 'TPResult' class that basically encapsulates the enum.
-TPR_true, TPR_false, TPR_ambiguous, and TPR_error enum constants are replaced by TPResult::True(), TPResult::False(), etc. calls that return a TPResult object.
-Also fixed the subtle bug in Parser::isCXXFunctionDeclarator (caught by the above changes as a compilation error).

llvm-svn: 57125
2008-10-05 18:52:21 +00:00
Anders Carlsson c181b01681 Add parsing of the sentinel attribute. Still need to create the attribute.
llvm-svn: 57121
2008-10-05 18:05:59 +00:00
Chris Lattner 465fa32cd5 Wrap long lines and other minor cleanups, no functionality change.
llvm-svn: 57119
2008-10-05 17:34:18 +00:00
Anders Carlsson c442c92b6f Remove copyright notice, we decided not to have them.
llvm-svn: 57118
2008-10-05 17:21:08 +00:00
Argyrios Kyrtzidis bc28fefcde Disambiguate between a declaration or an expression, in the 'for-init-statement' part of a 'for' statement.
llvm-svn: 57112
2008-10-05 15:50:46 +00:00
Argyrios Kyrtzidis 2534620b4e Fix Parser::isCXXConditionDeclaration to properly resolve declarations.
llvm-svn: 57111
2008-10-05 15:19:49 +00:00
Argyrios Kyrtzidis 71f3e19df0 Disambiguate between a declaration or expression for the 'condition' part of a if/switch/while/for statement.
llvm-svn: 57109
2008-10-05 15:03:47 +00:00
Argyrios Kyrtzidis 7b87f27438 Consider GNU attributes when doing ambiguity resolution.
llvm-svn: 57108
2008-10-05 14:27:18 +00:00
Zhongxing Xu 8c9771bdf0 Remove redundant parameter and rename StMgr to StateMgr.
llvm-svn: 57107
2008-10-05 12:12:48 +00:00
Daniel Dunbar b8ed192605 Make VectorType printing less broken.
- Print size as number of elements times "sizeof(elt type)", not
   perfect but better than just printing the completely wrong type.

llvm-svn: 57100
2008-10-05 05:43:11 +00:00
Argyrios Kyrtzidis 2c7137d8d1 Resolve ambiguous C++ statements (C++ 6.8p1).
'ParseTentative.cpp' implements the functionality needed to resolve ambiguous C++ statements, to either a declaration or an expression, by "tentatively parsing" them.

llvm-svn: 57084
2008-10-05 00:06:24 +00:00
Daniel Dunbar 3ca0a634c2 Bug fix, CPATH="" does not add '.' to search path.
llvm-svn: 57072
2008-10-04 20:58:18 +00:00
Daniel Dunbar 921b968841 Add Parser support for #pragma pack
- Uses Action::ActOnPragmaPack
 - Test case is XFAIL pending verifier fixes.

llvm-svn: 57066
2008-10-04 19:21:03 +00:00
Daniel Dunbar 405965323d Add Preprocessor::RemovePragmaHandler.
- No functionality change.

llvm-svn: 57065
2008-10-04 19:17:46 +00:00
Ted Kremenek 5ca90a244f This is a big patch, but the functionality change is small and the rest of the patch consists of deltas due to API changes.
This patch overhauls the "memory region" abstraction that was prototyped (but never really used) as part of the Store.h.  This patch adds MemRegion.h and MemRegion.cpp, which defines the class MemRegion and its subclasses.  This classes serve to define an abstract representation of memory, with regions being layered on other regions to to capture the relationships between fields and variables, variables and the address space they are allocated in, and so on.  

The main motivation of this patch is that key parts of the analyzer assumed that all value bindings were to VarDecls.  In the future this won't be the case, and this patch removes lval::DeclVal and replaces it with lval::MemRegionVal.  Now all pieces of the analyzer must reason about abstract memory blocks instead of just variables.

There should be no functionality change from this patch, but it opens the door for significant improvements to the analyzer such as field-sensitivity and object-sensitivity, both which were on hold until the memory abstraction got generalized.

The memory region abstraction also allows type-information to literally be affixed to a memory region.  This will allow the some now redundant logic to be removed from the retain/release checker.

llvm-svn: 57042
2008-10-04 05:50:14 +00:00
Zhongxing Xu 8d1928a4ca Reverse the RHSBlock of LogicalOp && and ||
llvm-svn: 57041
2008-10-04 05:48:38 +00:00
Chris Lattner 7c306a70b9 add a new Rewriter::getRewritenText method that returns the text for a range
that includes any edits in the range.

llvm-svn: 57037
2008-10-03 23:31:16 +00:00
Daniel Dunbar 325601a9e5 Merge postfix attributes on record decls.
llvm-svn: 57019
2008-10-03 17:33:35 +00:00
Daniel Dunbar e4ac7a4059 Remove a FIXME.
llvm-svn: 57015
2008-10-03 16:42:10 +00:00
Daniel Dunbar 4d601119c3 Pass postfix attributes to ActOnFields (mismarked a file).
llvm-svn: 56993
2008-10-03 02:05:12 +00:00
Daniel Dunbar 15619c7e4b Pass postfix attributes to ActOnFields.
llvm-svn: 56992
2008-10-03 02:03:53 +00:00
Steve Naroff 2231569f01 Add getTypeSpecStartLoc() to VarDecls and FunctionDecls.
This is a temporary solution to help with the block rewriter (though it certainly has general utility).
Once DeclGroup's are implemented, this SourceLocation should be stored with it (since it applies to all the decls).

llvm-svn: 56985
2008-10-03 00:02:03 +00:00
Daniel Dunbar dc2ab1740a Add Builtins.def attribute for "can be a constant expression".
- Enabled for builtins which are always constant expressions
   (__builtin_huge_val*, __builtin_inf*, __builtin_constant_p,
   __builtin_classify_type, __builtin___CFStringMakeConstantString).

Added Builtin::Context::isConstantExpr.
 - Currently overly simply interface which only works for builtins
   whose constantexprness does not depend on their arguments.

CallExpr::isBuiltinConstantExpr now takes an ASTContext argument.

llvm-svn: 56983
2008-10-02 23:30:31 +00:00
Daniel Dunbar dd9b2d16f9 Add support for format string checking of object-size checking
versions of sprintf and friends.
 - Added FIXME that this mechanism should be generalized.

llvm-svn: 56962
2008-10-02 18:44:07 +00:00
Daniel Dunbar e23f28f8a5 Emit error unsupported for break/continue/goto inside Obj-C exception
handling blocks.
 - This has false positives, but at least prevents miscompiles.

llvm-svn: 56958
2008-10-02 18:02:06 +00:00
Steve Naroff d40a39626c Changed Sema::CheckForConstantInitializer to allow global block literals.
This commit also includes some name changes in the blocks rewriter (no functionality change).

llvm-svn: 56955
2008-10-02 17:12:56 +00:00
Daniel Dunbar c3d16493ae (LLVM up) Rename IRBuilder::IsNonNull -> IsNotNull.
llvm-svn: 56954
2008-10-02 17:05:36 +00:00
Ted Kremenek 3aa89a971d Enhance NSError** checking with analogous checking for CFErrorRef*.
Expand checking to include functions, not just methods.

llvm-svn: 56938
2008-10-01 23:24:09 +00:00
Ted Kremenek 8dcd40768e Use LVal::IsLValType(T) instead of checking to see if the type is an "lvalue" type directly.
llvm-svn: 56912
2008-10-01 05:02:13 +00:00
Daniel Dunbar fbe68a84f8 NeXT: Update to use CreateRuntimeFunction for the routines it imports.
llvm-svn: 56902
2008-10-01 01:06:06 +00:00
Daniel Dunbar 23fd462f48 Add simple interface for protecting runtime functions from name
collisions.
 - Provide CodeGenModule::CreateRuntimeFunction which guarantees that
   the function it creates will have the provided name in the final
   module. This allows the runtime to have its functions protected
   from declarations of the same name in the source code.

 - One could argue that this is a reason to abuse the llvm::Module
   namespace for dealing with function redeclarations. However, that
   approach seems conceptually flawed to me. This one also happens to
   be somewhat more efficient.

No functionality change.

llvm-svn: 56899
2008-10-01 00:49:24 +00:00
Ted Kremenek d331d09e2f Add a QualType to ConjuredSymbol to represent the type and size of the symbol.
Use this updated interface when invalidating arguments passed by reference; the type of symbol is of the object passed by reference, not the reference itself.

llvm-svn: 56894
2008-10-01 00:21:14 +00:00
Chris Lattner a1cf5f9663 simplify padding, just fold it into the earlier resize.
llvm-svn: 56880
2008-09-30 20:53:45 +00:00
Chris Lattner 8b567f9713 fix a potential buffer overrun that Eli noticed
llvm-svn: 56879
2008-09-30 20:51:14 +00:00
Chris Lattner 59f09b6fe1 Document assumptions that NumericLiteralParser makes with an assertion.
llvm-svn: 56876
2008-09-30 20:45:40 +00:00
Chris Lattner 97d749464d Handle minor version numbers in __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__
like "10.3.9"

llvm-svn: 56873
2008-09-30 20:30:12 +00:00
Daniel Dunbar 5f57710392 Add diagnostic for .{lo,hi,e,o} on odd-sized extended vectors.
llvm-svn: 56859
2008-09-30 17:22:47 +00:00
Steve Naroff 4a82d815de Fix <rdar://problem/6191148> [sema] Objective-C method lookup (at global scope) fails to handle overloaded selectors properly.
Long standing bug in Sema::ActOnInstanceMessage(). We now warn when messaging an "id" with multiple method signatures in scope. The diags are a little verbose, however they can be streamlined if necessary. 

llvm-svn: 56843
2008-09-30 14:38:43 +00:00
Steve Naroff 9f9774cd2b Improved fix for <rdar://problem/6247781> Parser rejecting properly mismatched properties.
Needed to make sure the relaxed type checking only applies to "readonly" properties.

llvm-svn: 56838
2008-09-30 10:07:56 +00:00
Nick Lewycky e275a66538 Add missing include for use of atoi.
llvm-svn: 56836
2008-09-30 07:18:57 +00:00
Ted Kremenek f1b299952a Revert last patch, but add a fixme
llvm-svn: 56832
2008-09-30 05:35:42 +00:00
Ted Kremenek 76bccf6221 Within the transfer function of UnaryOperatorExpr, handle implicit promotions
from the subexpression type to the expression type.

llvm-svn: 56831
2008-09-30 05:32:44 +00:00
Mon P Wang 553b4b912b Added support for sse intrinsics loadlpd, loadhpd, muldq128, and mulld128
llvm-svn: 56830
2008-09-30 05:31:27 +00:00
Daniel Dunbar 2efd538f61 Add infrastructure for proper @finally support.
- Provides a basic primitive to jump to an arbitrary basic block,
   through the finally code.

 - Only used for return statements and rethrow currently. Still need
   to handle break, continue and goto.

 - Code still needs to be shuffled around to live elsewhere.

llvm-svn: 56827
2008-09-30 01:06:03 +00:00
Chris Lattner b3793bb415 The definition of __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ follows
the target triple on darwin.  For example i386-apple-darwin9 -> 1050 because
darwin9 is "10.5".

llvm-svn: 56826
2008-09-30 01:00:25 +00:00
Chris Lattner 7ed3209332 define __PASCAL_STRINGS__ whenever -fpascal-strings is enabled.
llvm-svn: 56824
2008-09-30 00:48:48 +00:00
Chris Lattner 006579ddb5 __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ is a darwin-specific #define
llvm-svn: 56822
2008-09-30 00:46:39 +00:00
Steve Naroff 506e717e4f Fix <rdar://problem/6247781> Parser rejecting properly mismatched properties.
llvm-svn: 56821
2008-09-30 00:24:17 +00:00
Chris Lattner fb8b8f298c Fix the root cause of PR2750 instead of the side effect.
NumericLiteral parser is not careful about overrun because
it should never be possible.  It implicitly expects that its
input matched the regex for pp-constant.  Because of this, it
knows it can't be pointing to a prefix of something that
looks like a number.  This is all fine, except that __LINE__
does not prevent implicit concatenation from happening.  Fix
__LINE__ to not do this.

llvm-svn: 56818
2008-09-29 23:12:31 +00:00
Chris Lattner 4a80a59b6e Fix va_arg handling to do argument decaying at the correct place. This
fixes problems handling references of va_list, which happens on x86_64.
This fixes PR2841 and rdar://6252231

llvm-svn: 56809
2008-09-29 22:28:25 +00:00
Chris Lattner d9a663aeb9 Make some methods const, add some helpers to FullSourceLoc,
and add a dump method to FullSourceLoc!  Patch by Nico Weber!

llvm-svn: 56806
2008-09-29 21:46:13 +00:00
Steve Naroff 38093af363 Add a random C99 comment/reference.
llvm-svn: 56800
2008-09-29 20:07:05 +00:00
Steve Naroff 32d072ca45 Teach Sema::CheckAssignmentConstraints() to allow assignments between id and block pointer types (^{}).
llvm-svn: 56793
2008-09-29 18:10:17 +00:00
Steve Naroff 03fc762a02 Fix <rdar://problem/6251012> clang: Blocks are objects too.
llvm-svn: 56791
2008-09-29 16:51:41 +00:00
Steve Naroff c2036d5da4 Fix <rdar://problem/6253149> property declaration doesn't declare getter and setter.
llvm-svn: 56785
2008-09-29 14:20:56 +00:00
Nico Weber 378c5539c8 whitespace and comment changes, to fix grammar and 80 col violations
llvm-svn: 56776
2008-09-29 00:25:48 +00:00
Steve Naroff b6b1abb0f5 Change a NOTE to a FIXME based on feedback from clattner.
llvm-svn: 56775
2008-09-28 21:07:52 +00:00
Steve Naroff 8edb573a79 Fix <rdar://problem/6252129> implementation of method in category doesn't effectively declare it for methods below.
llvm-svn: 56771
2008-09-28 14:55:53 +00:00
Steve Naroff 4831c74d40 Fix <rdar://problem/6252108> assigning to argument passed to block should not require __block.
llvm-svn: 56770
2008-09-28 14:02:55 +00:00
Chris Lattner 037379d767 Fix rdar://6252231 - cannot call vsnprintf with va_list on x86_64,
by decaying __builtin_va_list's type when forming builtins.  On
x86-64 (and other targets) __builtin_va_list is a typedef for
an array.

llvm-svn: 56768
2008-09-28 06:05:35 +00:00
Chris Lattner ff2c187e59 Replace a comparison with a static list of builtins that was wrong (it
wasn't covering checking builtins like __builtin___vsnprintf_chk) with
a check that won't get out of date. 

llvm-svn: 56767
2008-09-28 05:54:29 +00:00
Chris Lattner e9d291c038 Fix rdar://6251437, references to enum constant decls in a block
don't need a BlockDeclRefExpr.

llvm-svn: 56766
2008-09-28 05:30:26 +00:00
Steve Naroff e18f94c20d Fix <rdar://problem/6252216> compare block to NULL.
llvm-svn: 56764
2008-09-28 01:11:11 +00:00
Daniel Dunbar d3dcb4f8ed Add support for implicit rethrows in @catch blocks.
Comment exception-handling code generation strategy.

llvm-svn: 56763
2008-09-28 01:03:14 +00:00
Daniel Dunbar a2d3570fc9 Skip redundant if.
llvm-svn: 56762
2008-09-28 00:19:22 +00:00
Steve Naroff edec9ba58d Fix <rdar://problem/6252226> parser thinks block argument is undefined identifier in NSServices.m
llvm-svn: 56761
2008-09-28 00:13:36 +00:00
Daniel Dunbar 7f08678f7d (Update LLVM) Clean up obj-c exception generation to be a bit more
readable and to generate more readable IR.

llvm-svn: 56758
2008-09-27 23:30:04 +00:00
Daniel Dunbar 86919f45cc Bug fix, codegen @catch(id<X> ...) acceptably.
- This should be rejected by sema (IMHO) but that needs some
   investigation.

llvm-svn: 56756
2008-09-27 22:21:14 +00:00
Ted Kremenek 21c24f1785 Revert 56735. The old bug categories were more informative.
llvm-svn: 56755
2008-09-27 22:02:42 +00:00
Daniel Dunbar 523208fb4a Simplify generate code for exceptions:
- There is no need to branch on the rethrow variable to determine if
   we need to call objc_exception_try_exit. We know whether an
   exception was thrown, so just branch to a different target if we
   want to skip the try_exit. 

   This is a slight semantic departure from gcc, but only for throwing
   nil, which is undefined (and for which gcc emits broken code).

 - Also fixes a bug in current code which was calling try_exit too
   many times when an exception was uncaught (but there were some
   handlers).

Fix bug introduced in prev. commit, the type of the @catch parameter
was uninitialized.

llvm-svn: 56754
2008-09-27 07:36:24 +00:00
Daniel Dunbar aec553bfdb Prefer llvm::Function::addFnAttr(...) to F->addAttribute(~0, ...).
llvm-svn: 56753
2008-09-27 07:16:42 +00:00
Daniel Dunbar 274ff37583 Simplify code to emit the unified return block and move it to the end
of the function.

llvm-svn: 56752
2008-09-27 07:15:59 +00:00
Daniel Dunbar b22ff59750 Bug fix, make sure to initialize exception object (to rethrow) even
when there are no @catch blocks.

Also, eliminated unneeded alloca for the rethrow object.

Also, avoid generating code to rethrow exception if the exception will
trivially always be caught.

llvm-svn: 56751
2008-09-27 07:03:52 +00:00
Daniel Dunbar da04d7f4ec Easy fix for nasty bug, exception data buffer had wrong type == wrong
(smaller) size == garbage on stack == heisenbugs.

llvm-svn: 56750
2008-09-27 06:32:25 +00:00
Zhongxing Xu 612e0c9604 Delete trailing white space. It's over 80 columns.
llvm-svn: 56749
2008-09-27 03:27:29 +00:00
Ted Kremenek 16a59fabec Change "leaks" to have the category "Performance".
llvm-svn: 56735
2008-09-27 00:45:27 +00:00
Ted Kremenek 8bafa2cf9f Internally store the body of a BlockExpr using a Stmt* instead of a CompoundStmt*, and use the getBody() method to do the appropriate checking. This both removes the type-punning warnings in Expr.cpp and also makes BlockExpr have more consistency checks against modifications to its body (via StmtIterator).
llvm-svn: 56710
2008-09-26 23:24:14 +00:00
Ted Kremenek 6ed79f0c13 Use a union instead of a bunch of magic casts to implement a variant. This removes the type-punning errors for DeclGroup.
llvm-svn: 56708
2008-09-26 23:19:04 +00:00
Ted Kremenek d86d39cc9e Add CFG support for implicit-control flow for VLA size expressions within an SizeOfAlignOfTypeExpr.
llvm-svn: 56706
2008-09-26 22:58:57 +00:00
Devang Patel 597e70876e Now Attributes are divided in three groups
- return attributes - inreg, zext and sext
- parameter attributes
- function attributes - nounwind, readonly, readnone, noreturn

Return attributes use 0 as the index.
Function attributes use ~0U as the index.

llvm-svn: 56705
2008-09-26 22:53:57 +00:00
Chris Lattner b03dc76499 clean up a bunch of fixme's I added, by moving
DirectoryLookup::DirType into SourceManager.h

llvm-svn: 56692
2008-09-26 21:18:42 +00:00
Chris Lattner c88a23e8d7 Fix the rest of rdar://6243860 hopefully. This requires changing FileIDInfo
to whether the fileid is a 'extern c system header' in addition to whether it
is a system header, most of this is spreading plumbing around.  Once we have that,
PPLexerChange bases its "file enter/exit" notifications to PPCallbacks to
base the system header state on FileIDInfo instead of HeaderSearch.  Finally,
in Preprocessor::HandleIncludeDirective, mirror logic in GCC: the system headerness
of a file being entered can be set due to the #includer or the #includee.

llvm-svn: 56688
2008-09-26 20:12:23 +00:00
Ted Kremenek ac49ea63c6 Do not create CFGs for functions/methods using blocks (need to add control-flow).
llvm-svn: 56672
2008-09-26 18:17:07 +00:00
Chris Lattner e744d32b72 emulate a bit of GCC path lookup weirdness: if a system
directory is shadowed by a user directory in the lookup
path, ignore the user directory not the system one.  Not
doing this can affect file lookup and the "is a system
header" bit on locations.  For example:
  clang -v -I/usr/include inc.c -E | & grep /usr/inc
now prints:

# 1 "/usr/include/i386/_types.h" 1 3 4
# 37 "/usr/include/i386/_types.h" 3 4
# 70 "/usr/include/i386/_types.h" 3 4

instead of:

# 1 "/usr/include/i386/_types.h" 1
# 37 "/usr/include/i386/_types.h"
# 70 "/usr/include/i386/_types.h"

This is part of rdar://6243860.

llvm-svn: 56669
2008-09-26 17:46:45 +00:00
Ted Kremenek 68d2190226 Enter a new scope for a @try block.
llvm-svn: 56668
2008-09-26 17:32:47 +00:00
Ted Kremenek 61a625ff70 Move VLA processing logic from LiveVariables to CFG construction. This way all dataflow analyses "see" the VLA size expressions.
llvm-svn: 56655
2008-09-26 16:26:36 +00:00
Steve Naroff ba756cb3fc Tweak Expr::isModifiableLvalue() and Expr::isLvalue() to better deal with BlockDeclRef exprs.
This fixes <rdar://problem/6248392> clang: Error when using address of stack variable inside block.

llvm-svn: 56652
2008-09-26 14:41:28 +00:00
Ted Kremenek 2ece64bbc4 Examine VLA size expressions when computing liveness information.
Fixes <rdar://problem/6248086>

llvm-svn: 56645
2008-09-26 05:52:45 +00:00
Daniel Dunbar 26e2ab4a37 Parser support for prefix __attribute__ on @protocol.
llvm-svn: 56642
2008-09-26 04:48:09 +00:00
Daniel Dunbar c136e0ca43 Sema support for format and noreturn attributes on Objective-C methods.
llvm-svn: 56640
2008-09-26 04:12:28 +00:00
Daniel Dunbar 980c66946b Add support for CFString in format attribute.
llvm-svn: 56639
2008-09-26 03:32:58 +00:00
Daniel Dunbar 2c793a2ecd Add # of block pointer types to -print-stats.
llvm-svn: 56638
2008-09-26 03:23:00 +00:00
Daniel Dunbar b5fe494a2c Update clang to pretend to be gcc-4.2.
- This really needs to be automated and configurable.

llvm-svn: 56635
2008-09-26 01:13:13 +00:00
Ted Kremenek a34ea3b9cf Have @finally introduce a new scope.
Fixes: <rdar://problem/6248119> @finally doesn't introduce a new scope

llvm-svn: 56629
2008-09-26 00:31:16 +00:00
Devang Patel 322300d1c2 Large mechanical patch.
s/ParamAttr/Attribute/g
s/PAList/AttrList/g
s/FnAttributeWithIndex/AttributeWithIndex/g
s/FnAttr/Attribute/g

This sets the stage 
- to implement function notes as function attributes and 
- to distinguish between function attributes and return value attributes.

llvm-svn: 56623
2008-09-25 21:02:23 +00:00
Ted Kremenek a5e23f6b78 Added prototype implementation of the DeclGroup, DeclGroupRef, and DeclGroupOwningRef classes.
Documentation and testing are pending.

llvm-svn: 56611
2008-09-25 17:13:40 +00:00
Steve Naroff f17c232a9e Downgrade incompatible block pointer error to a warning (to be consistent with incompatible pointer warnings in general).
llvm-svn: 56595
2008-09-24 23:31:10 +00:00
Steve Naroff c60873ce44 Fix <rdar://problem/6243788> clang: Incorrect return statement for Blocks?
llvm-svn: 56590
2008-09-24 22:26:48 +00:00
Steve Naroff 921a45c6d6 Extend ASTContext::getTypeInfo() and ASTContext::getObjCEncodingForType() for BlockTypes.
This fixes <rdar://problem/6240616> clang: Assertion failed when using typedef and Blocks.

llvm-svn: 56554
2008-09-24 15:05:44 +00:00
Daniel Dunbar 5449ce5d75 Implement Obj-C synthesized setters for copy / retain.
llvm-svn: 56547
2008-09-24 06:32:09 +00:00
Daniel Dunbar a08dff1be1 Implement Obj-C getter synthesis for copy and retain.
Also, "simple" getter synthesis no longer uses temporary AST objects.

llvm-svn: 56544
2008-09-24 04:04:31 +00:00
Daniel Dunbar 1c64e5d12f Refactor some CodeGen functionality:
- Add CodeGenFunction::{EmitReturnOfRValue, EmitIvarOffset}
 - Factor EmitLValueForIvar out of EmitObjCIvarRefLValue.

No non-error functionality change (some unsupported errors are
degraded to asserts for the time being).

llvm-svn: 56543
2008-09-24 04:00:38 +00:00
Daniel Dunbar a91c3e097f Add Obj-C runtime methods to get runtime specific functions for
implementing property access.

llvm-svn: 56542
2008-09-24 03:38:44 +00:00
Devang Patel e2aef07b2d Adjust whitespaces.
llvm-svn: 56538
2008-09-24 01:03:00 +00:00
Devang Patel 3e1f51b53f s/ParamAttrsWithIndex/FnAttributeWithIndex/g
Rename to match changes done on llvm side.

llvm-svn: 56537
2008-09-24 01:01:36 +00:00
Daniel Dunbar e8a06e619a Implement type checking of Objective-C property attributes.
- readonly and readwrite are mutually exclusive.
 - assign, copy, and retain are mutually exclusive.
 - copy and retain are invalid on non-object types.
 - Warn about using default 'assign' property on object types
   (attempting to follow gcc behavior).

llvm-svn: 56507
2008-09-23 21:53:23 +00:00
Steve Naroff de2d5b75c2 Fix <rdar://problem/6240065> clang: __BLOCKS__ should be defined.
llvm-svn: 56503
2008-09-23 21:28:24 +00:00
Daniel Dunbar d0921de8b0 Add x86_64 Linux target.
- PR2824

llvm-svn: 56491
2008-09-23 17:37:57 +00:00
Daniel Dunbar c6fdac260b Bug fix, result of isIntegerConstantExpr could be of incorrect width
for type.
  - PR2817

llvm-svn: 56482
2008-09-22 23:53:24 +00:00
Ted Kremenek b76a3f44ec Output "REPORTHEADER" and "REPORTSUMMARYEXTRA" tags for use with scan-view.
llvm-svn: 56440
2008-09-22 17:33:32 +00:00
Steve Naroff 25709eca44 Remove unused slot/reference and update Sema::ActOnIdentifierExpr().
llvm-svn: 56438
2008-09-22 15:31:56 +00:00
Steve Naroff cd5e782bce Fix http://llvm.org/bugs/show_bug.cgi?id=2816.
llvm-svn: 56433
2008-09-22 10:28:57 +00:00
Ted Kremenek 76f79ba890 Change casing of bug type.
llvm-svn: 56405
2008-09-21 19:08:31 +00:00
Ted Kremenek 638e280c32 The checks in BasicObjCFoundationChecks now have a category: "API Misuse (Apple)"
llvm-svn: 56403
2008-09-21 19:01:39 +00:00
Ted Kremenek ba9781dcfc The "unused ivar" check now has a category: "Optimization"
llvm-svn: 56402
2008-09-21 18:58:22 +00:00
Ted Kremenek 1b6997ed5e Built-in checks now have a category: "Logic Errors"
llvm-svn: 56401
2008-09-21 18:57:28 +00:00
Ted Kremenek 80b2b16540 Added experimental "intelligent-sizing" of HTML message bubbles based on the contents of the message.
llvm-svn: 56400
2008-09-21 18:52:59 +00:00
Ted Kremenek 33663885c3 Add a bug category for NSError** checks.
llvm-svn: 56394
2008-09-21 06:57:40 +00:00
Ted Kremenek de195e2100 Add "category" to BugTypes, allowing bugs to be grouped.
Changed casing of many bug names.  The convention will be to have bug names (mostly) lower cased, and categories use some capitalization.

llvm-svn: 56385
2008-09-20 04:23:38 +00:00
Ted Kremenek bc15d8539d Add PostStore, a new ProgramPoint to distinguish between 'stores' and other PostStmts.
GRExprEngine:
  Use PostStore in EvalStore.
  Use a second version of EvalStore in EvalBinaryOperator to associate the store with the expression on the LHS.

llvm-svn: 56383
2008-09-20 01:50:34 +00:00
Ted Kremenek 31a15f8ba2 Bug fix: for the base transfer function logic for casts, handle const casts as just propagating the value.
llvm-svn: 56368
2008-09-19 20:51:22 +00:00
Ted Kremenek 34bfd8a490 Fixed logic error in BasicConstraintManager pointed out by Zhongxing Xu.
For checking if a symbol >= value, we need to check if symbol == value || symbol
> value. When checking symbol > value and we know that symbol != value, the path
is infeasible only if value == maximum integer.

For checking if a symbol <= value, we need to check if symbol == value || symbol
< value. When checking symbol < value and we know that symbol != value, the path
is infeasible only if value == minimum integer.

Updated test case exercising this logic: we only prune paths if the values are
unsigned.

llvm-svn: 56354
2008-09-19 18:00:36 +00:00
Chris Lattner a7b034463e Fix rdar://6222856: the receiver of a message expr is an
arbitrary expr, not just a assign expr.  The grammar comment
was right, the code was just wrong.

llvm-svn: 56353
2008-09-19 17:44:00 +00:00
Ted Kremenek a5bf9cb4be When we have a binary expression 'int operator symbol', properly rewrite this as
'symbol operator-reverse int'. This patch is a combination of code from
Zhongxing Xu and myself (Zhongxing noticed this bug for the cases of
relational operators).

llvm-svn: 56351
2008-09-19 17:31:13 +00:00
Zhongxing Xu a8e88ecda6 Add an omitted case for AssumeSymInt.
llvm-svn: 56334
2008-09-19 06:07:59 +00:00
Ted Kremenek a417c0e80a Add panic function "__assert_fail".
llvm-svn: 56327
2008-09-19 02:30:47 +00:00
Ted Kremenek 6a1a334b6c Register the implicit null-dereferenced object as a notable symbol.
llvm-svn: 56319
2008-09-18 23:23:19 +00:00
Ted Kremenek b42f482c91 Implement second part of PR 2600: NSError** parameter may be null, and should be checked before being dereferenced.
llvm-svn: 56318
2008-09-18 23:09:54 +00:00
Ted Kremenek f0673e4eb6 Change implementation of NSError** coding-style check to be invoked at the end of the retain/release analysis.
llvm-svn: 56312
2008-09-18 21:25:13 +00:00
Steve Naroff 3405a73ab8 Finish pushing blocks attribute through the clang attribute machinery.
Also added a couple simple tests from the "gcc.apple" test suite.

llvm-svn: 56309
2008-09-18 16:44:58 +00:00
Ted Kremenek fc3abeb1e5 Implemented one of the checks requested in PR 2600:
"Method accepting NSError** argument should have non-void return value to indicate that an error occurred."

Test case written, but the header needs to be delta-debugged reduced.  Will commit shortly.

llvm-svn: 56297
2008-09-18 06:33:41 +00:00
Daniel Dunbar 86d97c7985 Improve x86 ABI compatibility.
- Enables use of ABIArgInfo::Expand when needed. This greatly
   improves our x86 ABI compatibility.

 - As the infrastructure for target specific ABI handling isn't built
   yet, this change means ABI compatibility on other platforms is once
   again broken in a different way than before.

 - Upcoming: Figure out how to refactor ABI handling into
   targets. More documentation.

llvm-svn: 56293
2008-09-17 21:22:33 +00:00
Daniel Dunbar d9d1f5f522 Print current function on verification failures.
llvm-svn: 56291
2008-09-17 21:13:22 +00:00
Daniel Dunbar d34d6dc458 Drop CodeGenTypes parameter to classifyArgumentType.
Ensure that ABIArgInfo::Default implementation for aggregrate types
is sensible (StructRet on return and ByVal on arguments).

No functionality change.

llvm-svn: 56289
2008-09-17 20:11:04 +00:00
Steve Naroff 43bafa78b3 Remove BlockStmtExpr.
Block literals are now represented by the concrete BlockExpr class.
This is cleanup (removes a FIXME).
No functionality change.

llvm-svn: 56288
2008-09-17 18:37:59 +00:00
Steve Naroff a5629376e8 Fix http://llvm.org/bugs/show_bug.cgi?id=2760.
llvm-svn: 56280
2008-09-17 14:05:40 +00:00
Daniel Dunbar 8fc81b02e2 Add support for ABIArgInfo::Expand
- No functionality change.

llvm-svn: 56269
2008-09-17 00:51:38 +00:00
Ted Kremenek 8782716c4a Minor pass-sensitivity improvement:
if we know that 'len != 0' and know that 'i == 0' then we know that
  'i < len' must evaluate to true and cannot evaluate to false

llvm-svn: 56260
2008-09-16 23:24:45 +00:00
Steve Naroff 7a147c6a3c Remove support for BlockExprExpr. For example...
^(expression) or ^(int arg1, float arg2)(expression)
...is no longer supported. 
All block literals now require a compound statement.

llvm-svn: 56257
2008-09-16 23:11:46 +00:00
Steve Naroff 3b1e172d7e Sema::ActOnBlockReturnStmt(): Need to perform the UsualUnaryConversions on the return type.
Sema::CheckReturnStackAddr(): Make sure we skip over implicit casts.
Added some more test cases...

llvm-svn: 56254
2008-09-16 22:25:10 +00:00
Ted Kremenek 0ecb53a421 ProgramPoint now takes the space of two pointers instead of one. This change was
motivated because it became clear that the number of subclasses of ProgramPoint
would expand and we ran out of bits to represent a pointer variant. As a plus of
this change, BlockEdge program points can now be represented explicitly without
using a cache of CFGBlock* pairs in CFG.

llvm-svn: 56245
2008-09-16 18:44:52 +00:00
Zhongxing Xu 5912c6e6f0 Fixed an offset calculation error.
llvm-svn: 56242
2008-09-16 07:58:21 +00:00
Ted Kremenek 2d470fc0ba Patch by Csaba Hruska!
"Here is a patch what replaces std::ostream with llvm::raw_ostream. This patch
covers the AST library, but ignores Analysis lib."

llvm-svn: 56185
2008-09-13 05:16:45 +00:00
Ted Kremenek ef2b3a71bb Add missing spaces in path diagnostics.
llvm-svn: 56166
2008-09-12 18:17:46 +00:00
Daniel Dunbar 84b70f7f0f Add --suppress-system-warnings (on by default, use =0 to disable)
- For investigating warnings in system headers / builtins.
 - Currently also enables the behavior that allows silent redefinition
   of types in system headers. Conceptually these are separate but I
   didn't feel it was worth two options (or changing LangOptions).

llvm-svn: 56163
2008-09-12 18:10:20 +00:00
Douglas Gregor aa1e21dcbd Give string literals const element typesin C++, and cope with the deprecated C++ conversion from a string literal to a pointer-to-non-const-character
llvm-svn: 56137
2008-09-12 00:47:35 +00:00
Daniel Dunbar 484603be40 Iterate on sema for :? in Objective-C:
- Follow C99 behavior of using other operand type when one of
   operands is a null pointer constant.
 - Fix overenthusiastic devolving of any Objective-C types to id:
   o If either operand has an Objective-C object type then:
     - If both operands are interfaces and either operand can be
       assigned to the other, use that type as the composite type.
     - Otherwise, if either type is id, use id as the composite type.
     - Otherwise, warn about incompatible types and use id as the
       composite type.
 - Return handling of qualified idea to separate test following
   general pointer type checking.
   o Upgraded from old code to allow devolving to id (without warning,
     which matches GCC).
 - <rdar://problem/6212771>

Add test case for issues fixed above, XFAIL though because it exposed
a new issue in property handling.

llvm-svn: 56135
2008-09-11 23:12:46 +00:00
Argyrios Kyrtzidis 47f9865182 Add comments about C++ clause 3.3.2p4 that mentions that the condition declaration should be local to an if/switch/while/for statement.
llvm-svn: 56134
2008-09-11 23:08:39 +00:00
Douglas Gregor 27a907eb8c bool is not an extension in C++
llvm-svn: 56103
2008-09-11 12:06:59 +00:00
Anders Carlsson 9396a89899 Make sure to store the exception in the catch parameter.
llvm-svn: 56102
2008-09-11 09:15:33 +00:00
Anders Carlsson b5130d8588 Make sure to emit the catch parameter as well as the catch body.
llvm-svn: 56101
2008-09-11 08:21:54 +00:00
Anders Carlsson 3a3c2444d6 Fix stupid mistake I made in the exception handling code
llvm-svn: 56100
2008-09-11 06:35:14 +00:00
Argyrios Kyrtzidis 176edb5490 Do implicit conversion to bool for the condition in a do-while statement.
llvm-svn: 56096
2008-09-11 05:16:22 +00:00
Argyrios Kyrtzidis fea38016a9 Fix do-while scoping in C++.
llvm-svn: 56095
2008-09-11 04:46:46 +00:00
Argyrios Kyrtzidis 9321c74bd0 Allow array-to-pointer conversion for rvalues.
llvm-svn: 56094
2008-09-11 04:25:59 +00:00
Argyrios Kyrtzidis 0fdbd6cf25 CXXConditionDeclExpr expression node is an lvalue.
llvm-svn: 56093
2008-09-11 04:22:26 +00:00
Argyrios Kyrtzidis 504bb844ba Revert r56078, getLang().C99 being true in C++ is a bug that will be fixed.
llvm-svn: 56090
2008-09-11 03:06:46 +00:00