summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaInit.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Fix representation of compound literals for C++ objects with destructors.Jordan Rose2013-05-061-5/+34
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, this compound literal expression (a GNU extension in C++): (AggregateWithDtor){1, 2} resulted in this AST: `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-CXXBindTemporaryExpr [...] 'struct AggregateWithDtor' (CXXTemporary [...]) `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 Note the two CXXBindTemporaryExprs. The InitListExpr is really part of the CompoundLiteralExpr, not an object in its own right. By introducing a new entity initialization kind in Sema specifically for compound literals, we avoid the treatment of the inner InitListExpr as a temporary. `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 llvm-svn: 181212
* Fix assert if __extension__ or _Generic is used when initializing a char ↵Richard Smith2013-05-061-4/+11
| | | | | | array from a string literal. llvm-svn: 181174
* Replace 'MultiExprArg()' with 'None'Dmitri Gribenko2013-05-051-7/+7
| | | | llvm-svn: 181166
* Handle parens properly when initializing a char array from a string literal.Richard Smith2013-05-051-3/+14
| | | | llvm-svn: 181159
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-2/+2
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Don't build a call expression referring to a function which we're not allowedRichard Smith2013-05-041-7/+14
| | | | | | | | | to use. This makes very little difference right now (other than suppressing follow-on errors in some cases), but will matter more once we support deduced return types (we don't want expressions with undeduced return types in the AST). llvm-svn: 181107
* ArrayRef'ize InitializationSequence constructor and ↵Dmitri Gribenko2013-05-031-65/+52
| | | | | | | | InitializationSequence::Diagnose() Patch by Robert Wilhelm. llvm-svn: 181022
* C++1y: support simple variable assignments in constexpr functions.Richard Smith2013-04-261-0/+1
| | | | llvm-svn: 180603
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-10/+49
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-12/+15
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Force a load when creating a reference to a temporary copied from a bitfield.Jordan Rose2013-04-111-9/+90
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For this source: const int &ref = someStruct.bitfield; We used to generate this AST: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'const int' lvalue <NoOp> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Notice the lvalue inside the MaterializeTemporaryExpr, which is very confusing (and caused an assertion to fire in the analyzer - PR15694). We now generate this: DeclStmt [...] `-VarDecl [...] ref 'const int &' `-MaterializeTemporaryExpr [...] 'const int' lvalue `-ImplicitCastExpr [...] 'int' <LValueToRValue> `-MemberExpr [...] 'int' lvalue bitfield .bitfield [...] `-DeclRefExpr [...] 'struct X' lvalue ParmVar [...] 'someStruct' 'struct X' Which makes a lot more sense. This allows us to remove code in both CodeGen and AST that hacked around this special case. The commit also makes Clang accept this (legal) C++11 code: int &&ref = std::move(someStruct).bitfield PR15694 / <rdar://problem/13600396> llvm-svn: 179250
* <rdar://problem/13278115> Improve diagnostic when failing to bind an rvalue ↵Douglas Gregor2013-03-261-0/+8
| | | | | | reference to an lvalue of compatible type. llvm-svn: 178095
* <rdar://problem/13395022> Strip references when extracting an ↵Douglas Gregor2013-03-251-2/+2
| | | | | | initializer_list's element type during application of an initialization sequence. llvm-svn: 177944
* Add a clarifying note when a return statement is rejected becauseJohn McCall2013-03-191-6/+22
| | | | | | | | we expect a related result type. rdar://12493140 llvm-svn: 177378
* Bring inheriting constructor implementation up-to-date with current defectRichard Smith2013-03-181-3/+6
| | | | | | | | | reports, and implement implicit definition of inheriting constructors. Remaining missing features: inheriting constructor templates, implicit exception specifications for inheriting constructors, inheriting constructors from dependent bases. llvm-svn: 177320
* Replace TypeLoc llvm::cast support to be well-defined.David Blaikie2013-02-181-3/+3
| | | | | | | | | | | | | | The TypeLoc hierarchy used the llvm::cast machinery to perform undefined behavior by casting pointers/references to TypeLoc objects to derived types and then using the derived copy constructors (or even returning pointers to derived types that actually point to the original TypeLoc object). Some context is in this thread: http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-December/056804.html Though it's spread over a few months which can be hard to read in the mail archive. llvm-svn: 175462
* Make helper functions static.Benjamin Kramer2013-02-151-1/+2
| | | | llvm-svn: 175265
* The meat of this patch is in BuildCXXMemberCalLExpr where we make it useNick Lewycky2013-02-121-7/+4
| | | | | | | | | | | | MarkMemberReferenced instead of marking functions referenced directly. An audit of callers to MarkFunctionReferenced and DiagnoseUseOfDecl also caused a few other changes: * don't mark functions odr-used when considering them for an initialization sequence. Do mark them referenced though. * the function nominated by the cleanup attribute should be diagnosed. * operator new/delete should be diagnosed when building a 'new' expression. llvm-svn: 174951
* Add OpenCL samplers as Clang builtin types and check sampler related ↵Guy Benyei2013-02-071-1/+45
| | | | | | restrictions. llvm-svn: 174601
* Add some missing diagnostics for C++11 narrowing conversions.Richard Smith2013-02-051-4/+9
| | | | llvm-svn: 174337
* Don't forget to run destructors when we create an array temporary of class type.Richard Smith2013-02-021-2/+5
| | | | llvm-svn: 174257
* Revert r172285 (suppressing a 'redundant' -Wc++98-compat warning) and add aRichard Smith2013-01-261-1/+0
| | | | | | testcase for a situation it caused us to miss. llvm-svn: 173540
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-1/+48
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* Don't crash when binding a reference to a temporary pointer created fromRichard Smith2013-01-151-0/+4
| | | | | | | | resolving an overloaded function reference within an initializer list. Previously we would try to resolve the overloaded function reference without first stripping off the InitListExpr wrapper. llvm-svn: 172517
* Only produce one -Wc++98-compat warning when initializing a reference from ↵Richard Smith2013-01-121-0/+1
| | | | | | an init list with multiple elements. llvm-svn: 172285
* PR14838: When a member reference is bound to a temporary, don't forget toRichard Smith2013-01-081-2/+2
| | | | | | | perform the semantic checks associated with the destruction of that temporary. It'll be destroyed at the end of the constructor. llvm-svn: 171818
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-17/+17
| | | | llvm-svn: 171367
* Fix for PR12222.Erik Verbruggen2012-12-251-5/+5
| | | | | | | | Changed getLocStart() and getLocEnd() to be required for Stmts, and make getSourceRange() optional. The default implementation for getSourceRange() is build the range by calling getLocStart() and getLocEnd(). llvm-svn: 171067
* PR13470: Ensure that copy-list-initialization isntantiates asRichard Smith2012-12-191-10/+16
| | | | | | | | | | | | copy-list-initialization (and doesn't add an additional copy step): Fill in the ListInitialization bit when creating a CXXConstructExpr. Use it when instantiating initializers in order to correctly handle instantiation of copy-list-initialization. Teach TreeTransform that function arguments are initializations, and so need this special treatment too. Finally, remove some hacks which were working around SubstInitializer's shortcomings. llvm-svn: 170489
* Change DeclContextLookup(Const)Result to (Mutable)ArrayRef<NamedDecl*>, as ↵David Blaikie2012-12-191-14/+10
| | | | | | | | | | | | | | | per review discussion in r170365 This does limit these typedefs to being sequences, but no current usage requires them to be contiguous (we could expand this to a more general iterator pair range concept at some point). Also, it'd be nice if SmallVector were constructible directly from an ArrayRef but this is a bit tricky since ArrayRef depends on SmallVectorBaseImpl for the inverse conversion. (& generalizing over all range-like things, while nice, would require some nontrivial SFINAE I haven't thought about yet) llvm-svn: 170482
* Implement C++03 [dcl.init]p5's checking for value-initialization of referencesRichard Smith2012-12-081-4/+64
| | | | | | | | properly, rather than faking it up by pretending that a reference member makes the default constructor non-trivial. That leads to rejects-valids when putting such types inside unions. llvm-svn: 169662
* Sort all of Clang's files under 'lib', and fix up the broken headersChandler Carruth2012-12-041-4/+4
| | | | | | | | | | | | | uncovered. This required manually correcting all of the incorrect main-module headers I could find, and running the new llvm/utils/sort_includes.py script over the files. I also manually added quite a few missing headers that were uncovered by shuffling the order or moving headers up to be main-module-headers. llvm-svn: 169237
* Consistently use 'needsImplicit<special member>' to determine whether we needRichard Smith2012-12-011-5/+2
| | | | | | | an implicit special member, rather than sometimes using '!hasDeclared<special member>'. No functionality change. llvm-svn: 169075
* Don't return a pointer to an UnresolvedSetImpl in the CXXRecordDecl interface,Argyrios Kyrtzidis2012-11-281-9/+10
| | | | | | expose only the iterators instead. llvm-svn: 168770
* objective-C arc: load of a __weak object happens via call toFariborz Jahanian2012-11-271-7/+19
| | | | | | | | | | | objc_loadWeak. This retains and autorelease the weakly-refereced object. This hidden autorelease sometimes makes __weak variable alive even after the weak reference is erased, because the object is still referenced by an autorelease pool. This patch overcomes this behavior by loading a weak object via call to objc_loadWeakRetained(), followng it by objc_release at appropriate place, thereby removing the hidden autorelease. // rdar://10849570 llvm-svn: 168740
* Copy the decls returned by DeclContext::lookup_result to aArgyrios Kyrtzidis2012-11-131-12/+27
| | | | | | | | | new container so we can safely iterate over them. The container holding the lookup decls can under certain conditions be changed while iterating (e.g. because of deserialization). llvm-svn: 167816
* PR14021: Copy lookup results to ensure safe iteration.David Blaikie2012-10-181-2/+8
| | | | | | | | | | | | | | | | | Within the body of the loop the underlying map may be modified via Sema::AddOverloadCandidate -> Sema::CompareReferenceRelationship -> Sema::RequireCompleteType to avoid the use of invalid iterators the sequence is copied first. A reliable, though large, test case is available - it will be reduced and committed shortly. Patch by Robert Muth. Review by myself, Nico Weber, and Rafael Espindola. llvm-svn: 166188
* Tests for DR1507.Richard Smith2012-10-181-1/+2
| | | | llvm-svn: 166162
* Update comment to match DR1502.Richard Smith2012-10-171-2/+1
| | | | llvm-svn: 166158
* Cleaning up the self initialization checker.Richard Trieu2012-10-011-8/+0
| | | | | | | | | | | -Allow Sema to do more processing on the initial Expr before checking it. -Remove the special conditions in HandleExpr() -Move the code so that only one call site is needed. -Removed the function from Sema and only call it locally. -Warn on potentially evaluated reference variables, not just casts to r-values. -Update tests. llvm-svn: 164951
* When processing an InitListExpr and skipping the initialization of an invalidRichard Smith2012-09-281-0/+2
| | | | | | | record, skip at least one element from the InitListExpr to avoid an infinite loop if we're initializing an array of unknown bound. llvm-svn: 164851
* Move the null check outside of the loop, no functionality change.Argyrios Kyrtzidis2012-09-101-1/+4
| | | | llvm-svn: 163553
* Push ArrayRef through the Expr hierarchy.Benjamin Kramer2012-08-241-11/+8
| | | | | | No functionality change. llvm-svn: 162552
* Now that ASTMultiPtr is nothing more than a array reference, make it a ↵Benjamin Kramer2012-08-231-1/+1
| | | | | | | | MutableArrayRef. This required changing all get() calls to data() and using the simpler constructors. llvm-svn: 162501
* Remove ASTOwningVector, it doesn't own anything and provides no value over ↵Benjamin Kramer2012-08-231-4/+4
| | | | | | SmallVector. llvm-svn: 162492
* Rip out remnants of move semantic emulation and smart pointers in Sema.Benjamin Kramer2012-08-231-32/+32
| | | | | | | These were nops for quite a while and only lead to confusion. ASTMultiPtr now behaves like a proper dumb array reference. llvm-svn: 162475
* Fix a bunch of -Wdocumentation warnings.Dmitri Gribenko2012-08-231-1/+1
| | | | llvm-svn: 162452
* Simplify code, no functionality change.Benjamin Kramer2012-08-041-2/+1
| | | | llvm-svn: 161303
* Explicitly defaulted constructors cannot be used for default initialization.Aaron Ballman2012-07-311-1/+1
| | | | llvm-svn: 161088
* When testing whether we can perform copy or move initialization, beDouglas Gregor2012-07-311-2/+2
| | | | | | sure to supply an initialization location. Fixes <rdar://problem/11951661>. llvm-svn: 161084
OpenPOWER on IntegriCloud