summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* PR16263: Implement current direction of core issue 1376. Binding a reference toRichard Smith2013-06-151-2/+2
| | | | | | | | | | | the result of a cast-to-reference-type lifetime-extends the object to which the reference inside the cast binds. This requires us to look for subobject adjustments on both the inside and the outside of the MaterializeTemporaryExpr when looking for a temporary to lifetime-extend (which we also need for core issue 616, and possibly 1213). llvm-svn: 184024
* Implement core issue 903: only integer literals with value 0 and prvalues ofRichard Smith2013-06-131-8/+9
| | | | | | type std::nullptr_t are null pointer constants from C++11 onwards. llvm-svn: 183883
* PR12086, PR15117Richard Smith2013-06-121-1/+1
| | | | | | | | | | | | | | | | | | | Introduce CXXStdInitializerListExpr node, representing the implicit construction of a std::initializer_list<T> object from its underlying array. The AST representation of such an expression goes from an InitListExpr with a flag set, to a CXXStdInitializerListExpr containing a MaterializeTemporaryExpr containing an InitListExpr (possibly wrapped in a CXXBindTemporaryExpr). This more detailed representation has several advantages, the most important of which is that the new MaterializeTemporaryExpr allows us to directly model lifetime extension of the underlying temporary array. Using that, this patch *drastically* simplifies the IR generation of this construct, provides IR generation support for nested global initializer_list objects, fixes several bugs where the destructors for the underlying array would accidentally not get invoked, and provides constant expression evaluation support for std::initializer_list objects. llvm-svn: 183872
* Do not walk through member-accesses on bitfields when looking for the objectRichard Smith2013-06-031-3/+5
| | | | | | | | which is lifetime-extended by a reference binding. An additional temporary is created for such a bitfield access (although we have no explicit AST representation for it). llvm-svn: 183095
* Fix handling of pointers-to-members and comma expressions whenRichard Smith2013-06-031-3/+8
| | | | | | lifetime-extending temporaries in reference bindings. llvm-svn: 183089
* 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
* Allocate memory for the new number of subexpressions. Fixup for r181572Dmitri Gribenko2013-05-101-1/+1
| | | | llvm-svn: 181611
* ArrayRef'ize ShuffleVectorExpr::setExprsDmitri Gribenko2013-05-101-4/+3
| | | | | | But ShuffleVectorExpr should be tail-allocating the storage for expressions. llvm-svn: 181572
* Grab-bag of bit-field fixes:John McCall2013-05-061-3/+8
| | | | | | | | | | | | | | - 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
* C++1y constexpr extensions, round 1: Allow most forms of declaration andRichard Smith2013-04-221-1/+1
| | | | | | | | statement in constexpr functions. Everything which doesn't require variable mutation is also allowed as an extension in C++11. 'void' becomes a literal type to support constexpr functions which return 'void'. llvm-svn: 180022
* C++1y: Allow aggregates to have default initializers.Richard Smith2013-04-201-2/+24
| | | | | | | | | | | Add a CXXDefaultInitExpr, analogous to CXXDefaultArgExpr, and use it both in CXXCtorInitializers and in InitListExprs to represent a default initializer. There's an additional complication here: because the default initializer can refer to the initialized object via its 'this' pointer, we need to make sure that 'this' points to the right thing within the evaluation. llvm-svn: 179958
* Basic support for Microsoft property declarations andJohn McCall2013-04-161-0/+1
| | | | | | | | references thereto. Patch by Tong Shen! llvm-svn: 179585
* Add streamed versions of getQualifiedNameAsString.Benjamin Kramer2013-02-231-1/+2
| | | | | | Move the cold virtual method getNameForDiagnostic out of line. llvm-svn: 175966
* Excise <cctype> from Clang (except clang-tblgen) in favor of CharInfo.h.Jordan Rose2013-02-081-1/+2
| | | | | | | Nearly all of these changes are one-to-one replacements; the few that aren't have to do with custom identifier validation. llvm-svn: 174768
* Use const visitors in ASTDumper.Alexander Kornienko2013-02-011-1/+1
| | | | | | | http://llvm-reviews.chandlerc.com/D355 Patch by Philip Craig! llvm-svn: 174171
* Constify some getters of DesignatedInitExprDmitri Gribenko2013-01-261-6/+9
| | | | llvm-svn: 173574
* Switch to APFloat constructor taking fltSemantics.Tim Northover2013-01-221-4/+37
| | | | | | | | This change also makes the serialisation store the required semantics, fixing an issue where PPC128 was always assumed when re-reading a 128-bit value. llvm-svn: 173139
* Implement OpenCL event_t as Clang builtin type, including event_t related ↵Guy Benyei2013-01-201-0/+3
| | | | | | OpenCL restrictions (OpenCL 1.2 spec 6.9) llvm-svn: 172973
* Some builtins do not evaluate their arguments. Teach EvaluatedExprVisitor notRichard Smith2013-01-171-0/+6
| | | | | | to visit them. llvm-svn: 172769
* Suppress all -Wunused-value warnings from macro body expansions.Matt Beaumont-Gay2013-01-171-4/+0
| | | | | | | | | | | | | | | | | | | This is inspired by a number of false positives in real code, including PR14968. I've added test cases reduced from these false positives to test/Sema/unused-expr.c, as well as corresponding test cases that pass the offending expressions as arguments to a no-op macro to ensure that we do warn there. This also removes my previous tweak from r166522/r166534, so that we warn on unused cast expressions in macro arguments. There were several test cases that were using -Wunused-value to test general diagnostic emission features; I changed those to use other warnings or warn on a macro argument expression. I stared at the test case for PR14399 for a while with Richard Smith and we believe the new test case exercises the same codepaths as before. llvm-svn: 172696
* Remove useless 'llvm::' qualifier from names like StringRef and others that areDmitri Gribenko2013-01-121-3/+3
| | | | | | brought into 'clang' namespace by clang/Basic/LLVM.h llvm-svn: 172323
* s/CXX0X/CXX11/g, except for __GNU_EXPERIMENTAL_CXX0X__, and update a few ↵Richard Smith2013-01-021-2/+2
| | | | | | nearby 'C++0x' comments. llvm-svn: 171372
* s/CPlusPlus0x/CPlusPlus11/gRichard Smith2013-01-021-2/+2
| | | | llvm-svn: 171367
* Fix for PR12222.Erik Verbruggen2012-12-251-37/+25
| | | | | | | | Changed getLocStart() and getLocEnd() to be required for Stmts, and make getSourceRange() optional. The default implementation for getSourceRange() is build the range by calling getLocStart() and getLocEnd(). llvm-svn: 171067
* Don't hit an assertion failure when calculating the __PRETTY_FUNCTION__Argyrios Kyrtzidis2012-12-141-1/+1
| | | | | | | | | | | | | | of a member function with parenthesized declarator. Like this test case: class Foo { const char *(baz)() { return __PRETTY_FUNCTION__; } }; llvm-svn: 170233
* Pull the Attr iteration parts out of Attr.h, so including DeclBase.h doesn't ↵Benjamin Kramer2012-12-011-6/+7
| | | | | | | | | pull in all the generated Attr code. Required to pull some functions out of line, but this shouldn't have a perf impact. No functionality change. llvm-svn: 169092
* Allow to pass from syntactic form of InitListExpr to semantic form (just as ↵Abramo Bagnara2012-11-081-2/+2
| | | | | | viceversa). No functionality change. llvm-svn: 167591
* Fixed range of implicit MemberExpr.Abramo Bagnara2012-11-081-2/+5
| | | | llvm-svn: 167581
* Fix an incorrect assert, the LHS can be an LValue.Rafael Espindola2012-11-011-1/+1
| | | | llvm-svn: 167232
* [libclang] Introduce clang_Cursor_getReceiverType which returns the CXType forArgyrios Kyrtzidis2012-11-011-20/+16
| | | | | | | | the receiver of an ObjC message expression. rdar://12578643 llvm-svn: 167201
* Move two helper functions to AST so that sema can use them.Rafael Espindola2012-10-271-0/+69
| | | | llvm-svn: 166853
* Address feedback from Eli Friedman on r166522.Matt Beaumont-Gay2012-10-241-4/+4
| | | | | | | In particular, we do want to warn on some unused cast subexpressions within macros. llvm-svn: 166534
* Don't emit -Wunused-value warnings from macro expansions.Matt Beaumont-Gay2012-10-231-0/+4
| | | | llvm-svn: 166522
* Fix -Wunused-value to not warn on expressions that have unresolved lookups dueMatt Beaumont-Gay2012-10-231-0/+5
| | | | | | to dependent arguments. llvm-svn: 166468
* StringRef-ify Binary/UnaryOperator::getOpcodeStrDavid Blaikie2012-10-081-2/+2
| | | | llvm-svn: 165383
* Move isObjCSelf into Expr.Anna Zaks2012-10-011-0/+18
| | | | llvm-svn: 164966
* Handle C++ functional casts in a similar way to C-style casts inEli Friedman2012-09-241-0/+1
| | | | | | unused expression warnings. <rdar://problem/12359208>. llvm-svn: 164569
* In StringLiteral::setString make sure that we copy the number ofArgyrios Kyrtzidis2012-09-141-3/+3
| | | | | | | | | | | bytes of the buffer and not the size of the string, otherwise we may overwrite the buffer if there is a mismatch between the size of the string and the CharByteWidth, and assertions are disabled. The bug where this could occur was fixed in r163931. Related to rdar://12069503 llvm-svn: 163939
* PR13811: Add a FunctionParmPackExpr node to handle references to functionRichard Smith2012-09-121-0/+1
| | | | | | | parameter packs where the reference is not being expanded but the pack has been. Previously, Clang would segfault in such cases. llvm-svn: 163672
* Change the representation of builtin functions in the ASTEli Friedman2012-08-311-2/+9
| | | | | | | | | (__builtin_* etc.) so that it isn't possible to take their address. Specifically, introduce a new type to represent a reference to a builtin function, and a new cast kind to convert it to a function pointer in the operand of a call. Fixes PR13195. llvm-svn: 162962
* Push ArrayRef through the Expr hierarchy.Benjamin Kramer2012-08-241-63/+64
| | | | | | No functionality change. llvm-svn: 162552
* Fix InitListExpr::isStringLiteralInit so it handles various edge cases ↵Eli Friedman2012-08-201-3/+3
| | | | | | correctly. PR13643. llvm-svn: 162226
* Factor out computation of whether a typeid's expression is potentiallyRichard Smith2012-08-131-16/+4
| | | | | | evaluated into a CXXTypeid member function. No functionality change. llvm-svn: 161779
* Provide isConst/Volatile on CXXMethodDecl.David Blaikie2012-08-101-4/+4
| | | | | | | | | This also provides isConst/Volatile/Restrict on FunctionTypes to coalesce the implementation with other callers (& update those other callers). Patch contributed by Sam Panzer (panzer@google.com). llvm-svn: 161647
* Implement warning for integral null pointer constants other than the literal 0.David Blaikie2012-08-081-2/+7
| | | | | | | | | | | | | | | | | | | | This is effectively a warning for code that violates core issue 903 & thus will become standard error in the future, hopefully. It catches strange null pointers such as: '\0', 1 - 1, const int null = 0; etc... There's currently a flaw in this warning (& the warning for 'false' as a null pointer literal as well) where it doesn't trigger on comparisons (ptr == '\0' for example). Fix to come in a future patch. Also, due to this only being a warning, not an error, it triggers quite frequently on gtest code which tests expressions for null-pointer-ness in a SFINAE context (so it wouldn't be a problem if this was an error as in an actual implementation of core issue 903). To workaround this for now, the diagnostic does not fire in unevaluated contexts. Review by Sean Silva and Richard Smith. llvm-svn: 161501
* Update documentation of HasSideEffects to match its callers' expectations, andRichard Smith2012-08-071-20/+18
| | | | | | | | | | | | update implementation to match. An elidable, non-trivial constructor call is a side-effect under this definition, but wasn't under the old one, because we are not required to evaluate it even though it may have an effect. Also rationalize checking for volatile reads: just look for lvalue-to-rvalue conversions on volatile glvalues, and ignore whether a DeclRefExpr etc is for a volatile variable. llvm-svn: 161393
* Teach Expr::HasSideEffects about all the Expr types, and fix a bug where itRichard Smith2012-08-071-0/+215
| | | | | | | | | | | | | | | | | | | was mistakenly classifying dynamic_casts which might throw as having no side effects. Switch it from a visitor to a switch, so it is kept up-to-date as future Expr nodes are added. Move it from ExprConstant.cpp to Expr.cpp, since it's not really related to constant expression evaluation. Since we use HasSideEffect to determine whether to emit an unused global with internal linkage, this has the effect of suppressing emission of globals in some cases. I've left many of the Objective-C cases conservatively assuming that the expression has side-effects. I'll leave it to someone with better knowledge of Objective-C than mine to improve them. llvm-svn: 161388
* Handle the case where the base type is not dependent, but the derived one is.Rafael Espindola2012-07-171-0/+3
| | | | | | Fixes pr13353.cpp. llvm-svn: 160393
* Drop the ASTContext.h include from Stmt.h and fix up transitive users.Benjamin Kramer2012-07-041-0/+28
| | | | | | | | | | | | | | This required moving the ctors for IntegerLiteral and FloatingLiteral out of line which shouldn't change anything as they are usually called through Create methods that are already out of line. ASTContext::Deallocate has been a nop for a long time, drop it from ASTVector and make it independent from ASTContext.h Pass the StorageAllocator directly to AccessedEntity so it doesn't need to have a definition of ASTContext around. llvm-svn: 159718
* Fix another issue with devirtualizing calls to final methods by passing themRafael Espindola2012-06-281-16/+22
| | | | | | | | the correct this pointer. There is some potential for sharing a bit more code with canDevirtualizeMemberFunctionCalls, but that can be done in an independent patch. llvm-svn: 159326
OpenPOWER on IntegriCloud