Commit Graph

111 Commits

Author SHA1 Message Date
Anders Carlsson 250aada4b9 AddInitializerToDecl can't take a FullExprArg. Make it take an ExprArg, and create the CXXExprWithTemporaries before setting the initializer on the VarDecl.
llvm-svn: 79176
2009-08-16 05:13:48 +00:00
Anders Carlsson f86a8d1030 BuildCXXConstructExpr doesn't need to take an ASTContext.
llvm-svn: 79149
2009-08-15 23:41:35 +00:00
Nate Begeman 5ec4b318e3 Take 2 on AltiVec-style vector initializers.
Fixes PR4704 problems

Addresses Eli's patch feedback re: ugly cast code

Updates all postfix operators to remove ParenListExprs.  While this is awful,
no better solution (say, in the parser) is obvious to me.  Better solutions
welcome.

llvm-svn: 78621
2009-08-10 23:49:36 +00:00
Daniel Dunbar 481fe50903 Revert r78535, it is causing a number of failures to build projects.
--- Reverse-merging r78535 into '.':
D    test/Sema/altivec-init.c
U    include/clang/Basic/DiagnosticSemaKinds.td
U    include/clang/AST/Expr.h
U    include/clang/AST/StmtNodes.def
U    include/clang/Parse/Parser.h
U    include/clang/Parse/Action.h
U    tools/clang-cc/clang-cc.cpp
U    lib/Frontend/PrintParserCallbacks.cpp
U    lib/CodeGen/CGExprScalar.cpp
U    lib/Sema/SemaInit.cpp
U    lib/Sema/Sema.h
U    lib/Sema/SemaExpr.cpp
U    lib/Sema/SemaTemplateInstantiateExpr.cpp
U    lib/AST/StmtProfile.cpp
U    lib/AST/Expr.cpp
U    lib/AST/StmtPrinter.cpp
U    lib/Parse/ParseExpr.cpp
U    lib/Parse/ParseExprCXX.cpp

llvm-svn: 78551
2009-08-10 03:01:36 +00:00
Nate Begeman a96114ed08 AltiVec-style vector initializer syntax, vec4 a = (vec4)(a, b, c, d);
In addition to being defined by the AltiVec PIM, this is also the vector
initializer syntax used by OpenCL, so that vector literals are compatible
with macro arguments.

llvm-svn: 78535
2009-08-09 17:55:44 +00:00
Fariborz Jahanian 001309371e Set and use Elidable in elimination of copy ctors.
llvm-svn: 78331
2009-08-06 19:12:38 +00:00
Fariborz Jahanian d460cb4356 Handle destruction of temporaries used in default argument
construction of constructor calls.

llvm-svn: 78222
2009-08-05 18:17:32 +00:00
Fariborz Jahanian aa890bf2f3 Patch to improve ir-gen for constructors with default argument
expressions and a test case.

llvm-svn: 78213
2009-08-05 17:03:54 +00:00
Mike Stump 12b8ce168d Canonicalize else.
llvm-svn: 78102
2009-08-04 21:02:39 +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
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 b825c0ddc5 Replaced Type::getAsLValueReferenceType(), Type::getAsRValueReferenceType(), Type::getAsMemberPointerType(), Type::getAsTagType(), and Type::getAsRecordType() with their Type::getAs<XXX> equivalents.
llvm-svn: 76139
2009-07-17 01:20:38 +00:00
Nate Begeman 425038cc6d Extra vector element initializers in OpenCL is an error, not a warning.
llvm-svn: 74951
2009-07-07 21:53:06 +00:00
Douglas Gregor 04318256b7 Keep track of the Expr used to describe the size of an array type,
from Enea Zaffanella!

llvm-svn: 74831
2009-07-06 15:59:29 +00:00
Argyrios Kyrtzidis cfbfe78e9e De-ASTContext-ify DeclContext.
Remove ASTContext parameter from DeclContext's methods. This change cascaded down to other Decl's methods and changes to call sites started "escalating".
Timings using pre-tokenized "cocoa.h" showed only a ~1% increase in time run between and after this commit.

