summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* ObjectiveC arc: Introduce a new initialization kindFariborz Jahanian2013-07-311-0/+6
| | | | | | | | for parameters passed to CF audited functions to be used for better diagnostics. Current set but unused. // rdar://14569171 llvm-svn: 187508
* ObjectiveC arc: Move check for type conversions in arcFariborz Jahanian2013-07-311-7/+19
| | | | | | | | out of ImpCastExprToType and to the caller site as appropriate. This is in prep. to do more work for // rdar://14569171 llvm-svn: 187503
* Fix a crasher than manifests when typo correction suggests a function template.Richard Trieu2013-07-311-2/+2
| | | | llvm-svn: 187467
* Partially revert r186903.Eli Friedman2013-07-261-1/+1
| | | | | | | | It turns out that Plum Hall depends on us not emitting an error on integer literals which fit into long long, but fit into unsigned long long. So C99 conformance requires not conforming to C99. :) llvm-svn: 187172
* Integers which are too large should be an error.Eli Friedman2013-07-231-4/+4
| | | | | | | | Switch some warnings over to errors which should never have been warnings in the first place. (Also, a minor fix to the preprocessor rules for integer literals while I'm here.) llvm-svn: 186903
* Don't emit open-paren fixit without close-paren.Eli Friedman2013-07-221-0/+4
| | | | | | | | | | getLocForEndOfToken() isn't guaranteed to succeed; if it doesn't, make sure we do something sane. Fixes PR16673. I'm not sure how to write a testcase for this short of grepping through the diagnostic output. llvm-svn: 186889
* Make IgnoreParens() look through ChooseExprs.Eli Friedman2013-07-201-2/+4
| | | | | | | | | | | | | This is the same way GenericSelectionExpr works, and it's generally a more consistent approach. A large part of this patch is devoted to caching the value of the condition of a ChooseExpr; it's needed to avoid threading an ASTContext into IgnoreParens(). Fixes <rdar://problem/14438917>. llvm-svn: 186738
* Clean up diagnostics for inheriting constructors.Eli Friedman2013-07-181-3/+20
| | | | | | | No new diagnostics, just better wording and notes pointing at more relevant locations. llvm-svn: 186629
* Improve idiomatic-parentheses by checking method family instead of relying ↵Jean-Daniel Dupas2013-07-171-1/+1
| | | | | | on the selector name. llvm-svn: 186524
* Make Expr::isConstantInitializer match IRGen.Eli Friedman2013-07-161-1/+1
| | | | | | | | | | Sema needs to be able to accurately determine what will be emitted as a constant initializer and what will not, so we get accurate errors in C and accurate -Wglobal-constructors warnings in C++. This makes Expr::isConstantInitializer match CGExprConstant as closely as possible. llvm-svn: 186464
* Make CheckAddressOfOperand a member of Sema so it can be reused byRichard Smith2013-07-111-35/+34
| | | | | | __builtin_addressof. llvm-svn: 186052
* Attempt typo correction for function calls with the wrong number of arguments.Kaelyn Uhrain2013-07-081-4/+98
| | | | | | | | | | | | | | | Combined with typo correction's new ability to apply global/absolute nested name specifiers to possible corrections, cases such as in PR12287 where the desired function is being shadowed by a lexically closer function with the same name but a different number of parameters will now include a FixIt. On a side note, since the test for this change caused test/SemaCXX/typo-correction.cpp to exceed the typo correction limit for a single file, I've included a test case for exceeding the limit and added some comments to both the original and part two of typo-correction.cpp warning future editors of the files about the limit. llvm-svn: 185881
* Fix Sema for compares with _Atomic vars.Eli Friedman2013-07-081-25/+6
| | | | | | | | | | | | | | | | Use UsualArithmeticConversions unconditionally in analysis of comparisons and conditional operators: the method performs the usual arithmetic conversions if both sides are arithmetic, and usual unary conversions if they are not. This is just a cleanup for conditional operators; for comparisons, it fixes the issue that we would try to check isArithmetic() on an atomic type. Also, fix GetExprRange() in SemaChecking.cpp so it deals with variables of atomic type correctly. Fixes PR15537. llvm-svn: 185857
* Use SmallVectorImpl& for function arguments instead of SmallVector.Craig Topper2013-07-051-1/+1
| | | | llvm-svn: 185715
* Sema: Call IgnoreParens fewer times in CheckAddressOfOperandDavid Majnemer2013-07-051-4/+4
| | | | llvm-svn: 185684
* Add typedefs for Densemaps containing SmallVectors to avoid repeating the ↵Craig Topper2013-07-051-1/+1
| | | | | | SmallVector size when creating iterators for the DenseMap. llvm-svn: 185682
* Use SmallVectorImpl instead of SmallVector for iterators and references to ↵Craig Topper2013-07-041-1/+1
| | | | | | avoid specifying the vector size unnecessarily. llvm-svn: 185610
* Improve -Wlogical-not-parentheses to catch when the not is applied to an enum.Richard Trieu2013-07-041-1/+1
| | | | llvm-svn: 185602
* Allow typo correction to try removing nested name specifiers.Kaelyn Uhrain2013-07-021-6/+8
| | | | | | | | | | | | | | | | | The removal is tried by retrying the failed lookup of a correction candidate with either the MemberContext or SS (CXXScopeSpecifier) or both set to NULL if they weren't already. If the candidate identifier is then looked up successfully, make a note in the candidate that the SourceRange should include any existing nested name specifier even if the candidate isn't adding a different one (i.e. the candidate has a NULL NestedNameSpecifier). Also tweak the diagnostic messages to differentiate between a suggestion that just replaces the identifer but leaves the existing nested name specifier intact and one that replaces the entire qualified identifier, in cases where the suggested replacement is unqualified. llvm-svn: 185487
* Fix mangling for block literals.Eli Friedman2013-07-011-7/+14
| | | | | | | | | | | | | | | Blocks, like lambdas, can be written in contexts which are required to be treated as the same under ODR. Unlike lambdas, it isn't possible to actually take the address of a block, so the mangling of the block itself doesn't matter. However, objects like static variables inside a block do need to be mangled in a consistent way. There are basically three components here. One, block literals need a consistent numbering. Two, objects/types inside a block literal need to be mangled using it. Three, objects/types inside a block literal need to have their linkage computed correctly. llvm-svn: 185372
* Ensure that debugger calls to signature-less functions default toJohn McCall2013-06-271-3/+42
| | | | | | | | | | | | | | | | | | | | | passing arguments in the fixed style. We have an abstraction for deciding this, but it's (1) deep in IR-generation, (2) necessarily tied to exact argument lists, and (3) triggered by unprototyped function types, which we can't legitimately make in C++ mode. So this solution, wherein Sema rewrites the function type to an exact prototype but leaves the variadic bit enabled so as to request x86-64-like platforms to pass the extra variadic info, is very much a hack, but it's one that works in practice on the platforms that LLDB will support in the medium term --- the only place we know of where it's a problem is instance methods in Windows, where variadic functions are implicitly cdecl. We may have a more abstracted base on which to build a solution by then. rdar://13731520 llvm-svn: 185112
* Delete dead code.Eli Friedman2013-06-271-26/+1
| | | | llvm-svn: 185053
* Don't use unnamed local enums as template arguments.Joerg Sonnenberger2013-06-261-4/+4
| | | | | | Fixes -Werror bootstrap. llvm-svn: 185023
* Fix PCH bug with member templates of local classes in nontemplate functions. Faisal Vali2013-06-261-1/+2
| | | | | | | | | | | | | | | | | | | | | | | | As noted by Richard in the post: http://lists.cs.uiuc.edu/pipermail/cfe-commits/Week-of-Mon-20130624/082605.html, the following code should not add an entry into PendingLocalImplicitInstantiations, since local instantiations should only occur within the context of other instantiations: int foo(double y) { struct Lambda { template<class T> T operator()(T t) const { return t; }; } lambda; return lambda(y); } Hence the attached code does the following: 1) In MarkFunctionReferenced, check if ActiveInstantiations.size() is non-zero before adding to PendingLocalImplicitInstantiations. 2) In InstantiateFunctionDefinition, we swap out/in PendingLocalImplicitInstantiations so that only those pending local instantiations that are added during the instantiation of the current function are instantiated recursively. llvm-svn: 184903
* Tweak -Wdeprecated-objc-pointer-introspection to have a subgroup for results ↵Ted Kremenek2013-06-241-1/+14
| | | | | | | | | | | | | of using -performSelectorXXX. -performSelector: and friends return a value that is boxed as an Objective-C pointer. Sometimes it is an Objective-C pointer, sometimes it isn't. Some clients may wish to silence this warning based on calling this method. Fixes <rdar://problem/14147304> llvm-svn: 184789
* [AST] Introduce a new DecayedType sugar nodeReid Kleckner2013-06-241-0/+2
| | | | | | | | | | | | | | The goal of this sugar node is to be able to look at an arbitrary FunctionType and tell if any of the parameters were decayed from an array or function type. Ultimately this is necessary to implement Microsoft's C++ name mangling scheme, which mangles decayed arrays differently from normal pointers. Reviewers: rsmith Differential Revision: http://llvm-reviews.chandlerc.com/D1014 llvm-svn: 184763
* Extend -Wnon-pod-varargs to check calls made from member pointers.Richard Trieu2013-06-221-1/+2
| | | | llvm-svn: 184629
* Extend -Wnon-pod-varargs to more cases, such as function pointers as returnRichard Trieu2013-06-221-0/+3
| | | | | | types and function pointer arrays. llvm-svn: 184616
* Extend -Wnon-pod-varargs to check calls made from function pointers.Richard Trieu2013-06-201-1/+1
| | | | llvm-svn: 184470
* [Windows] Fix __declspec(property) when the getter returns a refReid Kleckner2013-06-191-1/+2
| | | | | | | | This fixes an issue when parsing atlbase.h. Patch by Will Wilson! llvm-svn: 184319
* Unify return type checking for functions and ObjC methods. Move all theEli Friedman2013-06-141-7/+0
| | | | | | | | random checks for ObjC object return types to SemaType.cpp. Fixes issue with ObjC method type checking reported on cfe-dev. llvm-svn: 184006
* Fix the warning for divide by zero to be a bit more robust. ;]Chandler Carruth2013-06-141-9/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, it only ever fired for zeros which formed null pointers. Now, hilariously, in C++98 this was almost anything. Including tricks like warning on the divisor in this code: typedef char c3[3]; size_t f(c3* ptr) { return (sizeof(ptr) / sizeof(*ptr)) / (size_t)(!(sizeof(ptr) % sizeof(*ptr))); } Why the RHS of the outer divide is a null pointer constant is a sordid tale of sorrow. Anyways, the committee fixed this for C++11 and onward as part of core isssue 903, and Richard recently implemented this fix causing the warning to go away here (and elsewhere). This patch restores the warning here and adds it for numerous other somewhat obvious gaffes: int g(int x) { return x / (int)(0.0); } The patch is essentially just using the full power of our constant folding in Clang to produce the warning, but insisting that it must fold to an *integer* which is zero so that we don't get false positives anywhere. llvm-svn: 183970
* Implement DR61: Address of ambiguous bound methods should be disallowedDavid Majnemer2013-06-111-1/+9
| | | | | | | DR61 affirms that expressions containing unresolved member access should be disallowed when performing "address of" operations. llvm-svn: 183723
* Objective-C [qoi]: Issue better warning when nsstring literal is missingFariborz Jahanian2013-06-101-2/+7
| | | | | | the '@'. PR16287 and // rdar://14106083 llvm-svn: 183713
* Use FPT::getArgTypes() instead of manually building ArrayRefsReid Kleckner2013-06-101-10/+3
| | | | | | | | Made significantly easier with git-clang-format. Differential Revision: http://llvm-reviews.chandlerc.com/D947 llvm-svn: 183694
* Add a new warning, -Wlogical-not-parentheses, to -Wparentheses.Richard Trieu2013-06-101-0/+40
| | | | | | | | | | | | | | | | | | This warning triggers on the logical not of a non-boolean expression on the left hand side of comparison. Often, the user meant to negate the comparison, not just the left hand side of the comparison. Two notes are also emitted, the first with a fix-it to add parentheses around the comparison, and the other to put parenthesis around the not expression to silence the warning. bool not_equal(int x, int y) { return !x == y; // warn here } return !(x == y); // first fix-it, to negate comparison. return (!x) == y; // second fix-it, to silence warning. llvm-svn: 183688
* Added a type checking which handle the case of an ext vector and integral scalarJin-Gu Kang2013-06-081-6/+13
| | | | llvm-svn: 183602
* fix up recogtion of block pointer type in my last patch.Fariborz Jahanian2013-06-071-1/+3
| | | | | | | | | // rdar://14085217. e-This line, and those below, will be ignored-- M lib/Sema/SemaExpr.cpp llvm-svn: 183531
* blocks: fixes an ast bug when block pointer variableFariborz Jahanian2013-06-071-1/+4
| | | | | | | | | | is evaluated in a condition expression and then dereferenced to envoke the block. This is pr15663 and I applied a slight variation of the patch with a test case. (patch is from Arthur O'Dwyer). Also // rdar://14085217 llvm-svn: 183471
* Model temporary lifetime-extension explicitly in the AST. Use this model toRichard Smith2013-06-051-1/+1
| | | | | | | | | handle temporaries which have been lifetime-extended to static storage duration within constant expressions. This correctly handles nested lifetime extension (through reference members of aggregates in aggregate initializers) but non-constant-expression emission hasn't yet been updated to do the same. llvm-svn: 183283
* [ms-inline asm] Don't diagnose an empty lookup for inline assmebly. This happenChad Rosier2013-05-241-1/+6
| | | | | | | | | | | | | for labels in inline assembly that aren't in the lookup tables. E.g., __asm { a: jmp a } rdar://13983623 llvm-svn: 182659
* Objective-C arc: don't count use of __weakFariborz Jahanian2013-05-211-2/+2
| | | | | | | variables when they are used in such unevaluated contexts as __typeof, etc. // rdar://13942025 llvm-svn: 182423
* Refactor places which perform contextual implicit conversions to go through aRichard Smith2013-05-211-105/+45
| | | | | | | | | | | | | common function. The C++1y contextual implicit conversion rules themselves are not yet implemented, however. This also fixes a subtle bug where template instantiation context notes were dropped for diagnostics coming from conversions for integral constant expressions -- we were implicitly slicing a SemaDiagnosticBuilder into a DiagnosticBuilder when producing these diagnostics, and losing their context notes in the process. llvm-svn: 182406
* Objective-C++ (and c++) Sema: Patch fixes a sema crash when gnu’s ?: ↵Fariborz Jahanian2013-05-171-1/+8
| | | | | | | | | | | extension is used for Objective-C++’s dictionary subscripting. This is done by filtering out all placeholder types before check on lowering of the common expression is done. // rdar://1374918. Reviewed by John McCall. llvm-svn: 182120
* First pass of semantic analysis for init-captures: check the initializer, buildRichard Smith2013-05-161-4/+5
| | | | | | | | | | | | | a FieldDecl from it, and propagate both into the closure type and the LambdaExpr. You can't do much useful with them yet -- you can't use them within the body of the lambda, because we don't have a representation for "the this of the lambda, not the this of the enclosing context". We also don't have support or a representation for a nested capture of an init-capture yet, which was intended to work despite not being allowed by the current standard wording. llvm-svn: 181985
* Use only explicit bool conversion operatorDavid Blaikie2013-05-151-1/+1
| | | | | | | | | | | | | | | | | | | The most common (non-buggy) case are where such objects are used as return expressions in bool-returning functions or as boolean function arguments. In those cases I've used (& added if necessary) a named function to provide the equivalent (or sometimes negative, depending on convenient wording) test. DiagnosticBuilder kept its implicit conversion operator owing to the prevalent use of it in return statements. One bug was found in ExprConstant.cpp involving a comparison of two PointerUnions (PointerUnion did not previously have an operator==, so instead both operands were converted to bool & then compared). A test is included in test/SemaCXX/constant-expression-cxx1y.cpp for the fix (adding operator== to PointerUnion in LLVM). llvm-svn: 181869
* Cleanup handling of UniqueExternalLinkage.Rafael Espindola2013-05-131-4/+4
| | | | | | | | | | | | | This patch renames getLinkage to getLinkageInternal. Only code that needs to handle UniqueExternalLinkage specially should call this. Linkage, as defined in the c++ standard, is provided by getFormalLinkage. It maps UniqueExternalLinkage to ExternalLinkage. Most places in the compiler actually want isExternallyVisible, which handles UniqueExternalLinkage as internal. llvm-svn: 181677
* ArrayRef'ize GenericSelectionExprDmitri Gribenko2013-05-101-16/+13
| | | | llvm-svn: 181592
* Add support for __wchar_t in -fms-extensions mode.Hans Wennborg2013-05-101-3/+3
| | | | | | | | | | | | | | | | | MSVC provides __wchar_t. This is the same as the built-in wchar_t type from C++, but it is also available with -fno-wchar and in C. The commit changes ASTContext to have two different types for this: - WCharTy is the built-in type used for wchar_t in C++ and __wchar_t. - WideCharTy is the type of a wide character literal. In C++ this is the same as WCharTy, and in C it is an integer type compatible with the type in <stddef.h>. This fixes PR15815. llvm-svn: 181587
* ArrayRef'ize Sema::BuildCallToObjectOfClassTypeDmitri Gribenko2013-05-091-2/+1
| | | | llvm-svn: 181562
OpenPOWER on IntegriCloud