summaryrefslogtreecommitdiffstats
path: root/clang/lib/AST/Expr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Further adjustments to -Wglobal-constructors; works for references and directJohn McCall2010-08-021-18/+28
| | | | | | initializations now. llvm-svn: 110063
* Kill off RequiresGlobalConstructor in favor of isConstantInitializer.John McCall2010-08-011-0/+15
| | | | | | Note some obvious false positives in the test case. llvm-svn: 109986
* Remove the vast majority of the Destroy methods from the AST library,Douglas Gregor2010-07-251-69/+0
| | | | | | since we aren't going to be calling them ever. llvm-svn: 109377
* Update ImplicitCastExpr to be able to represent an XValue.Sebastian Redl2010-07-201-2/+4
| | | | llvm-svn: 108807
* Introduce a new cast kind for an "lvalue bitcast", which handlesDouglas Gregor2010-07-131-0/+2
| | | | | | | | | | | | | | | | reinterpret_casts (possibly indirectly via C-style/functional casts) on values, e.g., int i; reinterpret_cast<short&>(i); The IR generated for this is essentially the same as for *reinterpret_cast<short*>(&i). Fixes PR6437, PR7593, and PR7344. llvm-svn: 108294
* When forming a function call or message send expression, be sure toDouglas Gregor2010-07-131-1/+4
| | | | | | | | | | | | | | | | | strip cv-qualifiers from the expression's type when the language calls for it: in C, that's all the time, while C++ only does it for non-class types. Centralized the computation of the call expression type in QualType::getCallResultType() and some helper functions in other nodes (FunctionDecl, ObjCMethodDecl, FunctionType), and updated all relevant callers of getResultType() to getCallResultType(). Fixes PR7598 and PR7463, along with a bunch of getResultType() call sites that weren't stripping references off the result type (nothing stripped cv-qualifiers properly before this change). llvm-svn: 108234
* Read/write the C++ parts of DeclRefExpr and MemberExpr for PCH.Argyrios Kyrtzidis2010-07-081-0/+13
| | | | llvm-svn: 107872
* Fix rdar://8139785 "implement warning on dead expression in comma operator"Argyrios Kyrtzidis2010-06-301-3/+8
| | | | | | | | | | As a bonus, fix the warning for || and && operators; it was emitted even if one of the operands had side effects, e.g: x || test_logical_foo1(); emitted a bogus "expression result unused" for 'x'. llvm-svn: 107274
* Introduce Expr::Classify and Expr::ClassifyModifiable, which determine the ↵Sebastian Redl2010-06-281-372/+0
| | | | | | classification of an expression under the C++0x taxology (value category). Reimplement isLvalue and isModifiableLvalue using these functions. No regressions in the test suite from this, and my rough performance check doesn't show any regressions either. llvm-svn: 107007
* Support a couple more C++ Exprs for PCH.Argyrios Kyrtzidis2010-06-241-2/+6
| | | | llvm-svn: 106727
* Do not treat @selector as lvalue (unlike g++).Fariborz Jahanian2010-06-171-1/+0
| | | | | | Patch by Nico Weber (pr7390). llvm-svn: 106242
* Objective-c++ IRGen. Support for @selector expression asFariborz Jahanian2010-06-171-0/+1
| | | | | | an lvalue. Fixes PR7390. llvm-svn: 106235
* Give Type::isIntegralType() an ASTContext parameter, so that itDouglas Gregor2010-06-161-4/+5
| | | | | | | | | | | | provides C "integer type" semantics in C and C++ "integral type" semantics in C++. Note that I still need to update isIntegerType (and possibly other predicates) using the same approach I've taken for isIntegralType(). The two should have the same meaning, but currently don't (!). llvm-svn: 106074
* Introduce Type::isIntegralOrEnumerationType(), to cover those placesDouglas Gregor2010-06-161-4/+5
| | | | | | | | | | in C++ that involve both integral and enumeration types. Convert all of the callers to Type::isIntegralType() that are meant to work with both integral and enumeration types over to Type::isIntegralOrEnumerationType(), to prepare to eliminate enumeration types as integral types. llvm-svn: 106071
* When deciding whether an expression has the boolean nature, don't look throughJohn McCall2010-06-121-1/+3
| | | | | | explicit casts. Fixes PR7359. llvm-svn: 105871
* Substantially alter the design of the Objective C type AST by introducingJohn McCall2010-05-151-3/+3
| | | | | | | | | | | | | | | | | | | | | ObjCObjectType, which is basically just a pair of one of {primitive-id, primitive-Class, user-defined @class} with a list of protocols. An ObjCObjectPointerType is therefore just a pointer which always points to one of these types (possibly sugared). ObjCInterfaceType is now just a kind of ObjCObjectType which happens to not carry any protocols. Alter a rather large number of use sites to use ObjCObjectType instead of ObjCInterfaceType. Store an ObjCInterfaceType as a pointer on the decl rather than hashing them in a FoldingSet. Remove some number of methods that are no longer used, at least after this patch. By simplifying ObjCObjectPointerType, we are now able to easily remove and apply pointers to Objective-C types, which is crucial for a certain kind of ObjC++ metaprogramming common in WebKit. llvm-svn: 103870
* add a couple of key functions for classes without them.Chris Lattner2010-05-131-0/+2
| | | | llvm-svn: 103688
* Static data members intialized in-class that have constant values areDouglas Gregor2010-05-111-1/+1
| | | | | | | | value-dependent if their initializers are value-dependent; my recent tweak to these dependent rules overstepped by taking away this value-dependents. Fixes a Boost.GIL regression. llvm-svn: 103476
* Fix indentationDouglas Gregor2010-05-111-1/+1
| | | | llvm-svn: 103465
* A DeclRefExpr that refers to a member function or a static data memberDouglas Gregor2010-05-111-3/+14
| | | | | | | | | | | | | | of the current instantiation is value-dependent. The C++ standard fails to enumerate this case and, therefore, we missed it. Chandler did all of the hard work of reducing the last remaining Boost.PtrContainer failure (which had to do with static initialization in the Serialization library) down to this simple little test. While I'm at it, clean up the dependence rules for template arguments that are declarations, and implement the dependence rules for template argument packs. llvm-svn: 103464
* Don't complain about an __builtin_va_arg expression's result beingDouglas Gregor2010-05-081-0/+1
| | | | | | unused, since the operation has side effects. llvm-svn: 103360
* Move CheckICE and isIntegerConstantExpr to ExprConstant.cpp because it seemedJohn McCall2010-05-071-379/+0
| | | | | | like a good idea at the time. llvm-svn: 103237
* Add IgnoreParenImpCasts() to Expr, which is basically like IgnoreParenCastsJohn McCall2010-05-051-1/+15
| | | | | | | | | except it only skips implicit casts. Also fix ObjCImplicitGetterSetterRefExpr's child_begin to skip the base expression if it's actually a type reference (which you get with static property references). llvm-svn: 103132
* Reapplying patch to change StmtNodes.def to StmtNodes.td, this timeAlexis Hunt2010-05-051-1/+1
| | | | | | | with no whitespace. This will allow statements to be referred to in attribute TableGen files. llvm-svn: 103087
* Revert r103072; I accidentally ended up deleting a bunch of trailingAlexis Hunt2010-05-051-80/+80
| | | | | | | whitespace which makes this patch unreadable. Will recommit without the whitespace. llvm-svn: 103086
* Change StmtNodes.def to StmtNodes.td in anticipation of a rewrite of attributesAlexis Hunt2010-05-051-80/+80
| | | | llvm-svn: 103072
* Fix a thinko that caused us not to compute __builtin_offset as aDouglas Gregor2010-04-301-1/+4
| | | | | | constant expression in C. llvm-svn: 102762
* When determining a standard conversion sequence involves resolving theDouglas Gregor2010-04-291-0/+1
| | | | | | | | | | | | | | | | | | | | | address of an overloaded function (or function template), perform that resolution prior to determining the implicit conversion sequence. This resolution is not part of the implicit conversion sequence itself. Previously, we would always consider this resolution to be a function pointer decay, which was a lie: there might be an explicit & in the expression, in which case decay should not occur. This caused the CodeGen assertion in PR6973 (where we created a pointer to a pointer to a function when we should have had a pointer to a function), but it's likely that there are corner cases of overload resolution where this would have failed. Cleaned up the code involved in determining the type that will produced afer resolving the overloaded function reference, and added an assertion to make sure the result is correct. Fixes PR6973. llvm-svn: 102650
* Completely reimplement __builtin_offsetof, based on a patch by RobertoDouglas Gregor2010-04-281-3/+64
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Amadini. This change introduces a new expression node type, OffsetOfExpr, that describes __builtin_offsetof. Previously, __builtin_offsetof was implemented using a unary operator whose subexpression involved various synthesized array-subscript and member-reference expressions, which was ugly and made it very hard to instantiate as a template. OffsetOfExpr represents the AST more faithfully, with proper type source information and a more compact representation. OffsetOfExpr also has support for dependent __builtin_offsetof expressions; it can be value-dependent, but will never be type-dependent (like sizeof or alignof). This commit introduces template instantiation for __builtin_offsetof as well. There are two major caveats to this patch: 1) CodeGen cannot handle the case where __builtin_offsetof is not a constant expression, so it produces an error. So, to avoid regressing in C, we retain the old UnaryOperator-based __builtin_offsetof implementation in C while using the shiny new OffsetOfExpr implementation in C++. The old implementation can go away once we have proper CodeGen support for this case, which we expect won't cause much trouble in C++. 2) __builtin_offsetof doesn't work well with non-POD class types, particularly when the designated field is found within a base class. I will address this in a subsequent patch. Fixes PR5880 and a bunch of assertions when building Boost.Python tests. llvm-svn: 102542
* Wrap a couple of long lines. (Test commit.)Enea Zaffanella2010-04-271-2/+4
| | | | llvm-svn: 102420
* CastExpr should not hold a pointer to the base path. More cleanup.Anders Carlsson2010-04-241-2/+1
| | | | llvm-svn: 102249
* Rename InheritancePath to BasePath, rename CastExpr::CXXBaseVector to ↵Anders Carlsson2010-04-241-2/+2
| | | | | | CXXBaseSpecifierArray. More to come. llvm-svn: 102245
* Destroy the inheritance path.Anders Carlsson2010-04-231-0/+7
| | | | llvm-svn: 102211
* Implement template instantiation for Objective-C++ message sends. WeDouglas Gregor2010-04-221-3/+3
| | | | | | | | | | | | support dependent receivers for class and instance messages, along with dependent message arguments (of course), and check as much as we can at template definition time. This commit also deals with a subtle aspect of template instantiation in Objective-C++, where the type 'T *' can morph from a dependent PointerType into a non-dependent ObjCObjectPointer type. llvm-svn: 102071
* CXXNamedCastExpr is actually an abstract expression.Zhongxing Xu2010-04-211-1/+0
| | | | llvm-svn: 101994
* Overhaul the AST representation of Objective-C message sendDouglas Gregor2010-04-211-92/+149
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | expressions, to improve source-location information, clarify the actual receiver of the message, and pave the way for proper C++ support. The ObjCMessageExpr node represents four different kinds of message sends in a single AST node: 1) Send to a object instance described by an expression (e.g., [x method:5]) 2) Send to a class described by the class name (e.g., [NSString method:5]) 3) Send to a superclass class (e.g, [super method:5] in class method) 4) Send to a superclass instance (e.g., [super method:5] in instance method) Previously these four cases where tangled together. Now, they have more distinct representations. Specific changes: 1) Unchanged; the object instance is represented by an Expr*. 2) Previously stored the ObjCInterfaceDecl* referring to the class receiving the message. Now stores a TypeSourceInfo* so that we know how the class was spelled. This both maintains typedef information and opens the door for more complicated C++ types (e.g., dependent types). There was an alternative, unused representation of these sends by naming the class via an IdentifierInfo *. In practice, we either had an ObjCInterfaceDecl *, from which we would get the IdentifierInfo *, or we fell into the case below... 3) Previously represented by a class message whose IdentifierInfo * referred to "super". Sema and CodeGen would use isStr("super") to determine if they had a send to super. Now represented as a "class super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). 4) Previously represented by an instance message whose receiver is a an ObjCSuperExpr, which Sema and CodeGen would check for via isa<ObjCSuperExpr>(). Now represented as an "instance super" send, where we have both the location of the "super" keyword and the ObjCInterfaceDecl* of the superclass we're targetting (statically). Note that ObjCSuperExpr only has one remaining use in the AST, which is for "super.prop" references. The new representation of ObjCMessageExpr is 2 pointers smaller than the old one, since it combines more storage. It also eliminates a leak when we loaded message-send expressions from a precompiled header. The representation also feels much cleaner to me; comments welcome! This patch attempts to maintain the same semantics we previously had with Objective-C message sends. In several places, there are massive changes that boil down to simply replacing a nested-if structure such as: if (message has a receiver expression) { // instance message if (isa<ObjCSuperExpr>(...)) { // send to super } else { // send to an object } } else { // class message if (name->isStr("super")) { // class send to super } else { // send to class } } with a switch switch (E->getReceiverKind()) { case ObjCMessageExpr::SuperInstance: ... case ObjCMessageExpr::Instance: ... case ObjCMessageExpr::SuperClass: ... case ObjCMessageExpr::Class:... } There are quite a few places (particularly in the checkers) where send-to-super is effectively ignored. I've placed FIXMEs in most of them, and attempted to address send-to-super in a reasonable way. This could use some review. llvm-svn: 101972
* Add raw_ostream operators to NamedDecl for convenience. Switch over all ↵Benjamin Kramer2010-04-171-6/+4
| | | | | | | | users of getNameAsString on a stream. The next step is to print the name directly into the stream, avoiding a temporary std::string copy. llvm-svn: 101632
* make our existing "switch on bool" warning work for C. SinceChris Lattner2010-04-161-0/+59
| | | | | | | the result of comparisons are 'int' in C, it doesn't work to test just the result type of the expression. llvm-svn: 101576
* Use ASTVector instead of std::vector for the Exprs in InitListExpr. PerformanceTed Kremenek2010-04-131-9/+10
| | | | | | | measurements of '-fsyntax-only' on combine.c (403.gcc) shows no real performance change, but now the vector isn't leaked. llvm-svn: 101195
* 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
OpenPOWER on IntegriCloud