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
Ted Kremenek
944375abae
Update checker build.
...
llvm-svn: 57303
2008-10-08 18:32:06 +00:00
Steve Naroff
35530480c2
Touchup the rewriter to handle the new BlockExpr->BlockDecl dance.
...
llvm-svn: 57299
2008-10-08 17:31:13 +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
21cc560188
Remove DeclStmt::getDecl(). Now clients of DeclStmt must explicitly reason about a DeclStmt referring to a collection of Decls.
...
llvm-svn: 57217
2008-10-06 22:51:42 +00:00
Ted Kremenek
db7f2a74db
Explicitly access the first Decl* referenced by a DeclStmt instead of using "getDecl()." Added a FIXME indicating that the call to RewriteObjCQualifiedInterfaceTypes() is meant to modifying the type-specifier; hopefully this will be a little more clean once DeclGroups contain type specifiers.
...
llvm-svn: 57216
2008-10-06 22:45:07 +00:00
Ted Kremenek
5b6f8ee7b9
Use "DeclStmt::getSolitaryDecl()" when accessing the DeclStmt of an @catch .
...
llvm-svn: 57215
2008-10-06 22:39:38 +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
292b3842a0
Use DeclStmt::getSolitaryDecl() instead of DeclStmt::getDecl() when rewriting Objective-c foreach statements.
...
llvm-svn: 57212
2008-10-06 22:16:13 +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
53532c1fda
In RewriteFunctionBody, using DeclStmt::decl_iterator to rewrite the Decls in a DeclStmt instead of using getDecl() to fetch the first Decl.
...
Steve: Please review this patch. 'make test' passes, and my cursory scan of the rewriter leads me to believe this doesn't break anything, but I'm not sure.
llvm-svn: 57195
2008-10-06 18:47:09 +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
Ted Kremenek
f8a2765fb7
Use DeclStmt::decl_iterator instead of walking the ScopedDecl chain (which will soon be removed).
...
llvm-svn: 57187
2008-10-06 18:36:52 +00:00
Ted Kremenek
151534a197
Add const_decl_iterator to DecStmt.
...
llvm-svn: 57186
2008-10-06 18:35:55 +00:00
Ted Kremenek
c7d5d976bf
Update Xcode project.
...
llvm-svn: 57180
2008-10-06 17:42:44 +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
Ted Kremenek
3b670d1a0c
Updated checker build.
...
llvm-svn: 57176
2008-10-06 15:46:11 +00:00
Chris Lattner
25728d931a
fix incorrect rdar number.
...
llvm-svn: 57165
2008-10-06 07:43:28 +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
b7c86a211c
Remove the 'C' / isConstantExpr flag on builtins. Code should never
...
depend on the value of this flag, it should depend on whether
tryEvaluate is able to *actually* fold a builtin.
llvm-svn: 57160
2008-10-06 06:51:12 +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
Daniel Dunbar
6ba6cc42d4
Add script for checking builtin macros verse another compiler ($CC or
...
gcc).
llvm-svn: 57133
2008-10-05 20:39: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
Chris Lattner
9daca0e561
Fix a problem reported in PR2766 that makes clang reject old versions
...
of GCC's headers. This impacts people that run clang in Tiger systems.
llvm-svn: 57126
2008-10-05 19:05:44 +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
Anders Carlsson
d27a0c2395
Change indentation for a couple of files in the Xcode project.
...
llvm-svn: 57120
2008-10-05 18:04:30 +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
5af11b2462
Move the TentativeParsingResult enum closer to where it gets used.
...
No functionality change.
llvm-svn: 57115
2008-10-05 17:02:44 +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
93bc49d882
Add X86 builtin code generation test case.
...
llvm-svn: 57104
2008-10-05 06:38:36 +00:00
Daniel Dunbar
363a5c0a1b
Improve C language testing coverage.
...
llvm-svn: 57103
2008-10-05 06:36:33 +00:00
Daniel Dunbar
35bd17f1a5
Fix X86 palignr[128] builtins to match LLVM.
...
llvm-svn: 57102
2008-10-05 06:35:41 +00:00
Daniel Dunbar
b11d5d65e8
Add some builtins to codegen test case.
...
llvm-svn: 57101
2008-10-05 06:34:45 +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
Daniel Dunbar
e47e96a4a5
Fix another X86 builtin definitions.
...
- vec_set_v4hi had "v4s" in place of "V4s"
llvm-svn: 57099
2008-10-05 05:21:00 +00:00
Daniel Dunbar
91d8be141b
Fix some X86 builtin definitions.
...
- cmp instructions return int
- storedqu had bad const qualifier
- pmuldq128 used invalid type code
llvm-svn: 57098
2008-10-05 05:14:37 +00:00
Daniel Dunbar
0af89ff0fb
Add -rewrite-macros test case.
...
llvm-svn: 57094
2008-10-05 01:39:04 +00:00