llvm-svn: 74506
2009-06-30 02:36:12 +00:00
Chris Lattner d86a13e02e Improve error recovery in C++: when we hit 'implicit int' cases in C++,
these are usually because the parser was thoroughly confused.  In addition
to typing the value being declared as an int and hoping for the best, we
mark the value as invalid so we don't get chains of errors when it is
used downstream.  In C, implicit int actually is valid, so typing the thing
as int is good and marking it invalid is bad. :)

llvm-svn: 74266
2009-06-26 04:45:06 +00:00
Eli Friedman 9782caa369 Allow initializing a vector with a vector in addition to allowing a list
of the elements.  Issue reported on cfe-dev by Mattias Holm.

llvm-svn: 73292
2009-06-13 10:38:46 +00:00
Eli Friedman 42a8465518 Fix for PR4285: allow intializing a const wchar_t array with a wide
string.

llvm-svn: 72663
2009-05-31 10:54:53 +00:00
Anders Carlsson 4b2434da54 Remove VarDecl from CXXConstructExpr.
llvm-svn: 72633
2009-05-30 20:56:46 +00:00
Anders Carlsson 28486d420b Remove VarDecl from CheckInitializerTypes now that CXXConstructExpr doesn't need to take a VarDecl anymore. (It still does, but it won't for long)
llvm-svn: 72630
2009-05-30 20:41:30 +00:00
Eli Friedman bd32745978 Make sure we don't give the wrong warning, and make sure not to set
hadError (suppressing future diagnostics) if we didn't print an 
error.

llvm-svn: 72588
2009-05-29 20:20:05 +00:00
Eli Friedman be7e42b27f Add an assertion so that we don't accidentally build constant arrays of
VLAs.

llvm-svn: 72587
2009-05-29 20:17:55 +00:00
Eli Friedman 893abe482d Revert r72575, which isn't really right, and fix up other code to
handle the construct in question correctly.

llvm-svn: 72581
2009-05-29 18:22:49 +00:00
Mike Stump fc30bf9b16 Avoid dumping during semantic analysis when checking array types when
a vla is used.

llvm-svn: 72575
2009-05-29 16:34:15 +00:00
Anders Carlsson 5063613a3b Fix another test case.
llvm-svn: 72478
2009-05-27 16:38:58 +00:00
Anders Carlsson d48a008b46 Relax an assert to an if check.
llvm-svn: 72477
2009-05-27 16:28:34 +00:00
Anders Carlsson 98cee2fde0 Create CXXConstructExprs when constructing via copy initialization.
llvm-svn: 72474
2009-05-27 16:10:08 +00:00
Douglas Gregor 0f9d4003df Template instantiation for GNU array-range designators.
llvm-svn: 72234
2009-05-21 23:30:39 +00:00
Douglas Gregor ca1aeecd37 Template instantiation for C99 designated initializers, because we
can. Also, delay semantic analysis of initialization for
value-dependent as well as type-dependent expressions, since we can't
always properly type-check a value-dependent expression.

llvm-svn: 72233
2009-05-21 23:17:49 +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
Eli Friedman 0b4af8f755 PR3009: Get rid of bogus warning for scalar compound literals.
This patch isn't quite ideal in that it eliminates the warning for 
constructs like "int a = {1};", where the braces are in fact redundant.  
However, that would have required a bunch of refactoring, and it's 
much less likely to cause confusion compared to redundant nested braces.

llvm-svn: 71939
2009-05-16 11:45:48 +00:00
Mike Stump 87c57acfb7 Reflow some comments.
llvm-svn: 71936
2009-05-16 07:39:55 +00:00
Anders Carlsson b781bcdc30 Replace more release+static_cast with takeAs.
llvm-svn: 70567
2009-05-01 19:49:17 +00:00
Chris Lattner c71d08bc22 fix PR4073 by making designated initializer checking code use
VerifyIntegerConstantExpression instead of isIntegerConstantExpr.
This makes it ext-warn but tolerate things that fold to a constant
but that are not valid i-c-e's.

