summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Add a new warning, -Wself-move, to Clang.Richard Trieu2015-01-101-1/+87
| | | | | | | | -Wself-move is similiar to -Wself-assign. This warning is triggered when a value is attempted to be moved to itself. See r221008 for a bug that would have been caught with this warning. llvm-svn: 225581
* Parse: Don't crash when namespace is in GNU statement exprDavid Majnemer2015-01-091-5/+0
| | | | | | | | | | | Parser::ParseNamespace can get a little confused when it found itself inside a compound statement inside of a non-static data member initializer. Try to determine that the statement expression's scope makes sense before trying to parse it's contents. llvm-svn: 225514
* WIPDavid Majnemer2014-12-261-16/+16
| | | | llvm-svn: 224843
* Adding a -Wunused-value warning for expressions with side effects used in an ↵Aaron Ballman2014-12-171-0/+13
| | | | | | unevaluated expression context, such as sizeof(), or decltype(). Also adds a similar warning when the expression passed to typeid() *is* evaluated, since it is equally likely that the user would expect the expression operand to be unevaluated in that case. llvm-svn: 224465
* Consider calls from implict host device functions as valid in SemaCUDA.Jacques Pienaar2014-12-161-4/+3
| | | | | | | | | | | | | | | | | | | | | | | | | | | In SemaCUDA all implicit functions were considered host device, this led to errors such as the following code snippet failing to compile: struct Copyable { const Copyable& operator=(const Copyable& x) { return *this; } }; struct Simple { Copyable b; }; void foo() { Simple a, b; a = b; } Above the implicit copy assignment operator was inferred as host device but there was only a host assignment copy defined which is an error in device compilation mode. Differential Revision: http://reviews.llvm.org/D6565 llvm-svn: 224358
* Renamed RefersToEnclosingLocal bitfield to RefersToCapturedVariable.Alexey Bataev2014-12-161-15/+15
| | | | | | | Bitfield RefersToEnclosingLocal of Stmt::DeclRefExprBitfields renamed to RefersToCapturedVariable to reflect latest changes introduced in commit 224323. Also renamed method Expr::refersToEnclosingLocal() to Expr::refersToCapturedVariable() and comments for constant arguments. No functional changes. llvm-svn: 224329
* [OPENMP] Bugfix for processing of global variables in OpenMP regions.Alexey Bataev2014-12-161-10/+30
| | | | | | | | Currently, if global variable is marked as a private OpenMP variable, the compiler crashes in debug version or generates incorrect code in release version. It happens because in the OpenMP region the original global variable is used instead of the generated private copy. It happens because currently globals variables are not captured in the OpenMP region. This patch adds capturing of global variables iff private copy of the global variable must be used in the OpenMP region. Differential Revision: http://reviews.llvm.org/D6259 llvm-svn: 224323
* Sema: Cleanup and improve string-plus-char checking.Daniel Marjamaki2014-12-151-4/+4
| | | | | | Patch by Anders Rönnholm llvm-svn: 224268
* Sema: Don't diagnose string + int if the int is value dependentDavid Majnemer2014-12-151-1/+1
| | | | | | | | | | | Don't send a value dependent expression into the expression evaluator, HandleSizeof would crash. Making HandleSizeof handle dependent types would noisily warn about the operation even if everything turns out OK after instantiation. This fixes PR21848. llvm-svn: 224240
* When checking for nonnull parameter attributes, also check the ParmVarDecl ↵Aaron Ballman2014-12-111-1/+1
| | | | | | since the attribute may reside there, instead of just on the FunctionDecl. Fixes PR21668. llvm-svn: 224039
* [OpenCL] Implemented restrictions for pointer conversions specified in ↵Anastasia Stulova2014-11-261-2/+24
| | | | | | | | | | | | OpenCL v2.0. OpenCL v2.0 s6.5.5 restricts conversion of pointers to different address spaces: - the named address spaces (__global, __local, and __private) => __generic - implicitly converted; - __generic => named - with an explicit cast; - named <=> named - disallowed; - __constant <=> any other - disallowed. llvm-svn: 222834
* Ensure that any TypoExprs in the arguments to bultins with custom typeKaelyn Takata2014-11-251-2/+6
| | | | | | | | checking are handled before the custom type checking is performed. Fixes PR21669. llvm-svn: 222797
* Force the correction of delayed typos in casts in non-C++ code.Kaelyn Takata2014-11-241-0/+6
| | | | | | | Fixes PR21656, which is fallout from r222551 caused by an untested/missed code path. llvm-svn: 222694
* Enable ActOnIdExpression to use delayed typo correction for non-C++ codeKaelyn Takata2014-11-211-14/+33
| | | | | | when calling DiagnoseEmptyLookup. llvm-svn: 222551
* Wire up delayed typo correction to DiagnoseEmptyLookup and set upKaelyn Takata2014-11-201-8/+88
| | | | | | | | | Sema::ActOnIdExpression to use the new functionality. Among other things, this allows recovery in several cases where it wasn't possible before (e.g. correcting a mistyped static_cast<>). llvm-svn: 222464
* Add a flag to BuildDeclarationNameExpr to not reject invalid decls.Kaelyn Takata2014-11-201-7/+8
| | | | llvm-svn: 222463
* [Sema] Patch to issue warning on comparing parameters withFariborz Jahanian2014-11-181-0/+20
| | | | | | | | | | | nonnull attribute when comparison is always true/false. Original patch by Steven Wu. I have added extra code to prevent issuing of warning when the nonnull parameter is modified prior to the comparison. This addition prevents false positives in the most obvious cases. There may still be false positive warnings in some cases (as one of my tests indicates), but benefit far outweighs such cases. rdar://18712242 llvm-svn: 222264
* Recommit r222044 with a test fix - it does not make sense to huntAnton Korobeynikov2014-11-141-3/+7
| | | | | | for a typedef before arithmetic conversion in all rare corner cases. llvm-svn: 222049
* Again revert r222044 to resolve darwin objc test fails.Anton Korobeynikov2014-11-141-7/+3
| | | | llvm-svn: 222047
* Follow-up to D6217Anton Korobeynikov2014-11-141-3/+7
| | | | | | | | | | | | | | | | | Summary: Ok, here is somewhat addition to D6217 aiming to preserve old darwin behavior wrt the typedefed types. The actual change to SemaChecking turned out to be pretty gross, in particular: 1. We need to extract the typedef'ed type for proper diagnostics 2. We need to walk over paren expressions as well Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6256 llvm-svn: 222044
* [Sema]. Warn when logical expression is a pointerFariborz Jahanian2014-11-141-0/+1
| | | | | | | which evaluates to true. rdar://18716393. Reviewed by Richard Trieu llvm-svn: 222009
* -Wsentinel: Suggest nullptr in C++11 instead of NULLReid Kleckner2014-11-131-2/+4
| | | | llvm-svn: 221945
* Temporary revert r221818 until all the problemsAnton Korobeynikov2014-11-121-7/+3
| | | | | | with objc stuff will be resolved. llvm-svn: 221829
* Fix fallout from r219557Anton Korobeynikov2014-11-121-3/+7
| | | | | | | | | | | | | | | | | Summary: Consider the following nifty 1 liner: (0 ? csqrtl(2.0f) : sqrtl(2.0f)). One can easily obtain such code from e.g. tgmath. Right now it produces an assertion because we fail to do the promotion real => _Complex real. The case was properly handled previously (old handleOtherComplexFloatConversion routine), but was forgotten in the current version. This seems to be about fallout from r219557 Reviewers: chandlerc, rsmith Reviewed By: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D6217 llvm-svn: 221821
* Have LookupMemberExprInRecord only call CorrectTypoDelayed, dropping theKaelyn Takata2014-11-111-0/+11
| | | | | | | | | code for calling CorrectTypo. Includes a needed fix for non-C++ code to not choke on TypoExprs (which also resolves a TODO from r220698). llvm-svn: 221736
* Revert r221702 until I address Richard Trieu'sFariborz Jahanian2014-11-111-5/+1
| | | | | | comments. llvm-svn: 221714
* Patch to warn when logical evaluation of operand evalutes to a true value;Fariborz Jahanian2014-11-111-1/+5
| | | | | | | That this is a c-only patch. c++ already has this warning. This addresses rdar://18716393 llvm-svn: 221702
* This patch fixes a crash after rebuilding call AST ofFariborz Jahanian2014-11-111-0/+33
| | | | | | | | | | | | | an __unknown_anytype(...). In this case, we rebuild the vararg function type specially to convert the call expression to something that IRGen can handle. However, FunctionDecl as rebuilt in RebuildUnknownAnyExpr::resolveDecl is bogus and results in crash when accessing its params later on. This patch fixes the crash by rebuilding the FunctionDecl to match its new resolved type. rdar://15297105. (patch reapplied after lldb issue was fixed in r221660). llvm-svn: 221691
* [c++1z] N4295: fold-expressions.Richard Smith2014-11-081-2/+1
| | | | | | | | | | | | | | | | This is a new form of expression of the form: (expr op ... op expr) where one of the exprs is a parameter pack. It expands into (expr1 op (expr2onwards op ... op expr)) (and likewise if the pack is on the right). The non-pack operand can be omitted; in that case, an empty pack gives a fallback value or an error, depending on the operator. llvm-svn: 221573
* Revert r221404 which caused lldb to not displayFariborz Jahanian2014-11-071-33/+0
| | | | | | vararg expressions. llvm-svn: 221533
* This patch fixes a crash after rebuilding call AST ofFariborz Jahanian2014-11-051-0/+33
| | | | | | | | | | | | | an __unknown_anytype(...). In this case, we rebuild the vararg function type specially to convert the call expression to something that IRGen can handle. However, FunctionDecl as rebuilt in RebuildUnknownAnyExpr::resolveDecl is bogus and results in crash when accessing its params later on. This patch fixes the crash by rebuilding the FunctionDecl to match its new resolved type. rdar://15297105. John McCall, please review post-commit. llvm-svn: 221404
* Improved capturing variable-length array types in CapturedStmt.Alexey Bataev2014-10-291-11/+11
| | | | | | | | An updated implemnentation of VLA types capturing based on previously committed solution for Lambdas. This version captures the whole VLA type instead of particular variables which are part of VLA size expression and allows to use previusly calculated size of VLA type in captured regions. Required for OpenMP. Differential Revision: http://reviews.llvm.org/D5099 llvm-svn: 220850
* Start adding the infrastructure for handling TypoExprs.Kaelyn Takata2014-10-271-0/+7
| | | | | | | | | | | | | | | | Part of the infrastructure is a map from a TypoExpr to the Sema-specific state needed to correct it, along with helpers to ease dealing with the state. The the typo count is propagated up the stack of ExpressionEvaluationContextRecords when one is popped off of to avoid accidentally dropping TypoExprs on the floor. For example, the attempted correction of g() in test/CXX/class/class.mem/p5-0x.cpp happens with an ExpressionEvaluationContextRecord that is popped off the stack prior to ActOnFinishFullExpr being called and the tree transform for TypoExprs being run. llvm-svn: 220695
* Pass around CorrectionCandidateCallbacks as unique_ptrs soKaelyn Takata2014-10-271-18/+19
| | | | | | TypoCorrectionConsumer can keep the callback around as long as needed. llvm-svn: 220693
* Switching to range-based for loops; NFC.Aaron Ballman2014-10-161-10/+5
| | | | llvm-svn: 219940
* Allow constant expressions in pragma loop hints.Tyler Nowicki2014-10-121-0/+28
| | | | | | | | Previously loop hints such as #pragma loop vectorize_width(#) required a constant. This patch allows a constant expression to be used as well. Such as a non-type template parameter or an expression (2 * c + 1). Reviewed by Richard Smith llvm-svn: 219589
* [complex] Teach Clang to preserve different-type operands to arithmeticChandler Carruth2014-10-111-82/+29
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | operators where one type is a C complex type, and to emit both the efficient and correct implementation for complex arithmetic according to C11 Annex G using this extra information. For both multiply and divide the old code was writing a long-hand reduced version of the math without any of the special handling of inf and NaN recommended by the standard here. Instead of putting more complexity here, this change does what GCC does which is to emit a libcall for the fully general case. However, the old code also failed to do the proper minimization of the set of operations when there was a mixed complex and real operation. In those cases, C provides a spec for much more minimal operations that are valid. Clang now emits the exact suggested operations. This change isn't *just* about performance though, without minimizing these operations, we again lose the correct handling of infinities and NaNs. It is critical that this happen in the frontend based on assymetric type operands to complex math operations. The performance implications of this change aren't trivial either. I've run a set of benchmarks in Eigen, an open source mathematics library that makes heavy use of complex. While a few have slowed down due to the libcall being introduce, most sped up and some by a huge amount: up to 100% and 140%. In order to make all of this work, also match the algorithm in the constant evaluator to the one in the runtime library. Currently it is a broken port of the simplifications from C's Annex G to the long-hand formulation of the algorithm. Splitting this patch up is very hard because none of this works without the AST change to preserve non-complex operands. Sorry for the enormous change. Follow-up changes will include support for sinking the libcalls onto cold paths in common cases and fastmath improvements to allow more aggressive backend folding. Differential Revision: http://reviews.llvm.org/D5698 llvm-svn: 219557
* Fix for bug http://llvm.org/PR17427.Alexey Bataev2014-10-091-5/+30
| | | | | | | | Assertion failed: "Computed __func__ length differs from type!" Reworked PredefinedExpr representation with internal StringLiteral field for function declaration. Differential Revision: http://reviews.llvm.org/D5365 llvm-svn: 219393
* Don't trap when passing non-POD arguments to variadic functions in ↵Hans Wennborg2014-09-291-0/+4
| | | | | | | | | | | | | | | | | | MS-compatibility mode Clang warns (treated as error by default, but still ignored in system headers) when passing non-POD arguments to variadic functions, and generates a trap instruction to crash the program if that code is ever run. Unfortunately, MSVC happily generates code for such calls without a warning, and there is code in system headers that use it. This makes Clang not insert the trap instruction when in -fms-compatibility mode, while still generating the warning/error message. Differential Revision: http://reviews.llvm.org/D5492 llvm-svn: 218640
* Don't perform ADL when looking up operator=; there is no non-member form ofRichard Smith2014-09-231-1/+1
| | | | | | | | | that function, and apart from being slow, this is unnecessary: ADL can trigger instantiations that are not permitted here. The standard isn't *completely* clear here, but this seems like the intent, and in any case this approach is permitted by [temp.inst]p7. llvm-svn: 218330
* Patch to check at compile time for overflow whenFariborz Jahanian2014-09-181-2/+2
| | | | | | | | __builtin___memcpy_chk and similar builtins are being used. Patch by Jacques Fortier (with added clang tests). rdar://11076881 llvm-svn: 218063
* Don't try to devirtualize non-virtual callsReid Kleckner2014-09-161-0/+4
| | | | | | | | | | | We would end up marking the vtable of the derived class as used for no reason. Because the call itself is qualified, it is never virtual, and the vtable of the derived class isn't helpful. We would end up rejecting code that MSVC accepts for no benefit. See http://crbug.com/413478 llvm-svn: 217910
* Objective-C arc. Fixes a crash when issuing diagnostic forFariborz Jahanian2014-09-101-1/+1
| | | | | | passing parameter to an audited CF API. rdar://18222007 llvm-svn: 217530
* Split off CUDA-specific Sema parts to a new fileEli Bendersky2014-09-031-17/+0
| | | | | | | | | | | In line with SemaOpenMP.cpp, etc. CUDA-specific semantic analysis code goes into a separate file. This is in anticipation of adding extra functionality here in the near future. No change in functionality. Review: http://reviews.llvm.org/D5160 llvm-svn: 217043
* [C++11] Support for capturing of variable length arrays in lambda expression.Alexey Bataev2014-08-281-11/+30
| | | | | | Differential Revision: http://reviews.llvm.org/D4368 llvm-svn: 216649
* Call ResolveExceptionSpec for non-OdrUsed functions.Nico Weber2014-08-271-6/+9
| | | | | | | | In C++11, instantiation of exception specs is deferred. The instantiation is done in MarkFunctionReferenced(), which wasn't called for non-OdrUsed functions, which then caused an assert in codegen. Fixes PR19190, see the bug for details. llvm-svn: 216562
* Fix a bad location in -Wparentheses fix-it hintRichard Trieu2014-08-231-1/+1
| | | | | | | The code used getLocStart() instead of getLocEnd(). This works for single token expressions, but breaks if the expression is longer. llvm-svn: 216306
* C++1y is now C++14!Aaron Ballman2014-08-191-2/+2
| | | | | | Changes diagnostic options, language standard options, diagnostic identifiers, diagnostic wording to use c++14 instead of c++1y. It also modifies related test cases to use the updated diagnostic wording. llvm-svn: 215982
* Sema: Disallow taking the address of a bitfield coming from preincrementDavid Majnemer2014-07-311-2/+5
| | | | | | | | | | | | | | Clang forgot that '++s.m' was a bitfield l-value and permit it's address to be taken; this would crash at CodeGen-time. Instead, propagate the object-kind when we see the prefix increment/decrement. This fixes PR20496. Differential Revision: http://reviews.llvm.org/D4733 llvm-svn: 214386
* Not all instantiated variable is odr-used. Do not mark non-odr-used variable ↵Larisse Voufo2014-07-301-0/+6
| | | | | | template specializations as such. llvm-svn: 214267
OpenPOWER on IntegriCloud