summaryrefslogtreecommitdiffstats
path: root/clang/lib/Sema/SemaExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* 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
* ArrayRef'ize some SemaOverload methodsDmitri Gribenko2013-05-091-46/+42
| | | | | | Patch by Robert Wilhelm. llvm-svn: 181544
* CodeGen for CapturedStmtsBen Langmuir2013-05-091-5/+5
| | | | | | | | | | | | | | | | | EmitCapturedStmt creates a captured struct containing all of the captured variables, and then emits a call to the outlined function. This is similar in principle to EmitBlockLiteral. GenerateCapturedFunction actually produces the outlined function. It is based on GenerateBlockFunction, but is much simpler. The function type is determined by the parameters that are in the CapturedDecl. Some changes have been added to this patch that were reviewed as part of the serialization patch and moving the parameters to the captured decl. Differential Revision: http://llvm-reviews.chandlerc.com/D640 llvm-svn: 181536
* Grab-bag of bit-field fixes:John McCall2013-05-061-1/+1
| | | | | | | | | | | | | | - References to ObjC bit-field ivars are bit-field lvalues; fixes rdar://13794269, which got me started down this. - Introduce Expr::refersToBitField, switch a couple users to it where semantically important, and comment the difference between this and the existing API. - Discourage Expr::getBitField by making it a bit longer and less general-sounding. - Lock down on const_casts of bit-field gl-values until we hear back from the committee as to whether they're allowed. llvm-svn: 181252
* Fix representation of compound literals for C++ objects with destructors.Jordan Rose2013-05-061-1/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | Previously, this compound literal expression (a GNU extension in C++): (AggregateWithDtor){1, 2} resulted in this AST: `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-CXXBindTemporaryExpr [...] 'struct AggregateWithDtor' (CXXTemporary [...]) `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 Note the two CXXBindTemporaryExprs. The InitListExpr is really part of the CompoundLiteralExpr, not an object in its own right. By introducing a new entity initialization kind in Sema specifically for compound literals, we avoid the treatment of the inner InitListExpr as a temporary. `-CXXBindTemporaryExpr [...] 'struct Point' (CXXTemporary [...]) `-CompoundLiteralExpr [...] 'struct AggregateWithDtor' `-InitListExpr [...] 'struct AggregateWithDtor' |-IntegerLiteral [...] 'int' 1 `-IntegerLiteral [...] 'int' 2 llvm-svn: 181212
* Require the containing type to be complete when we seeJohn McCall2013-05-061-19/+54
| | | | | | | | | | | | __alignof__ of a field. This problem can only happen in C++11. Also do some petty optimizations. rdar://13784901 llvm-svn: 181185
* Replace 'MultiExprArg()' with 'None'Dmitri Gribenko2013-05-051-2/+2
| | | | llvm-svn: 181166
* Replace ArrayRef<T>() with None, now that we have an implicit ArrayRef ↵Dmitri Gribenko2013-05-051-5/+5
| | | | | | | | constructor from None Patch by Robert Wilhelm. llvm-svn: 181139
* Implement most of N3638 (return type deduction for normal functions).Richard Smith2013-05-041-0/+12
| | | | | | | Missing (somewhat ironically) is support for the new deduction rules in lambda functions, plus PCH support for return type patching. llvm-svn: 181108
* ArrayRef'ize MultiLevelTemplateArgumentList::ArgList. Patch by Faisal Vali!Richard Smith2013-05-031-6/+3
| | | | llvm-svn: 181077
* ArrayRef'ize InitializationSequence constructor and ↵Dmitri Gribenko2013-05-031-12/+9
| | | | | | | | InitializationSequence::Diagnose() Patch by Robert Wilhelm. llvm-svn: 181022
* Move parsing of identifiers in MS-style inline assembly intoJohn McCall2013-05-031-4/+6
| | | | | | | | | | | | | | | | | | | | | the actual parser and support arbitrary id-expressions. We're actually basically set up to do arbitrary expressions here if we wanted to. Assembly operands permit things like A::x to be written regardless of language mode, which forces us to embellish the evaluation context logic somewhat. The logic here under template instantiation is incorrect; we need to preserve the fact that an expression was unevaluated. Of course, template instantiation in general is fishy here because we have no way of delaying semantic analysis in the MC parser. It's all just fishy. I've also fixed the serialization of MS asm statements. This commit depends on an LLVM commit. llvm-svn: 180976
* PR15884: In the 'taking the address of a temporary' extension, materialize theRichard Smith2013-05-011-0/+3
| | | | | | | | temporary to an lvalue before taking its address. This removes a weird special case from the AST representation, and allows the constant expression evaluator to deal with it without (broken) hacks. llvm-svn: 180866
* Objective-C (mostly arc): Under ARC, we often have unneeded qualifiers Fariborz Jahanian2013-04-301-0/+4
| | | | | | | in the diagnostics. Remove them when reporting incompatible Objective-C pointer types. // rdar://13752880. llvm-svn: 180765
* Fix an assertion failure / accepts-invalid in -fms-extensions mode. Don't buildRichard Smith2013-04-291-8/+10
| | | | | | | | | a dependent-scope id expression when a templated member function of a non-templated class references an unknown identifier, since instantiation won't rebuild it (and we can tell at parse time that it'll never work). Based on a patch by Faisal Vali! llvm-svn: 180701
* Add a warning for Objective-C pointer introspection, which is solely the job ↵Ted Kremenek2013-04-221-0/+31
| | | | | | of the Objective-C runtime. llvm-svn: 180062
* Switch the note order for -Woverloaded-shift-op-parentheses so that the noteRichard Trieu2013-04-181-4/+4
| | | | | | | with the silence fix-it comes first. This is more consistent with the rest of the warnings in -Wparentheses. llvm-svn: 179742
* Add warning group -Woverloaded-shift-op-parentheses to -Wparentheses. ThisRichard Trieu2013-04-171-0/+32
| | | | | | | | | | | | | | | will fire on code such as: cout << x == 0; which the compiler will intrepret as (cout << x) == 0; This warning comes with two fixits attached to notes, one for parentheses to silence the warning, and another to evaluate the comparison first. llvm-svn: 179662
* Sema for Captured StatementsTareq A. Siraj2013-04-161-6/+57
| | | | | | | | | | | | | Add CapturedDecl to be the DeclContext for CapturedStmt, and perform semantic analysis. Currently captures all variables by reference. TODO: templates Author: Ben Langmuir <ben.langmuir@intel.com> Differential Revision: http://llvm-reviews.chandlerc.com/D433 llvm-svn: 179618
* Fix handling of atomic shift operations, from Serge Pavlov.Douglas Gregor2013-04-161-12/+12
| | | | llvm-svn: 179600
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+69
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Remove some dead code that has not been used since 2010.Joey Gouly2013-04-151-11/+0
| | | | llvm-svn: 179558
* Update OpenCL comments to mention spec section and version.Tanya Lattner2013-04-031-3/+3
| | | | llvm-svn: 178716
* Add 178663 back.Rafael Espindola2013-04-031-2/+2
| | | | | | | | | | | http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb went back green before it processed the reverted 178663, so it could not have been the culprit. Revert "Revert 178663." This reverts commit 4f8a3eb2ce5d4ba422483439e20c8cbb4d953a41. llvm-svn: 178682
* Revert 178663.Rafael Espindola2013-04-031-2/+2
| | | | | | | | | | Looks like it broke http://lab.llvm.org:8011/builders/clang-x86_64-darwin10-gdb Revert "Don't compute a patched/semantic storage class." This reverts commit 8f187f62cb0487d31bc4afdfcd47e11fe9a51d05. llvm-svn: 178681
* Don't compute a patched/semantic storage class.Rafael Espindola2013-04-031-2/+2
| | | | | | | | | | | For variables and functions clang used to store two storage classes. The one "as written" in the code and a patched one, which, for example, propagates static to the following decls. This apparently is from the days clang lacked linkage computation. It is now redundant and this patch removes it. llvm-svn: 178663
* Objective-C: Provide fixit hints when warningFariborz Jahanian2013-04-021-6/+34
| | | | | | | | about 'isa' ivar being explicitely accessed when base is a user class object reference. // rdar://13503456 llvm-svn: 178562
* Add -Wstatic-local-in-inline, which warns about using a static localJohn McCall2013-04-021-7/+12
| | | | | | | | | | | | | | variable in a C99 inline (but not static-inline or extern-inline) function definition. The standard doesn't actually say that this doesn't apply to "extern inline" definitions, but that seems like a useful extension, and it at least doesn't have the obvious flaw that a static mutable variable in an externally-available definition does. rdar://13535367 llvm-svn: 178520
* Sema: Don't crash when trying to emit a precedence warning on postinc/decrement.Benjamin Kramer2013-03-301-1/+2
| | | | | | | | | Post-Inc can occur as a binary call (the infamous dummy int argument), but it's not really a binary operator. Fixes PR15628. llvm-svn: 178412
* Sema: Warn on sizeof on binary ops on decayed arrays.Benjamin Kramer2013-03-291-0/+28
| | | | | | | | | | | | | The array will decay into a pointer, creating an unexpected result. sizeof(array + int) is an easy to make typo for sizeof(array) + int. This was motivated by a NetBSD security bug, used sizeof(key - r) instead of sizeof(key) - r, reducing entropy in a random number generator. http://cvsweb.netbsd.org/bsdweb.cgi/src/sys/kern/subr_cprng.c.diff?r1=1.14&r2=1.15&only_with_tag=MAIN&f=h Differential Revision: http://llvm-reviews.chandlerc.com/D571 llvm-svn: 178371
* Objective-C: Produce precise diagnostic whenFariborz Jahanian2013-03-281-2/+36
| | | | | | | | 'isa' ivar is accessed provided it is the first ivar. Fixit hint will follow in another patch. This is continuation of // rdar://13503456 llvm-svn: 178313
* Objective-C: Provide fixit suggestions when class objectFariborz Jahanian2013-03-281-4/+26
| | | | | | | | is accessed via accessing 'isa' ivar to use object_getClass/object_setClass apis. // rdar://13503456 llvm-svn: 178282
* Objective-C: Issue more precise warning when userFariborz Jahanian2013-03-271-0/+5
| | | | | | | is accessing 'isa' as an object pointer. // rdar://13503456. FixIt to follow in another patch. llvm-svn: 178179
OpenPOWER on IntegriCloud