summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Attempt to fix a read-after-free running test/Sema/designated-initializers.c.Eli Friedman2009-04-161-3/+3
| | | | | | Douglas, can you check that this is doing the right thing? llvm-svn: 69298
* Implement support for designated initializers that refer to members ofDouglas Gregor2009-04-151-12/+85
| | | | | | anonymous structs or unions. Fixes PR3778. llvm-svn: 69153
* Switch designated-initializer checking from using designator iteratorsDouglas Gregor2009-04-151-16/+17
| | | | | | to using designator indices. No functionality change. llvm-svn: 69147
* Propagate the ASTContext to various AST traversal and lookup functions.Douglas Gregor2009-04-091-11/+16
| | | | | | No functionality change (really). llvm-svn: 68726
* Add some more code modification hintsDouglas Gregor2009-04-011-1/+3
| | | | llvm-svn: 68261
* Make our diagnostics about the obsolete GNU designated-initializerDouglas Gregor2009-03-281-2/+2
| | | | | | | syntax into extension warnings, and provide code-modification hints showing how to fix the problem. llvm-svn: 67885
* Fix a thinko in the pre-allocation strategy for structured initializerDouglas Gregor2009-03-211-2/+10
| | | | | | | | | | 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
* When building the structured initializer list, pre-allocate storage inDouglas Gregor2009-03-201-0/+26
| | | | | | | | | | | 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
* Allow flexible array initializers that are not surrounded byDouglas Gregor2009-03-201-6/+19
| | | | | | | | 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
* Almost complete implementation of rvalue references. One bug, and a few ↵Sebastian Redl2009-03-161-1/+1
| | | | | | unclear areas. Maybe Doug can shed some light on some of the fixmes. llvm-svn: 67059
* Fix PR3509 by providing correct starting locations for initializer listsDouglas Gregor2009-03-011-11/+11
| | | | llvm-svn: 65777
* Eliminate CXXRecordTypeDouglas Gregor2009-02-281-2/+2
| | | | llvm-svn: 65671
* fix a bozobug.Chris Lattner2009-02-261-0/+1
| | | | llvm-svn: 65589
* ok, not as broken as I thought, just confusing. This allows Chris Lattner2009-02-261-1/+1
| | | | | | | initialization of wchar_t arrays with wide strings, and generalizes wchar_size.c to work on all targets. llvm-svn: 65586
* allow wide strings to initialize arrays compatible with wchar_t. Chris Lattner2009-02-261-6/+25
| | | | | | | Unfortunately this doesn't work yet because wchar_t is completely broken in C. llvm-svn: 65585
* handle @encode interactions with array initializers.Chris Lattner2009-02-241-17/+21
| | | | llvm-svn: 65401
* rename CheckStringLiteralInit to CheckStringInit and pass in the Chris Lattner2009-02-241-19/+26
| | | | | | string size as an argument. llvm-svn: 65400
* make SemaRef be a reference to sema, not a pointer.Chris Lattner2009-02-241-78/+78
| | | | llvm-svn: 65399
* move InitListChecker to be private to SemaInit.cppChris Lattner2009-02-241-4/+3
| | | | llvm-svn: 65398
* Make CheckSingleInitializer a static function in SemaInit.cppChris Lattner2009-02-241-13/+13
| | | | llvm-svn: 65397
* make CheckStringLiteralInit a static function in SemaInit.cppChris Lattner2009-02-241-18/+19
| | | | llvm-svn: 65396
* change IsStringLiteralInit into a static function in SemaInit.cppChris Lattner2009-02-241-7/+8
| | | | llvm-svn: 65395
* move some initialization checking code from SemaDecl.cppChris Lattner2009-02-241-3/+156
| | | | | | to SemaInit.cpp, no functionality change. llvm-svn: 65394
* Downgrade the "excess elements in initializer" errors to warnings *inDouglas Gregor2009-02-181-4/+10
| | | | | | C*. They're required errors in C++. llvm-svn: 64964
* Fix a bug with designated initializers where we were stepping out of aDouglas Gregor2009-02-121-8/+7
| | | | | | | | | union subobject initialization before checking whether the next initiailizer was actually a designated initializer. This led to spurious "excess elements in union initializer" errors. Thanks to rdivacky for reporting the bug! llvm-svn: 64392
* When handling "the rest" of a designated array subobject, maybe sureDouglas Gregor2009-02-091-1/+1
| | | | | | | | to tell it that it wasn't (directly) designated. This way, we unwind back to the explicit initializer list properly rather than getting stuck in the wrong subobject. Fixes llvm.org/PR3519 llvm-svn: 64155
* Implement semantic analysis for the GNU flexible array initializationDouglas Gregor2009-02-041-27/+127
| | | | | | | | | | | | | extension. The interaction with designated initializers is a bit... interesting... but we follow GNU's lead and don't permit too much crazy code in this area. Also, make the "excess initializers" error message a bit more informative. Addresses PR2561: http://llvm.org/bugs/show_bug.cgi?id=2561 llvm-svn: 63785
* Add iterators to LookupResult, allowing one to iterate over theDouglas Gregor2009-02-021-0/+2
| | | | | | | non-ambiguous name lookup results without allocating any memory, e.g., for sets of overloaded functions. llvm-svn: 63549
* Check value-initializations that occur when an initializer listDouglas Gregor2009-02-021-17/+106
| | | | | | provides too few elements. llvm-svn: 63525
* Upgrade the "excess elements in array initializer" warning to anDouglas Gregor2009-01-301-2/+3
| | | | | | | error, since both C99 and C++ consider it an error. For reference, GCC makes this a warning while G++ makes it an error. llvm-svn: 63435
* Implement and test aggregate initialization in C++. Major changes:Douglas Gregor2009-01-301-31/+155
| | | | | | | | | | | | | | | | - Support initialization of reference members; complain if any reference members are left uninitialized. - Use C++ copy-initialization for initializing each element (falls back to constraint checking in C) - Make sure we diagnose when one tries to provide an initializer list for a non-aggregate. - Don't complain about empty initializers in C++ (they are permitted) - Unrelated but necessary: don't bother trying to convert the decl-specifier-seq to a type when we're dealing with a C++ constructor, destructor, or conversion operator; it results in spurious warnings. llvm-svn: 63431
* Switch Type::isAggregateType to use the C++ definition of "aggregateDouglas Gregor2009-01-301-2/+2
| | | | | | | | type" rather than the C definition. We do this because both C99 and Clang always use "aggregate type" as "aggregate or union type", and the C++ definition includes union types. llvm-svn: 63395
* Make CodeGen produce an error if we come across a non-constant initializer ↵Douglas Gregor2009-01-291-3/+1
| | | | | | list that involves the GNU array-range designator extension llvm-svn: 63327
* Introduce a new expression node, ImplicitValueInitExpr, thatDouglas Gregor2009-01-291-8/+20
| | | | | | | | | | | | | represents an implicit value-initialization of a subobject of a particular type. This replaces the (ab)use of CXXZeroValueInitExpr within initializer lists for the "holes" that occur due to the use of C99 designated initializers. The new test case is currently XFAIL'd, because CodeGen's ConstExprEmitter (in lib/CodeGen/CGExprConstant.cpp) needs to be taught to value-initialize when it sees ImplicitValueInitExprs. llvm-svn: 63317
* Clean up designated initialization of unions, so that CodeGen doesn'tDouglas Gregor2009-01-291-3/+14
| | | | | | have to try to guess which member is being initialized. llvm-svn: 63315
* move library-specific diagnostic headers into library private dirs. ReduceChris Lattner2009-01-291-1/+0
| | | | | | redundant #includes. Patch by Anders Johnsen! llvm-svn: 63271
* fix an absolutely inscrutible gcc 4.0 error:Chris Lattner2009-01-291-1/+5
| | | | | | | | | | | | llvm[0]: Compiling SemaInit.cpp for Debug build SemaInit.cpp:171: error: ‘InitListChecker’ has not been declared SemaInit.cpp:171: error: ISO C++ forbids declaration of ‘InitListChecker’ with no type SemaInit.cpp: In function ‘int InitListChecker(clang::Sema*, clang::InitListExpr*, clang::QualType&)’: SemaInit.cpp:172: error: ‘hadError’ was not declared in this scope SemaInit.cpp:173: error: ‘SemaRef’ was not declared in this scope SemaInit.cpp:177: error: ‘FullyStructuredList’ was not declared in this scope llvm-svn: 63270
* Better documentation for our initialization checkerDouglas Gregor2009-01-291-19/+48
| | | | llvm-svn: 63261
* Move InitListChecker out of Sema.hDouglas Gregor2009-01-291-0/+76
| | | | llvm-svn: 63258
* Eliminate infinite looping in a wacky case with designated initializers. ↵Douglas Gregor2009-01-291-17/+24
| | | | | | Simplifies (somewhat) the actually checking of the initializer expression following the designators llvm-svn: 63257
* Remove Expr::hasSideEffects. It doesn't work anywayDouglas Gregor2009-01-281-2/+2
| | | | llvm-svn: 63254
* Improvements to code-generation and semantic analysis of designatedDouglas Gregor2009-01-281-37/+75
| | | | | | | | | | | | initializers. - We now initialize unions properly when a member other than the first is named by a designated initializer. - We now provide proper semantic analysis and code generation for GNU array-range designators *except* that side effects will occur more than once. We warn about this. llvm-svn: 63253
* Code generation support for C99 designated initializers.Douglas Gregor2009-01-281-97/+345
| | | | | | | | | | | | | | | | | | | | The approach I've taken in this patch is relatively straightforward, although the code itself is non-trivial. Essentially, as we process an initializer list we build up a fully-explicit representation of the initializer list, where each of the subobject initializations occurs in order. Designators serve to "fill in" subobject initializations in a non-linear way. The fully-explicit representation makes initializer lists (both with and without designators) easy to grok for codegen and later semantic analyses. We keep the syntactic form of the initializer list linked into the AST for those clients interested in exactly what the user wrote. Known limitations: - Designating a member of a union that isn't the first member may result in bogus initialization (we warn about this) - GNU array-range designators are not supported (we warn about this) llvm-svn: 63242
* Split the single monolithic DiagnosticKinds.def file into oneChris Lattner2009-01-271-1/+1
| | | | | | | | | .def file for each library. This means that adding a diagnostic to sema doesn't require all the other libraries to be rebuilt. Patch by Anders Johnsen! llvm-svn: 63111
* More APSInt appeasementDouglas Gregor2009-01-231-12/+20
| | | | llvm-svn: 62884
* Hopefully the last of the APSInt signedness issues with initializers. Fixes ↵Douglas Gregor2009-01-231-0/+1
| | | | | | PR clang/3378 llvm-svn: 62876
* Make sure all of the isUnsigned flags line up when comparing initializer ↵Douglas Gregor2009-01-231-3/+7
| | | | | | values, to really really fix PR clang/3377 llvm-svn: 62858
* Properly manage the bit-widths of APInts/APSInts in array initialization.Douglas Gregor2009-01-231-7/+12
| | | | | | Fixes PR clang/3377 llvm-svn: 62851
* Reimplement the handling of the "current object" in designatorDouglas Gregor2009-01-221-145/+197
| | | | | | | | | | | initializers, so that we are within the appropriate subobject after we've processed a multi-designator designation. We're matching GCC and EDG's behavior on all examples I've found thus far. *Huge* thanks to Eli Friedman for pointing out my fundamental misunderstanding of "current object" in the C99 spec. llvm-svn: 62812
* Initial implementation of semantic analysis and ASTs for C99Douglas Gregor2009-01-221-33/+358
| | | | | | | | | | | | | | | | | | designated initializers. This implementation should cover all of the constraints in C99 6.7.8, including long, complex designations and computing the size of incomplete array types initialized with a designated initializer. Please see the new test-case and holler if you find cases where this doesn't work. There are still some wrinkles with GNU's anonymous structs and anonymous unions (it isn't clear how these should work; we'll just follow GCC's lead) and with designated initializers for the members of a union. I'll tackle those very soon. CodeGen is still nonexistent, and there's some leftover code in the parser's representation of designators that I'll also need to clean up. llvm-svn: 62737
OpenPOWER on IntegriCloud