There must be a bug in the i-c-e computation though, because it
doesn't catch this case even with pedantic.

This also switches the later code to use EvaluateAsInt which is
simpler and handles everything that evaluate does.

llvm-svn: 70081
2009-04-25 21:59:05 +00:00
Eli Friedman 8d25b096fa Attempt to fix a read-after-free running test/Sema/designated-initializers.c.
Douglas, can you check that this is doing the right thing?

llvm-svn: 69298
2009-04-16 17:49:48 +00:00
Douglas Gregor d5846a1eb5 Implement support for designated initializers that refer to members of
anonymous structs or unions. Fixes PR3778.

llvm-svn: 69153
2009-04-15 06:41:24 +00:00
Douglas Gregor a532416d39 Switch designated-initializer checking from using designator iterators
to using designator indices. No functionality change.

llvm-svn: 69147
2009-04-15 04:56:10 +00:00
Douglas Gregor bcced4ec31 Propagate the ASTContext to various AST traversal and lookup functions.
No functionality change (really).

llvm-svn: 68726
2009-04-09 21:40:53 +00:00
Douglas Gregor 170512fa78 Add some more code modification hints
llvm-svn: 68261
2009-04-01 23:51:29 +00:00
Douglas Gregor 5c7c9cb678 Make our diagnostics about the obsolete GNU designated-initializer
syntax into extension warnings, and provide code-modification hints
showing how to fix the problem.

llvm-svn: 67885
2009-03-28 00:41:23 +00:00
Douglas Gregor 221c9a5578 Fix a thinko in the pre-allocation strategy for structured initializer
lists. The code wasn't accounting for the distinction between the
top-level call to getStructuredSubobjectInit and later calls that
occur deeper in the hierarchy. This problem manifested itself as
over-allocation in cases where we have large arrays of small
structures (<rdar://problem/6707362>).

llvm-svn: 67452
2009-03-21 18:13:52 +00:00
Douglas Gregor 6d00c993f5 When building the structured initializer list, pre-allocate storage in
its vectors based on the subobject type we're initializing and the
(unstructured) initializer list. This eliminates some malloc thrashing
when parsing initializers (from 117 vector reallocations down to 0
when parsing Cocoa.h). We can't always pre-allocate the right amount
of storage, since designated initializers can cause us to initialize
in non-predictable patterns.

llvm-svn: 67421
2009-03-20 23:58:33 +00:00
Douglas Gregor 07d8e3a500 Allow flexible array initializers that are not surrounded by
braces. We now build the appropriate fully-structured initializer list
for such things. Per PR3618, verified that we're getting the right
code generation.

llvm-svn: 67353
2009-03-20 00:32:56 +00:00
Sebastian Redl 0f8b23f71f Almost complete implementation of rvalue references. One bug, and a few unclear areas. Maybe Doug can shed some light on some of the fixmes.
llvm-svn: 67059
2009-03-16 23:22:08 +00:00
Douglas Gregor 5741efbba0 Fix PR3509 by providing correct starting locations for initializer lists
llvm-svn: 65777
2009-03-01 17:12:46 +00:00
Douglas Gregor 89ee6822d8 Eliminate CXXRecordType
llvm-svn: 65671
2009-02-28 01:32:25 +00:00
Chris Lattner 012b339693 fix a bozobug.
llvm-svn: 65589
2009-02-26 23:42:47 +00:00
Chris Lattner 7ec0bb6bc0 ok, not as broken as I thought, just confusing. This allows
initialization of wchar_t arrays with wide strings, and generalizes
wchar_size.c to work on all targets.

llvm-svn: 65586
2009-02-26 23:36:02 +00:00
Chris Lattner a9196810b3 allow wide strings to initialize arrays compatible with wchar_t.
Unfortunately this doesn't work yet because wchar_t is completely
broken in C.

llvm-svn: 65585
2009-02-26 23:26:43 +00:00
Chris Lattner d8b741c85f handle @encode interactions with array initializers.
llvm-svn: 65401
2009-02-24 23:10:27 +00:00