summaryrefslogtreecommitdiffstats
path: root/clang/test
Commit message (Collapse)AuthorAgeFilesLines
* 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-0/+43
| | | | llvm-svn: 150583
* Convert ad-hoc `int array[expr ? -1 : 1]' assertionsDmitri Gribenko2012-02-151-24/+24
| | | | | | in test/SemaCXX/nullptr.cpp to static_assert llvm-svn: 150579
* Make -Wformat fix-its preserve original conversion specifiers.Hans Wennborg2012-02-151-11/+59
| | | | | | | | | | | | | | | | | This commit makes PrintfSpecifier::fixType() and ScanfSpecifier::fixType() only fix a conversion specification enough that Clang wouldn't warn about it, as opposed to always changing it to use the "canonical" conversion specifier. (PR11975) This preserves the user's choice of conversion specifier in cases like: printf("%a", (long double)1); where we previously suggested "%Lf", we now suggest "%La" printf("%x", (long)1); where we previously suggested "%ld", we now suggest "%lx". llvm-svn: 150578
* If a static data member of a class template which could be used in a constantRichard Smith2012-02-151-0/+8
| | | | | | | | expression is referenced, defined, then referenced again, make sure we instantiate it the second time it's referenced. This is the static data member analogue of r150518. llvm-svn: 150560
* Implement DR1454. This allows all intermediate results in constant expressionsRichard Smith2012-02-153-28/+92
| | | | | | | | | | | | to be core constant expressions (including pointers and references to temporaries), and makes constexpr calculations Turing-complete. A Turing machine simulator is included as a testcase. This opens up the possibilty of removing CCValue entirely, and removing some copies from the constant evaluator in the process, but that cleanup is not part of this change. llvm-svn: 150557
* Split reinterpret_casts of member pointers out from CK_BitCast; thisJohn McCall2012-02-151-0/+40
| | | | | | | | | | | | | | | | | | | | | is general goodness because representations of member pointers are not always equivalent across member pointer types on all ABIs (even though this isn't really standard-endorsed). Take advantage of the new information to teach IR-generation how to do these reinterprets in constant initializers. Make sure this works when intermingled with hierarchy conversions (although this is not part of our motivating use case). Doing this in the constant-evaluator would probably have been better, but that would require a *lot* of extra structure in the representation of constant member pointers: you'd really have to track an arbitrary chain of hierarchy conversions and reinterpretations in order to get this right. Ultimately, this seems less complex. I also wasn't quite sure how to extend the constant evaluator to handle foldings that we don't actually want to treat as extended constant expressions. llvm-svn: 150551
* Implement indexing support for lambdas in libclang (both kinds), asDouglas Gregor2012-02-151-0/+33
| | | | | | | well as improving the RecursiveASTVisitor's walk of lambda expressions. llvm-svn: 150549
* [analyzer] Malloc Checker: Add another false positive as a todo test.Anna Zaks2012-02-151-0/+14
| | | | llvm-svn: 150534
* [analyzer] Malloc Checker: add support for reallocf, which always freesAnna Zaks2012-02-151-0/+34
| | | | | | the passed in pointer on failure. llvm-svn: 150533
* [analyzer] Malloc Checker: add support for valloc + minor codeAnna Zaks2012-02-151-0/+13
| | | | | | hardening. llvm-svn: 150532
* Advertize support for constexpr.Richard Smith2012-02-141-0/+9
| | | | llvm-svn: 150524
* constexpr: evaluation support for nullptr comparisons.Richard Smith2012-02-141-3/+14
| | | | llvm-svn: 150521
* Implement C++ core issue 974, which permits default arguments forDouglas Gregor2012-02-142-2/+53
| | | | | | | | lambda expressions. Because these issue was pulled back from Ready status at the Kona meeting, we still emit an ExtWarn when using default arguments for lambda expressions. llvm-svn: 150519
* If a constexpr function template specialization is referenced, and then theRichard Smith2012-02-141-0/+59
| | | | | | | | template is defined, and then the specialization is referenced again, don't forget to instantiate the template on the second reference. Use the source location of the first reference as the point of instantiation, though. llvm-svn: 150518
* [libclang] Indexing: only index implicit template instantiations via an ↵Argyrios Kyrtzidis2012-02-141-3/+8
| | | | | | opt-in indexing option. llvm-svn: 150517
* Generalize -Wempty-body: warn when statement body is empty (closes: PR11329)Dmitri Gribenko2012-02-149-45/+284
| | | | | | | | | | | | | | * if, switch, range-based for: warn if semicolon is on the same line. * for, while: warn if semicolon is on the same line and either next statement is compound statement or next statement has more indentation. Replacing the semicolon with {} or moving the semicolon to the next line will always silence the warning. Tests from SemaCXX/if-empty-body.cpp merged into SemaCXX/warn-empty-body.cpp. llvm-svn: 150515
* Pending clear answer from WG21 on whether core issue 903 is intended to apply toRichard Smith2012-02-141-0/+11
| | | | | | | C++11 or just C++17, restrict the set of null pointer constants in C++11 mode back to those which were considered null in C++98. llvm-svn: 150510
* Check the return type of lambda expressions.Douglas Gregor2012-02-142-0/+16
| | | | llvm-svn: 150503
* PR11650: Implement resolution of core issue 1301. Value initialization can't beRichard Smith2012-02-142-0/+76
| | | | | | | used to construct an object of union type with a deleted default constructor (plus fixes for some related value-initialization corner cases). llvm-svn: 150502
* Warn about non-int main() results in GNU C mode instead of erroring.John McCall2012-02-142-0/+4
| | | | | | Based on a patch by Vasiliy Korchagin! llvm-svn: 150500
* Implement support for lambda capture pack expansions, e.g.,Douglas Gregor2012-02-141-0/+58
| | | | | | [&values...] { print(values...); } llvm-svn: 150497
* Use several weighted factors to determine typo candidate viablity.Kaelyn Uhrain2012-02-141-0/+21
| | | | | | | | | | | Replace the simple Levenshtein edit distance for typo correction candidates--and the hacky way adding namespace qualifiers would affect the edit distance--with a synthetic "edit distance" comprised of several factors and their relative weights. This also allows the typo correction callback object to convey more information about the viability of a correction candidate than simply viable or not viable. llvm-svn: 150495
* Simplify and robustify lambda PCH testDouglas Gregor2012-02-141-3/+1
| | | | llvm-svn: 150493
* Implement AST (de-)serialization for lambda expressions.Douglas Gregor2012-02-141-0/+43
| | | | llvm-svn: 150491
* Fix crash-on-invalid for 'operator int[]()' in C++11.David Blaikie2012-02-141-0/+3
| | | | | | Signed off by Richard Smith. llvm-svn: 150464
* Add a coverage test for lambda expression IRGen.Eli Friedman2012-02-141-0/+54
| | | | llvm-svn: 150458
* Fix another issue introduced by the proposed wording for core issue 1358: sinceRichard Smith2012-02-141-1/+9
| | | | | | | | | | the instantiation of a constexpr function temploid is now always constexpr, a defaulted constexpr function temploid is often ill-formed by the rule in [dcl.fct.def.default]p2 that an explicitly-defaulted constexpr function must have a constexpr implicit definition. To avoid making loads of completely reasonable code ill-formed, do not apply that rule to templates. llvm-svn: 150453
* [analyzer] Malloc Checker: realloc: add dependency between the symbolsAnna Zaks2012-02-141-0/+41
| | | | | | | | | | | | | in realloc map. If there is no dependency, the reallocated ptr will get garbage collected before we know that realloc failed, which would lead us to missing a memory leak warning. Also added new test cases, which we can handle now. Plus minor cleanups. llvm-svn: 150446
* Simple test ensuring that we perform direct initialization when ↵Douglas Gregor2012-02-141-0/+9
| | | | | | copy-capturing in lambdas llvm-svn: 150442
* Link together the call operator produced from transforming a lambdaDouglas Gregor2012-02-141-0/+71
| | | | | | | | expression with the original call operator, so that we don't try to separately instantiate the call operator. Test and tweak a few more bits for template instantiation of lambda expressions. llvm-svn: 150440
* Deal with a horrible C++11 special case. If a non-literal type has a constexprRichard Smith2012-02-132-3/+87
| | | | | | | | | | | constructor, and that constructor is used to initialize an object of static storage duration such that all members and bases are initialized by constant expressions, constant initialization is performed. In this case, the object can still have a non-trivial destructor, and if it does, we must emit a dynamic initializer which performs no initialization and instead simply registers that destructor. llvm-svn: 150419
* Introduce support for template instantiation of lambdaDouglas Gregor2012-02-131-0/+45
| | | | | | | | | | | | | | | | | | expressions. This is mostly a simple refact, splitting the main "start a lambda expression" function into smaller chunks that are driven either from the parser (Sema::ActOnLambdaExpr) or during AST transformation (TreeTransform::TransformLambdaExpr). A few minor interesting points: - Added new entry points for TreeTransform, so that we can explicitly establish the link between the lambda closure type in the template and the lambda closure type in the instantiation. - Added a bit into LambdaExpr specifying whether it had an explicit result type or not. We should have had this anyway. This code is 'lightly' tested. llvm-svn: 150417
* [analyzer] Malloc Checker: realloc: correct the way we are handing theAnna Zaks2012-02-131-0/+51
| | | | | | case when size is 0. llvm-svn: 150412
* Remove unused diagnostics from include/clang/Basic/Diagnostic*.td files.Dmitri Gribenko2012-02-131-9/+1
| | | | llvm-svn: 150409
* Don't route explicit construction via list-initialization through the ↵Sebastian Redl2012-02-132-5/+23
| | | | | | functional cast code path. It sometimes does the wrong thing, produces horrible error messages, and is just unnecessary. llvm-svn: 150408
* [analyzer] Malloc checker: rework realloc handling:Anna Zaks2012-02-131-11/+26
| | | | | | | | | | | | | | | | | | | 1) Support the case when realloc fails to reduce False Positives. (We essentially need to restore the state of the pointer being reallocated.) 2) Realloc behaves differently under special conditions (from pointer is null, size is 0). When detecting these cases, we should consider under-constrained states (size might or might not be 0). The old version handled this in a very hacky way. The code did not differentiate between definite and possible (no consideration for under-constrained states). Further, after processing each special case, the realloc processing function did not return but chained to the next special case processing. So you could end up in an execution in which you first see the states in which size is 0 and realloc ~ free(), followed by the states corresponding to size is not 0 followed by the evaluation of the regular realloc behavior. llvm-svn: 150402
* Testcase for previous commit.Eric Christopher2012-02-131-0/+13
| | | | | | PR11970. llvm-svn: 150389
* Temporarily walk back a few of my recent debug info limiting changesEric Christopher2012-02-132-0/+2
| | | | | | | | while reworking how we handle wanting to emit only parts of structures. Fixes PR11970. llvm-svn: 150388
* Fix typo in PrintfConversionSpecifier::isDoubleArg()Hans Wennborg2012-02-131-0/+2
| | | | | | | This makes the printf diagnostics issue warnigns for %a, %A, %e, etc. when used with the wrong argument. llvm-svn: 150370
* Update constexpr implementation to match CWG's chosen approach for core issuesRichard Smith2012-02-1311-101/+104
| | | | | | | | | | | | | | | | | | | | 1358, 1360, 1452 and 1453. - Instantiations of constexpr functions are always constexpr. This removes the need for separate declaration/definition checking, which is now gone. - This makes it possible for a constexpr function to be virtual, if they are only dependently virtual. Virtual calls to such functions are not constant expressions. - Likewise, it's now possible for a literal type to have virtual base classes. A constexpr constructor for such a type cannot actually produce a constant expression, though, so add a special-case diagnostic for a constructor call to such a type rather than trying to evaluate it. - Classes with trivial default constructors (for which value initialization can produce a fully-initialized value) are considered literal types. - Classes with volatile members are not literal types. - constexpr constructors can be members of non-literal types. We do not yet use static initialization for global objects constructed in this way. llvm-svn: 150359
* Implement the standard decltype() semantics described in C++11Douglas Gregor2012-02-121-0/+6
| | | | | | | | [dcl.type.simple]p4, which treats all xvalues as returning T&&. We had previously implemented a pre-standard variant of decltype() that doesn't cope with, e.g., static_ast<T&&>(e) very well. llvm-svn: 150348
* Within the body of a lambda expression, decltype((x)) for anDouglas Gregor2012-02-123-3/+45
| | | | | | | | | | | | | | | | id-expression 'x' will compute the type based on the assumption that 'x' will be captured, even if it isn't captured, per C++11 [expr.prim.lambda]p18. There are two related refactors that go into implementing this: 1) Split out the check that determines whether we should capture a particular variable reference, along with the computation of the type of the field, from the actual act of capturing the variable. 2) Always compute the result of decltype() within Sema, rather than AST, because the decltype() computation is now context-sensitive. llvm-svn: 150347
* Proper initializer list support for new expressions and type construct ↵Sebastian Redl2012-02-124-2/+17
| | | | | | expressions. Array new still missing. llvm-svn: 150346
* Lambdas have a deleted default constructor and a deleted copyDouglas Gregor2012-02-124-0/+46
| | | | | | assignment operator, per C++ [expr.prim.lambda]p19. Make it so. llvm-svn: 150345
* Change the way we store initialization kinds so that all direct inits can ↵Sebastian Redl2012-02-124-52/+12
| | | | | | distinguish between list and parens form. This allows us to correctly diagnose the last test cases from litb. llvm-svn: 150343
* Employ DirectList initialized entities to properly sort through some ↵Sebastian Redl2012-02-122-23/+29
| | | | | | initialization edge cases. llvm-svn: 150342
* Fix the rewriter that broke with r149987.Argyrios Kyrtzidis2012-02-121-0/+29
| | | | | | | | | | | | | r149987 changed the way parsing happens inside an @implementation; it aggregates the declarations inside and reports them together as a DeclGroup. This had the side effect that function declarations were reported together with their definition, while the rewriter expected for function declarations to be reported immediately to the consumer and thus not have a body. Fix this by having the rewriter actually check with isThisDeclarationADefinition() to make sure the body comes from the current decl before rewriting it. llvm-svn: 150325
* Represent C++ direct initializers as ParenListExprs before semantic analysisSebastian Redl2012-02-113-18/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | instead of having a special-purpose function. - ActOnCXXDirectInitializer, which was mostly duplication of AddInitializerToDecl (leading e.g. to PR10620, which Eli fixed a few days ago), is dropped completely. - MultiInitializer, which was an ugly hack I added, is dropped again. - We now have the infrastructure in place to distinguish between int x = {1}; int x({1}); int x{1}; -- VarDecl now has getInitStyle(), which indicates which of the above was used. -- CXXConstructExpr now has a flag to indicate that it represents list- initialization, although this is not yet used. - InstantiateInitializer was renamed to SubstInitializer and simplified. - ActOnParenOrParenListExpr has been replaced by ActOnParenListExpr, which always produces a ParenListExpr. Placed that so far failed to convert that back to a ParenExpr containing comma operators have been fixed. I'm pretty sure I could have made a crashing test case before this. The end result is a (I hope) considerably cleaner design of initializers. More importantly, the fact that I can now distinguish between the various initialization kinds means that I can get the tricky generalized initializer test cases Johannes Schaub supplied to work. (This is not yet done.) This commit passed self-host, with the resulting compiler passing the tests. I hope it doesn't break more complicated code. It's a pretty big change, but one that I feel is necessary. llvm-svn: 150318
* Drive-by fix of incorrect diagnostic, and a test case for said diagnostic. ↵Sebastian Redl2012-02-111-2/+6
| | | | | | The double error is unfortunate, but I really don't see an alternative whose effort is worth it. llvm-svn: 150317
OpenPOWER on IntegriCloud