summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
* Don't emit an 'unused expression' warning for '||' and '&&' expressions that ↵Ted Kremenek2010-04-071-12/+15
| | | | | | | | contain assignments or similar side-effects. llvm-svn: 100676
* Implement the protected access restriction ([class.protected]), which requiresJohn McCall2010-04-061-2/+4
| | | | | | | | that protected members be used on objects of types which derive from the naming class of the lookup. My first N attempts at this were poorly-founded, largely because the standard is very badly worded here. llvm-svn: 100562
* Rework our handling of copy construction of temporaries, which was aDouglas Gregor2010-04-021-0/+65
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | poor (and wrong) approximation of the actual rules governing when to build a copy and when it can be elided. The correct implementation is actually simpler than the approximation. When we only enumerate constructors as part of initialization (e.g., for direct initialization or when we're copying from a class type or one of its derived classes), we don't create a copy. When we enumerate all conversion functions, we do create a copy. Before, we created some extra copies and missed some others. The new test copy-initialization.cpp shows a case where we missed creating a (required, non-elidable) copy as part of a user-defined conversion, which resulted in a miscompile. This commit also fixes PR6757, where the missing copy made us reject well-formed code in the ternary operator. This commit also cleans up our handling of copy elision in the case where we create an extra copy of a temporary object, which became necessary now that we produce the right copies. The code that seeks to find the temporary object being copied has moved into Expr::getTemporaryObject(); it used to have two different not-quite-the-same implementations, one in Sema and one in CodeGen. Note that we still do not attempt to perform the named return value optimization, so we miss copy elisions for return values and throw expressions. llvm-svn: 100196
* Remove the AST statistics tracking I added yesterday; it didn't pan out.Douglas Gregor2010-03-311-7/+0
| | | | llvm-svn: 100027
* Introduce a new kind of derived-to-base cast which bypasses the need forJohn McCall2010-03-301-0/+2
| | | | | | | null checks, and make sure we elide null checks when accessing base class members. llvm-svn: 99963
* Propagate the "found declaration" (i.e. the using declaration instead ofJohn McCall2010-03-301-25/+26
| | | | | | | | | | | | | the underlying/instantiated decl) through a lot of API, including "intermediate" MemberExprs required for (e.g.) template instantiation. This is necessary because of the access semantics of member accesses to using declarations: only the base class *containing the using decl* need be accessible from the naming class. This allows us to complete an access-controlled selfhost, if there are no recent regressions. llvm-svn: 99936
* Introduce new AST statistics that keep track of the number of isa (orDouglas Gregor2010-03-301-0/+7
| | | | | | | | | | | | | | | | | | | | | dyn_cast) invocations for C++ and Objective-C types, declarations, expressions, and statements. The statistics will be printed when -print-stats is provided to Clang -cc1, with results such as: 277073 clang - Number of checks for C++ declaration nodes 13311 clang - Number of checks for C++ expression nodes 18 clang - Number of checks for C++ statement nodes 174182 clang - Number of checks for C++ type nodes 92300 clang - Number of checks for Objective-C declaration nodes 9800 clang - Number of checks for Objective-C expression nodes 7 clang - Number of checks for Objective-C statement nodes 65733 clang - Number of checks for Objective-C type nodes The statistics are only gathered when NDEBUG is not defined, since they introduce potentially-expensive operations into very low-level routines (isa). llvm-svn: 99912
* Add Support for 'warn_unused_result" attribute onFariborz Jahanian2010-03-301-1/+8
| | | | | | objective-c methods. (radar 7418262). llvm-svn: 99903
* Make PredefinedExpr::ComputeName() more robust to incorrectTed Kremenek2010-03-181-1/+6
| | | | | | | code when we are printing the name of an Objective-C method whose class has not been declared. Fixes <rdar://problem/7495713>. llvm-svn: 98874
* Some cleanup, change diagnostic when assigning toFariborz Jahanian2010-03-181-5/+3
| | | | | | a property which is not lvalue. llvm-svn: 98848
* Improve the unused-value check to look into comma expressions and filter outJohn McCall2010-03-121-2/+8
| | | | | | | | voids in sub-expressions. Patch by Mike M! Fixes PR4806. llvm-svn: 98335
* When pretty-printing tag types, only print the tag if we're in C (andJohn McCall2010-03-101-1/+0
| | | | | | | | | | therefore not creating ElaboratedTypes, which are still pretty-printed with the written tag). Most of these testcase changes were done by script, so don't feel too sorry for my fingers. llvm-svn: 98149
* Extend ObjCMessageExpr for class method sends with the source locationDouglas Gregor2010-03-081-14/+20
| | | | | | of the class name. llvm-svn: 97943
* References to const int parameters with ICE default arguments are not ICEs.John McCall2010-02-241-2/+9
| | | | | | Fixes PR6373. llvm-svn: 97037
* Revert: "Change InitListExpr to allocate the array for holding references"Ted Kremenek2010-02-191-58/+27
| | | | | | | | This was causing buildbot breakage. This reverts commit d46e952cc8cb8d9eed8657d9a0b267910a0f745a. llvm-svn: 96652
* Change InitListExpr to allocate the array for holding referencesTed Kremenek2010-02-191-27/+58
| | | | | | | | | | | | | | | | to initializer expressions in an array allocated using ASTContext. This plugs a memory leak when ASTContext uses a BumpPtrAllocator to allocate memory for AST nodes. In my mind this isn't an ideal solution; it would be nice to have a general "vector"-like class that allocates memory using ASTContext, but whose guts could be separated from the methods of InitListExpr itself. I haven't gone and taken this approach yet because it isn't clear yet if we'll eventually want an alternate solution for recylcing memory using by InitListExprs as we are constructing the ASTs. llvm-svn: 96642
* Introduce a new kind of failed result for isLvalue/isModifiableLvalueDouglas Gregor2010-02-161-2/+29
| | | | | | | | which describes temporary objects of class type in C++. Use this to provide a more-specific, remappable diagnostic when takin the address of such a temporary. llvm-svn: 96396
* White-list comma expressions with the literal 0 as their RHS againstJohn McCall2010-02-161-1/+9
| | | | | | unused-value warnings. This is a common macro idiom. llvm-svn: 96326
* Don't error when setting a sub-structure variable via objc propertiesFariborz Jahanian2010-02-121-6/+1
| | | | | | in objective-c++ mode (do it for objective-c only). llvm-svn: 96012
* Allocate the SubExprs array in ObjCMessageExpr using the allocator ↵Ted Kremenek2010-02-111-15/+25
| | | | | | associated with ASTContext. This fixes yet another leak (<rdar://problem/7639260>). llvm-svn: 95930
* More vtable layout dumper improvements. Handle destructors, dump the ↵Anders Carlsson2010-02-111-4/+5
| | | | | | complete function type of the member functions (using PredefinedExpr::ComputeName. llvm-svn: 95887
* Diagnose when user provided getter is being used as lvalueFariborz Jahanian2010-02-111-5/+13
| | | | | | using property dot-syntax. Fixes radar 7628953. llvm-svn: 95838
* Per discussion, remove the explicit restriction on static const data members ↵John McCall2010-02-061-10/+3
| | | | | | | | with out-of-line initializers as integer constant expressions. Fixes PR6206. llvm-svn: 95463
* Revert "Numerous changes to selector handling:", this breaks a whole bunch ofDaniel Dunbar2010-02-031-1/+0
| | | | | | working code, for no apparent reason. llvm-svn: 95244
* Numerous changes to selector handling:David Chisnall2010-02-031-0/+1
| | | | | | | | | | | | | | | | | | | | | | | - Don't use GlobalAliases with non-0 GEPs (GNU runtime) - this was unsupported and LLVM will be generating errors if you do it soon. This also simplifies the code generated by the GNU runtime a bit. - Make GetSelector() return a constant (GNU runtime), not a load of a store of a constant. - Recognise @selector() expressions as valid static initialisers (as GCC does). - Add methods to GCObjCRuntime to emit selectors as constants (needed for using @selector() expressions as constants. These need implementing for the Mac runtimes - I couldn't figure out how to do this, they seem to require a load. - Store an ObjCMethodDecl in an ObjCSelectorExpr so that we can get at the type information for the selector. This is needed for generating typed selectors from @selector() expressions (as GCC does). Ideally, this information should be stored in the Selector, but that would be an invasive change. We should eventually add checks for common uses of @selector() expressions. Possibly adding an attribute that can be applied to method args providing the types of a selector so, for example, you'd do something like this: - (id)performSelector: __attribute__((selector_types(id, SEL, id)))(SEL) withObject: (id)object; Then, any @selector() expressions passed to the method will be check to ensure that it conforms to this signature. We do this at run time on the GNU runtime already, but it would be nice to do it at compile time on all runtimes. - Made @selector() expressions emit type info if available and the runtime supports it. Someone more familiar with the Mac runtime needs to implement the GetConstantSelector() function in CGObjCMac. This currently just assert()s. llvm-svn: 95189
* Remove abstract expression kinds from the StmtClass enum. Update a few usersJohn McCall2010-02-031-3/+0
| | | | | | appropriately. Call out a few missing cases in the expression mangler. llvm-svn: 95176
* In C++, an initializer on a variable doesn't necessarily mean it's the ↵Sebastian Redl2010-02-011-9/+7
| | | | | | definition. With that in mind, rename getDefinition to getAnyInitializer (to distinguish it from getInit) and reimplement it in terms of isThisDeclarationADefinition. Update all code to use this new function. llvm-svn: 94999
* Diagnose binding a non-const reference to a vector element.Anders Carlsson2010-01-311-0/+19
| | | | llvm-svn: 94963
* Fix reference binding of const lvalue references to bit-fields, whichDouglas Gregor2010-01-291-0/+7
| | | | | | | | | | | | | | | | | requires a temporary. Previously, we were building an initialization sequence that bound to the bit-field as if it were a real lvalue. Note that we previously (and still) diagnose binding of non-const references to bit-fields, as we should. There's no real way to test that this code is correct, since reference binding does not *currently* have any representation in the AST. This fix should make it easier for that to happen, so I've verified this fix with... Added InitializationSequence::dump(), to print an initialization sequence for debugging purposes. llvm-svn: 94826
* Add an CXXBindReferenceExpr (not used just yet).Anders Carlsson2010-01-291-0/+4
| | | | llvm-svn: 94791
* When determining whether a DeclRefExpr is value-dependent when itDouglas Gregor2010-01-151-4/+6
| | | | | | | | references a const variable of integral type, the initializer may be in a different declaration than the one that name-lookup saw. Find the initializer anyway. Fixes PR6045. llvm-svn: 93514
* Move the allocation of designators in DesignatedInitExpr to theDouglas Gregor2010-01-061-11/+19
| | | | | | ASTContext. Fixes <rdar://problem/7495428>. llvm-svn: 92867
* Make sure to explicitly pass type/value dependence to Expr constructor. ThisEli Friedman2009-12-301-3/+3
| | | | | | | | caught several cases where we were not doing the right thing. I'm not completely sure all cases are being handled correctly, but this should be an improvement. llvm-svn: 92281
* Fix for PR5872. Add static specifier and const/volatile qualifiers to member ↵Sam Weinig2009-12-271-0/+10
| | | | | | functions in __PRETTY_FUNCTION__ predefined expressions. llvm-svn: 92171
* support the warn_unused_result in C++ class methodsNuno Lopes2009-12-241-0/+2
| | | | llvm-svn: 92095
* indentation fixChris Lattner2009-12-211-1/+1
| | | | llvm-svn: 91807
* fix PR4010: add support for the warn_unused_result for function pointersNuno Lopes2009-12-201-3/+7
| | | | llvm-svn: 91803
* A CXXExprWithTemporaries expression is an lvalue if its subexpressionDouglas Gregor2009-12-191-0/+10
| | | | | | is an lvalue. Fixes PR5787. llvm-svn: 91765
* Diagnose attempting to assign to a sub-structure of an ivarFariborz Jahanian2009-12-151-4/+14
| | | | | | using objective-c property. (fixes radar 7449707) llvm-svn: 91474
* Improve template instantiation for object constructions in several ways:Douglas Gregor2009-12-141-0/+31
| | | | | | | | | | | | | - During instantiation, drop default arguments from constructor and call expressions; they'll be recomputed anyway, and we don't want to instantiate them twice. - Rewrote the instantiation of variable initializers to cope with non-dependent forms properly. Together, these fix a handful of problems I introduced with the switch to always rebuild expressions from the source code "as written." llvm-svn: 91315
* Un-namespace-qualify llvm_unreachable. It's a macro, so the qualification gaveJeffrey Yasskin2009-12-121-1/+1
| | | | | | no extra safety anyway. llvm-svn: 91207
* Patch to allow C-style cast from 'void *' to block pointer type.Fariborz Jahanian2009-12-111-0/+2
| | | | | | (fixes radar 7465023). llvm-svn: 91171
* Code gen for ObjCIsaExpr AST used as lvalue.Fariborz Jahanian2009-12-091-0/+1
| | | | | | (fixes radar 7457534). llvm-svn: 90995
* Added a missing case to a switch statement.Fariborz Jahanian2009-12-081-0/+2
| | | | llvm-svn: 90902
* DeclRefExpr stores a ValueDecl internally.John McCall2009-12-081-2/+2
| | | | | | Template instantiation can re-use DeclRefExprs. llvm-svn: 90848
* Don't print a void return type for C++ constructors and destructors when ↵Sam Weinig2009-12-061-1/+2
| | | | | | generating a predefined expr for them. llvm-svn: 90725
* Make the type of the Decl referred to by a MemberExpr a bit more precise.Eli Friedman2009-12-041-2/+2
| | | | llvm-svn: 90549
* Add recursion guards to ice-checking and evaluation for declrefs, so weEli Friedman2009-12-031-3/+8
| | | | | | don't infinitely recurse for cases we can't evaluate. llvm-svn: 90480
* r90313, in which OverloadedFunctionDecl is removed and never spoken of again.John McCall2009-12-021-3/+1
| | | | llvm-svn: 90313
* Eliminate the use of OverloadedFunctionDecl in member expressions.John McCall2009-11-301-0/+1
| | | | | | | | Create a new UnresolvedMemberExpr for these lookups. Assorted hackery around qualified member expressions; this will all go away when we implement the correct (i.e. extremely delayed) implicit-member semantics. llvm-svn: 90161
OpenPOWER on IntegriCloud