summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* Fix typo.Larisse Voufo2014-07-291-1/+1
| | | | llvm-svn: 214193
* Fix PR10177 where non-type template arguments to alias templates are not ↵Larisse Voufo2014-07-291-19/+21
| | | | | | marked as used in dependent contexts. The fix actually forces non-dependent names to be checked at template definition time as expected from the standard. llvm-svn: 214192
* Wrap to 80 columns. No behavior change.Nico Weber2014-07-271-4/+3
| | | | llvm-svn: 214047
* Objective-C. Warn if protocol used in an @protocolFariborz Jahanian2014-07-251-0/+9
| | | | | | | expression is a forward declaration as this results in undefined behavior. rdar://17768630 llvm-svn: 213968
* Improving the "integer constant too large" diagnostics based on post-commit ↵Aaron Ballman2014-07-241-6/+5
| | | | | | feedback from Richard Smith. Amends r213657. llvm-svn: 213865
* Provide extra information in the "integer constant is too large" diagnostic. ↵Aaron Ballman2014-07-221-3/+6
| | | | | | This will be used to improve other diagnostics. llvm-svn: 213657
* PR20356: Fix all Sema warnings with mismatched ext_/warn_ versusRichard Smith2014-07-191-6/+6
| | | | | | | | ExtWarn/Warnings. Mostly the name of the warning was changed to match the semantics, but in the PR20356 cases, the warning was about valid code, so the diagnostic was changed from ExtWarn to Warning instead. llvm-svn: 213443
* Avoid referencing the vtable when calling the ctor without emitting itReid Kleckner2014-07-161-2/+0
| | | | | | | | | | | | | | This fixes compilation errors about incomplete types used with WebKit's RefPtr template. Simply calling an out of line constructor should not instantiate all inline and defaulted virtual methods. Tested by building and testing several big piles of code on Linux. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D4429 llvm-svn: 213109
* Form a CallExpr from __noop without parensReid Kleckner2014-07-111-1/+14
| | | | | | | | | | | | MSVC accepts __noop without any trailing parens and treats it like a literal zero. We don't treat __noop as an integer literal, but now at least we can parse a naked __noop expression. Reviewers: rsmith Differential Revision: http://reviews.llvm.org/D4476 llvm-svn: 212860
* Fix typos.Nikola Smiljanic2014-07-091-1/+1
| | | | llvm-svn: 212589
* Switch over a few uses of param_begin() to parameters()Alp Toker2014-07-071-1/+1
| | | | llvm-svn: 212442
* Using of variable length arrays in captured statements and OpenMP constructs.Alexey Bataev2014-06-301-3/+102
| | | | | | Differential Revision: http://reviews.llvm.org/D4067 llvm-svn: 212010
* Objective-C ARC. Provide diagnostic and fix-it Fariborz Jahanian2014-06-261-1/+3
| | | | | | | | | when casting a retainable object to a objc_bridge_related CF type with the suggestion of applying the method specified in the bridging attribute to the object. // rdar://15932435 llvm-svn: 211807
* Convert StringLiteralParser constructor to use ArrayRef instead of a pointer ↵Craig Topper2014-06-261-5/+4
| | | | | | and count. llvm-svn: 211763
* Propagate isAddressOfMember into typo correction so that we don't correct ↵Nick Lewycky2014-06-231-0/+14
| | | | | | &qualified-id into &unqualified-id. Also make sure to set the naming class when we find the qualified-id in a different class than the nested name specifier specified so far. Fixes PR19681! llvm-svn: 211551
* Lex: Use the correct types for MS integer suffixesDavid Majnemer2014-06-211-13/+17
| | | | | | | | | | | | | | | | Something went wrong with r211426, it is an older version of this code and should not have been committed. It was reverted with r211434. Original commit message: We didn't properly implement support for the sized integer suffixes. Suffixes like i16 were essentially ignored instead of mapping them to the appropriately sized integer type. This fixes PR20008. Differential Revision: http://reviews.llvm.org/D4132 llvm-svn: 211441
* Revert "Lex: Use the correct types for MS integer suffixes"Rafael Espindola2014-06-211-13/+13
| | | | | | | | | This reverts commit r211426. This broke the arm bots. The crash can be reproduced on X86 by running. ./bin/clang -cc1 -fsyntax-only -verify -fms-extensions ~/llvm/clang/test/Lexer/ms-extensions.c -triple arm-linux llvm-svn: 211434
* Lex: Use the correct types for MS integer suffixesDavid Majnemer2014-06-211-13/+13
| | | | | | | | | | | | We didn't properly implement support for the sized integer suffixes. Suffixes like i16 were essentially ignored instead of mapping them to the appropriately sized integer type. This fixes PR20008. Differential Revision: http://reviews.llvm.org/D4132 llvm-svn: 211426
* Objective-C qoi. When Objective-C pointer mismatches withFariborz Jahanian2014-06-191-4/+31
| | | | | | | | a qualified-id type because pointer is object of a forward class declaration, include this info in a diagnostic note. // rdar://10751015 llvm-svn: 211324
* Objective-C ARC. Allow conversion of (void*) pointers toFariborz Jahanian2014-06-181-1/+2
| | | | | | | | retainable ObjC pointers without requiring a bridge-cast in the context of pointer comparison as this is in effect a +0 context. // rdar://16627903 llvm-svn: 211243
* Objective-C. Attributes on class declarations carry overFariborz Jahanian2014-06-181-0/+6
| | | | | | | to forward class declarations for diagnosis. // rdar://16681279 llvm-svn: 211195
* Objective-C. Diagnose when property access is using declaredFariborz Jahanian2014-06-161-5/+9
| | | | | | | property accessor methods which have become deprecated or available. // rdar://15951801 llvm-svn: 211039
* Hide the concept of diagnostic levels from lex, parse and semaAlp Toker2014-06-151-13/+5
| | | | | | | | | | | | | | | | The compilation pipeline doesn't actually need to know about the high-level concept of diagnostic mappings, and hiding the final computed level presents several simplifications and other potential benefits. The only exceptions are opportunistic checks to see whether expensive code paths can be avoided for diagnostics that are guaranteed to be ignored at a certain SourceLocation. This commit formalizes that invariant by introducing and using DiagnosticsEngine::isIgnored() in place of individual level checks throughout lex, parse and sema. llvm-svn: 211005
* Recover from missing 'typename' in sizeof(T::InnerType)Reid Kleckner2014-06-121-10/+35
| | | | | | | | | | | | | | | | | | | | | | Summary: 'sizeof' is a UnaryExprOrTypeTrait, and it can contain either a type or an expression. This change threads a RecoveryTSI parameter through the layers between TransformUnaryExprOrTypeTrait the point at which we look up the type. If lookup finds a single type result after instantiation, we now build TypeSourceInfo for it just like a normal transformation would. This fixes the last error in the hello world ATL app that I've been working with, and it now links and runs with clang. Please try it and file bugs! Reviewers: rsmith Subscribers: cfe-commits Differential Revision: http://reviews.llvm.org/D4108 llvm-svn: 210855
* Don't slice SemaDiagnosticBuilderReid Kleckner2014-06-111-3/+2
| | | | | | | I wasn't able to figure out how to emit this diagnostic from a SFINAE context, so I don't have a test. llvm-svn: 210713
* Allow lookup into dependent bases in more places under -fms-compatibilityReid Kleckner2014-06-111-22/+52
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | We currently allow unqualified lookup for instance methods but not static methods because we can't recover with a semantic 'this->' insertion. ATL headers have static methods that do unqualified lookup into dependent base classes. The pattern looks like: template <typename T> struct Foo : T { static int *getBarFromT() { return Bar; } }; Now we recover as if the user had written: template <typename T> struct Foo : T { static int *getBarFromT() { return Foo::Bar; } }; ... which will eventually look up Bar in T at instantiation time. Now we emit a diagnostic in both cases, and delay lookup in other contexts where 'this' is available and refers to a class with dependent bases. Reviewed by: rsmith Differential Revision: http://reviews.llvm.org/D4079 llvm-svn: 210611
* Related to PR19992: when the GNU alignof-expression extension is applied to anRichard Smith2014-06-101-4/+15
| | | | | | | expression of array-of-unknown-bound type, don't try to complete the array bound, and return the alignment of the element type rather than 1. llvm-svn: 210608
OpenPOWER on IntegriCloud