summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema
Commit message (Collapse)AuthorAgeFilesLines
...
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-212-9/+35
| | | | | | initializers of data members (both static and non-static). llvm-svn: 151017
* Implement name mangling for lambda expressions that occur within theDouglas Gregor2012-02-214-7/+40
| | | | | | | | | | | | | | | | default arguments of function parameters. This simple-sounding task is complicated greatly by two issues: (1) Default arguments aren't actually a real context, so we need to maintain extra state within lambda expressions to track when a lambda was actually in a default argument. (2) At the time that we parse a default argument, the FunctionDecl doesn't exist yet, so lambda closure types end up in the enclosing context. It's not clear that we ever want to change that, so instead we introduce the notion of the "effective" context of a declaration for the purposes of name mangling. llvm-svn: 151011
* Make RequireLiteralType work correctly with incomplete array types. PR12037.Eli Friedman2012-02-201-2/+8
| | | | llvm-svn: 151005
* Fix a constexpr FIXME: When implicitly instantiating the primary template for anRichard Smith2012-02-202-7/+8
| | | | | | | explicit specialization of a function template, mark the instantiation as constexpr if the specialization is, rather than requiring them to match. llvm-svn: 151001
* Make sure that we set up the right declaration contexts when creatingDouglas Gregor2012-02-201-2/+2
| | | | | | | | | and introducing the lambda closure type and its function call operator. Previously, we assumed that the lambda closure type would land directly in the current context, and not some parent context (as occurs with linkage specifications). Thanks to Richard for the test case. llvm-svn: 150987
* modern objc translator. Finish off first cut of theFariborz Jahanian2012-02-201-0/+4
| | | | | | | modern meta-data translation by commenting out private ivar declarations in user source. Also, added several tests. llvm-svn: 150985
* When we resolve the type of an 'auto' variable, clear out the linkageDouglas Gregor2012-02-201-1/+2
| | | | | | | of that variable; it will need to be recomputed with the resolved type. llvm-svn: 150984
* Basic support for name mangling of C++11 lambda expressions. BecauseDouglas Gregor2012-02-202-3/+14
| | | | | | | | | | | | | | | name mangling in the Itanium C++ ABI for lambda expressions is so dependent on context, we encode the number used to encode each lambda as part of the lambda closure type, and maintain this value within Sema. Note that there are a several pieces still missing: - We still get the linkage of lambda expressions wrong - We aren't properly numbering or mangling lambda expressions that occur in default function arguments or in data member initializers. - We aren't (de-)serializing the lambda numbering tables llvm-svn: 150982
* Emit a warning when list-initializing a std::initializer_list member.Sebastian Redl2012-02-192-1/+10
| | | | llvm-svn: 150933
* Add a testcase for using objects with list-constructors, and fix a Sema ↵Sebastian Redl2012-02-191-5/+17
| | | | | | crash by repeating an old hack. llvm-svn: 150925
* Fix a crash for nested initializer list initialization. Still does the wrong ↵Sebastian Redl2012-02-191-10/+19
| | | | | | thing in CodeGen, in that it never destructs anything. llvm-svn: 150922
* Remove dead code.Ahmed Charles2012-02-191-8/+0
| | | | llvm-svn: 150919
* Fix wrong-code bug: __imag on a scalar lvalue should produce a zero rvalue,Richard Smith2012-02-181-4/+10
| | | | | | rather than an lvalue referring to the scalar. llvm-svn: 150889
* Remove a debugging line accidentally left in the last commit.David Chisnall2012-02-181-1/+0
| | | | llvm-svn: 150882
* Implement #pragma redefine_extname.David Chisnall2012-02-181-0/+32
| | | | | | This fixes PR5172 and allows clang to compile C++ programs on Solaris using the system headers. llvm-svn: 150881
* Remove unused but set variable.Benjamin Kramer2012-02-181-3/+0
| | | | llvm-svn: 150877
* Rewrite variable capture within lambda expressions and blocks,Douglas Gregor2012-02-185-203/+212
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | eliminating a bunch of redundant code and properly modeling how the captures of outside blocks/lambdas affect the types seen by inner captures. This new scheme makes two passes over the capturing scope stack. The first pass goes up the stack (from innermost to outermost), assessing whether the capture looks feasible and stopping when it either hits the scope where the variable is declared or when it finds an existing capture. The second pass then walks down the stack (from outermost to innermost), capturing the variable at each step and updating the captured type and the type that an expression referring to that captured variable would see. It also checks type-specific restrictions, such as the inability to capture an array within a block. Note that only the first odr-use of each variable needs to do the full walk; subsequent uses will find the capture immediately, so multiple walks need not occur. The same routine that builds the captures can also compute the type of the captures without signaling errors and without actually performing the capture. This functionality is used to determine the type of declaration references as well as implementing the weird decltype((x)) rule within lambda expressions. The capture code now explicitly takes sides in the debate over C++ core issue 1249, which concerns the type of captures within nested lambdas. We opt to use the more permissive, more useful definition implemented by GCC rather than the one implemented by EDG. llvm-svn: 150875
* Unify our computation of the type of a captured reference to aDouglas Gregor2012-02-182-77/+43
| | | | | | | variable; it was previously duplicated, and one of the copies failed to account for outer non-mutable lambda captures. llvm-svn: 150872
* Add a bunch of missing calls to DiagnoseSentinelCalls. ↵Eli Friedman2012-02-183-0/+14
| | | | | | | | <rdar://problem/10885993>. This should probably be refactored... but it isn't completely obvious what refactoring is best. llvm-svn: 150869
* Diagnose uses of deleted destructors and inaccessible defaulted destructors.Richard Smith2012-02-182-14/+23
| | | | | | | | | | We had two separate issues here: firstly, varions functions were assuming that they did not need to perform semantic checks on trivial destructors (this is not true in C++11, where a trivial destructor can nonetheless be private or deleted), and a bunch of DiagnoseUseOfDecl calls were missing for uses of destructors. llvm-svn: 150866
* Initial refactoring of 'ShouldDeleteSpecialMember', in preparation for providingRichard Smith2012-02-182-612/+307
| | | | | | | | | decent diagnostics. Finish the work of combining all the 'ShouldDelete' functions into one. In unifying the code, fix a minor bug where an anonymous union with a deleted default constructor as a member of a union wasn't being considered as making the outer union's default constructor deleted. llvm-svn: 150862
* Don't allow non-empty ParenListExprs as array-new initializers.Sebastian Redl2012-02-171-5/+2
| | | | | | Don't know what I was thinking there. Fixes PR12023. llvm-svn: 150804
* Basic code generation support for std::initializer_list.Sebastian Redl2012-02-171-0/+1
| | | | | | | | | | | | | | | | | | | | | | | We now generate temporary arrays to back std::initializer_list objects initialized with braces. The initializer_list is then made to point at the array. We support both ptr+size and start+end forms, although the latter is untested. Array lifetime is correct for temporary std::initializer_lists (e.g. call arguments) and local variables. It is untested for new expressions and member initializers. Things left to do: Massively increase the amount of testing. I need to write tests for start+end init lists, temporary objects created as a side effect of initializing init list objects, new expressions, member initialization, creation of temporary objects (e.g. std::vector) for initializer lists, and probably more. Get lifetime "right" for member initializers and new expressions. Not that either are very useful. Implement list-initialization of array new expressions. llvm-svn: 150803
* Only add 'const' to the type of variables captured in a lambda whenDouglas Gregor2012-02-171-2/+7
| | | | | | we're capturing it by value in a non-mutable lambda. llvm-svn: 150791
* Rework the Sema/AST/IRgen dance for the lambda closure type'sDouglas Gregor2012-02-172-7/+69
| | | | | | | | | | | | | | | | | | | | conversion to function pointer. Rather than having IRgen synthesize the body of this function, we instead introduce a static member function "__invoke" with the same signature as the lambda's operator() in the AST. Sema then generates a body for the conversion to function pointer which simply returns the address of __invoke. This approach makes it easier to evaluate a call to the conversion function as a constant, makes the linkage of the __invoke function follow the normal rules for member functions, and may make life easier down the road if we ever want to constexpr'ify some of lambdas. Note that IR generation is responsible for filling in the body of __invoke (Sema just adds a dummy body), because the body can't generally be expressed in C++. Eli, please review! llvm-svn: 150783
* Reject continue/break statements within members of local functions nested withinRichard Smith2012-02-171-7/+11
| | | | | | | | | | | | | | | loop and switch statements, by teaching Scope that a function scope never has a continue/break parent for the purposes of control flow. Remove the hack in block and lambda expressions which worked around this by pretending that such expressions were continue/break scopes. Remove Scope::ControlParent, since it's unused. In passing, teach default statements to recover properly from a missing ';', and add a fixit for same to both default and case labels (the latter already recovered correctly). llvm-svn: 150776
* Avoid infinite mutual recursion in DiagnoseInvalidRedeclaration.Kaelyn Uhrain2012-02-161-2/+18
| | | | | | | | Don't try to typo-correct a method redeclaration to declarations not in the current record as it could lead to infinite recursion if CorrectTypo finds more than one correction candidate in a parent record. llvm-svn: 150735
* Lambda closure types are always considered to be like "local" classes,Douglas Gregor2012-02-162-3/+7
| | | | | | | | | even if they are not within a function scope. Teach template instantiation to treat them as such, and make sure that we have a local instantiation scope when instantiating default arguments and static data members. llvm-svn: 150725
* C++11 allows unions to have static data members. Remove the correspondingRichard Smith2012-02-161-7/+11
| | | | | | restriction and add some tests. llvm-svn: 150721
* If code completion patterns are not enabled, use simpler else/else ifDouglas Gregor2012-02-161-12/+16
| | | | | | completions that don't insert braces. Fixes <rdar://problem/10764168>. llvm-svn: 150707
* Add fixits for ARC casting errors for implicit conversions as well. ↵Argyrios Kyrtzidis2012-02-161-16/+86
| | | | | | | | | | rdar://10289283 Also fix the fixit (oh the irony) when it uses CFBridgingRetain/CFBridgingRelease; they are supposed to be calls with the casted expression as parameter, they should not be inserted into the cast like the __bridge keywords. llvm-svn: 150705
* Minor fix to template instantiation, which properly instantiatesDeLesley Hutchins2012-02-161-1/+1
| | | | | | dependent attributes on static members of templatized classes. llvm-svn: 150704
* Thread safety analysis: Don't check for lockable on undefined types.DeLesley Hutchins2012-02-161-0/+3
| | | | llvm-svn: 150702
* Proper checking of list-initializers for array new expressions.Sebastian Redl2012-02-161-9/+28
| | | | | | This finishes generalized initializer support in Sema. llvm-svn: 150688
* Revert "Revert "Make CXXNewExpr contain only a single initialier, and not ↵Sebastian Redl2012-02-163-125/+113
| | | | | | | | hold the used constructor itself."" This reintroduces commit r150682 with a fix for the Bullet benchmark crash. llvm-svn: 150685
* Revert "Make CXXNewExpr contain only a single initialier, and not hold the ↵Sebastian Redl2012-02-163-113/+125
| | | | | | | | | | used constructor itself." It leads to a compiler crash in the Bullet benchmark. This reverts commit r12014. llvm-svn: 150684
* Make CXXNewExpr contain only a single initialier, and not hold the used ↵Sebastian Redl2012-02-163-125/+113
| | | | | | | | | | constructor itself. Holding the constructor directly makes no sense when list-initialized arrays come into play. The constructor is now held in a CXXConstructExpr, if construction is what is done. The new design can also distinguish properly between list-initialization and direct-initialization, as well as implicit default-initialization constructors and explicit value-initialization constructors. Finally, doing it this way removes redundance from the AST because CXXNewExpr doesn't try to handle both the allocation and the initialization responsibilities. This breaks the static analysis of new expressions. I've filed PR12014 to track this. llvm-svn: 150682
* Shift Microsoft enum extensions from -fms-extensions to -fms-compatibility, ↵Eli Friedman2012-02-161-3/+3
| | | | | | so -fms-extensions doesn't affect enum semantics in incompatible ways. <rdar://problem/10657186>. llvm-svn: 150663
* Implicitly define a lambda's conversion functions (to functionDouglas Gregor2012-02-162-2/+62
| | | | | | | | | | | | | pointers and block pointers). We use dummy definitions to keep the invariant that an implicit, used definition has a body; IR generation will substitute the actual contents, since they can't be represented as C++. For the block pointer case, compute the copy-initialization needed to capture the lambda object in the block, which IR generation will need later. llvm-svn: 150645
* Silence a valgrind warning, and remove an unused var.Kaelyn Uhrain2012-02-151-3/+2
| | | | llvm-svn: 150629
* Support GCC's bug^Wextension allowing class array members to be initalized by aRichard Smith2012-02-151-0/+29
| | | | | | parenthesized braced-init-list in the base/member initialization list. llvm-svn: 150625
* Improve typo correction involving nested name specifiers.Kaelyn Uhrain2012-02-151-18/+112
| | | | | | | | | | | | Snooping in other namespaces when the identifier being corrected is already qualified (i.e. a valid CXXScopeSpec is passed to CorrectTypo) and ranking synthesized namespace qualifiers relative to the existing qualifier is now performed. Support for disambiguating the string representation of synthesized namespace qualifers has also been added (the change to test/Parser/cxx-using-directive.cpp is an example of an ambiguous relative qualifier). llvm-svn: 150622
* Lambda closure types have a conversion function to a block pointerDouglas Gregor2012-02-151-0/+50
| | | | | | | | | | | with the same parameter types and return type as the function call operator. This is the real answer to http://stackoverflow.com/questions/4148242/is-it-possible-to-convert-a-c0x-lambda-to-a-clang-block :) llvm-svn: 150620
* Factor the construction of the lambda-to-function-pointer conversion ↵Douglas Gregor2012-02-151-38/+48
| | | | | | function declaration into a separate function. No functionality change llvm-svn: 150617
* When overload resolution picks an implicitly-deleted special memberDouglas Gregor2012-02-154-12/+66
| | | | | | | | | function, provide a specialized diagnostic that indicates the kind of special member function (default constructor, copy assignment operator, etc.) and that it was implicitly deleted. Add a hook where we can provide more detailed information later. llvm-svn: 150611
* Introduce a new initialization entity for lambda captures, andDouglas Gregor2012-02-153-3/+20
| | | | | | specialize location information and diagnostics for this entity. llvm-svn: 150588
* Specialize noreturn diagnostics for lambda expressions.Douglas Gregor2012-02-152-10/+36
| | | | llvm-svn: 150586
* Fix silly precedence error.Douglas Gregor2012-02-151-1/+1
| | | | llvm-svn: 150585
* Specialize the diagnostic complaining about conflicting types ofDouglas Gregor2012-02-151-2/+2
| | | | | | | return statements within a lambda; this diagnostic previously referred to blocks. llvm-svn: 150584
* Implement code completion support for lambda capture lists.Douglas Gregor2012-02-151-13/+92
| | | | llvm-svn: 150583
OpenPOWER on IntegriCloud