summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExpr.cpp
Commit message (Collapse)AuthorAgeFilesLines
...
* Add a new expression class, ObjCSuperExpr, to handle the Objective-C ↵Douglas Gregor2008-11-041-3/+8
| | | | | | 'super'. Remove ObjCThis from PredefinedExpr llvm-svn: 58698
* Emit more descriptive unsupported error message on dot-syntax use of super.Daniel Dunbar2008-10-171-0/+2
| | | | llvm-svn: 57745
* Lift CodeGenFunction::EmitPredefinedFunctioName out of EmitPredefinedLValue.Daniel Dunbar2008-10-171-23/+27
| | | | | | | - Shouldn't assume predefined expr is a function printing one. - Uses CGM functionality to cache function names per module. llvm-svn: 57737
* Refactor some CodeGen functionality: Daniel Dunbar2008-09-241-15/+35
| | | | | | | | | | - Add CodeGenFunction::{EmitReturnOfRValue, EmitIvarOffset} - Factor EmitLValueForIvar out of EmitObjCIvarRefLValue. No non-error functionality change (some unsupported errors are degraded to asserts for the time being). llvm-svn: 56543
* Implement CodeGen support for the 'CXXConditionDeclExpr' expression node, ↵Argyrios Kyrtzidis2008-09-101-0/+9
| | | | | | which represents a 'condition' declaration, e.g: "if (int x=0) {...}". llvm-svn: 56045
* Move ABI specific code for functions / calls to CGCall.cpp:Daniel Dunbar2008-09-091-55/+0
| | | | | | - Factor out EmitFunction{Pro,Epi}log llvm-svn: 56031
* Change CodeGen to emit calls using (RValue,Type) list:Daniel Dunbar2008-09-091-40/+25
| | | | | | | | | | | | | | - Add CodeGenFunction::EmitAnyExprToTemp o Like EmitAnyExpr, but emits aggregates to a temporary location if none is available. Seems like this should be simpler (even aside from using first class aggregates). - Killed CodeGenFunction::EmitCallArg (just append the pair) - Conversion of RValues to actual call arguments is now isolated in CodeGenFunction::EmitCall. llvm-svn: 55970
* Refactor parameter attribute handling:Daniel Dunbar2008-09-081-30/+9
| | | | | | | | | - Add CGCall.h for dealing with ABI issues related to calls. - Add CGFunctionInfo and CGCallInfo for capturing ABI relevant information about functions and calls. - Isolate LLVM parameter attribute handling inside CGCall.cpp llvm-svn: 55963
* Implement codegen of aggregates as lvalues in binary expressions,Daniel Dunbar2008-09-041-1/+15
| | | | | | e.g. "(a = b).somefield". llvm-svn: 55758
* Add Objective-C property setter support.Daniel Dunbar2008-08-301-0/+18
| | | | | | | | | | | | | | | | | | | | | | - Change Obj-C runtime message API, drop the ObjCMessageExpr arg in favor of just result type and selector. Necessary so it can be reused in situations where we don't want to cons up an ObjCMessageExpr. - Update aggregate binary assignment to know about special property ref lvalues. - Add CodeGenFunction::EmitCallArg overload which takes an already emitted rvalue. Add CodeGenFunction::StoreComplexIntoAddr. Disabled logic in Sema for parsing Objective-C dot-syntax that accesses methods. This code does not search in the correct order and the AST node has no way of properly representing its results. Updated StmtDumper to print a bit more information about ObjCPropertyRefExprs. llvm-svn: 55561
* Refactor handling of calls:Daniel Dunbar2008-08-301-44/+55
| | | | | | | | | | | | | | | | - Added CodeGenFunction::EmitCall which just takes the callee, return type, and a list of (Value*,QualType) pairs. - Added CodeGenFunction::EmitCallArg which handles emitting code for a call argument and turning it into an appropriate (Value*,QualType) pair. - Changed Objective-C runtime interface so that the actual emission of arguments for message sends is (once again) done in the code to emit a message send. No intended functionality change, this is prep work for better ABI support and for Objective-C property setter support. llvm-svn: 55560
* Add special "property reference" CodeGen::LValue type for emittingDaniel Dunbar2008-08-291-3/+25
| | | | | | | | Objective-C property references. - This handles property references "more correctly" but setters still don't work. llvm-svn: 55534
* Support __PRETTY_FUNCTION__ and friends in Obj-C methods.Daniel Dunbar2008-08-251-22/+23
| | | | | | | | | | | | Add CodeGenFunction::EmitUnsupportedLValue - Gives error and returns undef value. Swap some asserts() over to using EmitUnsupportedLValue - Rumor has it users (and even some developers) prefer carat diagnostics to backtraces. - Works better in Release-Asserts to boot. llvm-svn: 55328
* Make code generation of ivar ref exprs more like member exprs.Anders Carlsson2008-08-251-19/+25
| | | | llvm-svn: 55298
* Implement Obj-C ivar references to aggregates.Daniel Dunbar2008-08-231-0/+17
| | | | | | | | | | | Implement Obj-C lvalue message sends (aggregate returns). Update several places to emit more precise ErrorUnsupported warnings for currently unimplemented Obj-C features (main missing chunks are property references, Obj-C exception handling, and the for ... in syntax). llvm-svn: 55234
* NeXT: Fix message sends which return structures.Daniel Dunbar2008-08-231-5/+5
| | | | | | - Simplify the sending code a bit. llvm-svn: 55232
* Trim CGObjCRuntime::GenerateMessageSend[Super]Daniel Dunbar2008-08-231-1/+11
| | | | | | | | | | | | | | | | | | - Returns an RValue. - Reduced to only taking the CodeGenFunction, Expr, and Receiver. - Becomes responsible for emitting the arguments. Add CodeGenFunction::EmitCallExprExt - Takes optional extra arguments to insert at the head of the call. - This allows the Obj-C runtimes to call into this and isolates the argument and call instruction generation code to one place. Upshot is that we now pass structures (more) correctly. Also, fix one aspect of generating methods which take structure arguments (for NeXT). This probably needs to be merged with the SetFunctionAttributes code in CodeGenModule.cpp llvm-svn: 55223
* Change WarnUnsupported to ErrorUnsupported (in name and in practice).Daniel Dunbar2008-08-161-2/+1
| | | | | | | - We are beyond the point where this shows up often and when it does generating miscompiled files is bad. llvm-svn: 54836
* Add GetAddrOfConstantCString methodDaniel Dunbar2008-08-131-4/+1
| | | | | | | | | | | | | | | | | | - Returns addr of constant for argument + '\0'. - I couldn't think of a better name. - Move appropriate users of GetAddrOfConstantString to this. Rename getStringForStringLiteral to GetStringForStringLiteral. Add GetAddrOfConstantStringFromLiteral - This combines GetAddrOfConstantString and GetStringForStringLiteral. This method can be, but is not yet, more efficient. Change GetAddrOfConstantString to not add terminating '\0' - <rdar://problem/6140956> llvm-svn: 54768
* Change ObjCRuntime GenerateProtocol[Ref] methods to takeDaniel Dunbar2008-08-131-0/+1
| | | | | | | | | | | ObjCProtocolDecl directly. Implement CodeGen support for forward protocol decls (no-ops are so nice to implement). Also moved CGObjCRuntime.h out of CodeGenModule.h llvm-svn: 54709
* Change CodeGenModule to only create ObjC runtime for ObjC filesDaniel Dunbar2008-08-111-1/+1
| | | | | | | - Changed CodeGenModule::getObjCRuntime to return reference. - Added CodeGenModule::hasObjCRuntime predicate. llvm-svn: 54645
* More #include cleaningDaniel Dunbar2008-08-111-7/+0
| | | | | | | | | | | - Kill unnecessary #includes in .cpp files. This is an automatic sweep so some things removed are actually used, but happen to be included by a previous header. I tried to get rid of the obvious examples and this was the easiest way to trim the #includes in one fell swoop. - We now return to regularly scheduled development. llvm-svn: 54632
* More #include cleaningDaniel Dunbar2008-08-111-0/+2
| | | | | | | | - Drop {Decl.h,DeclObjC.h,IdentifierTable.h} from Expr.h - Moved Sema::getCurMethodDecl() out of line (dependent on ObjCMethodDecl via dyn_cast). llvm-svn: 54629
* More #include cleaningDaniel Dunbar2008-08-111-1/+1
| | | | | | - Remove internal uses of AST.h llvm-svn: 54628
* Back out r54608 (inline string literals were getting an extra '\0')Daniel Dunbar2008-08-101-13/+4
| | | | | | | | | | | | | | | temporarily, I assumed GetAddrForConstantString literal was being used consistently but it doesn't look like it is. Factored out a CodeGenModule::getStringForStringLiteral which handles extracting a std::string for the bytes of a StringLiteral, padded to match the type. Update EmitLValue to use getStringForStringLiteral, this was previously not padding strings correctly. Good thing we only emit strings in 4 different places! llvm-svn: 54621
* rename PreDefinedExpr -> PredefinedExprChris Lattner2008-08-101-6/+6
| | | | llvm-svn: 54605
* Fix bitfield accesses which straddle the boundary of the underlyingDaniel Dunbar2008-08-061-46/+116
| | | | | | | | | | | | | | | | | | | | | type. - This generates somewhat less optimal code than before but this is not hard to rectify once stable (at the cost of slightly more complex code). - This currently always uses little-endian ordering of the bitfield. - This breaks the CodeGen/bitfield.c test because it was grepping for hard-coded assembly instructions. Will fix once a better test case is constructed (hard to do without execution). - This fixes SingleSource/UnitTests/2006-01-23-InitializedBitField.c and Regression/C/PR1386.c from the test suite. - <rdar://problem/6085090>, <rdar://problem/6094169> llvm-svn: 54395
* Finally fix PR2189. This makes a fairly invasive but important change toChris Lattner2008-08-041-1/+2
| | | | | | | | | | move getAsArrayType into ASTContext instead of being a method on type. This is required because getAsArrayType(const AT), where AT is a typedef for "int[10]" needs to return ArrayType(const int, 10). Fixing this greatly simplifies getArrayDecayedType, which is a good sign. llvm-svn: 54317
* Fix a regression I introduced in r54107:Chris Lattner2008-07-311-1/+1
| | | | | | http://llvm.org/viewvc/llvm-project?view=rev&revision=54107 llvm-svn: 54242
* Rework codegen emission of globalsDaniel Dunbar2008-07-291-3/+3
| | | | | | | | | | | | | | | | | | | | - No (intended) functionality change. - Primary purpose is to clearly separate (lazy) construction of globals that are a forward declaration or tentative definition from those that are the final definition. - Lazy construction is now encapsulated in GetAddrOf{Function,GlobalVar} while final definitions are constructed in EmitGlobal{Function,Var}Definition. - External interface for dealing with globals is now limited to EmitGlobal and GetAddrOf{Function,GlobalVar}. - Also updated helper functions dealing with statics, annotations, and ctors to be private. llvm-svn: 54179
* remove uses of QualType::getCanonicalType() from codegen for PR2189Chris Lattner2008-07-261-4/+4
| | | | llvm-svn: 54107
* change more instances of QualType::getCanonicalType to callChris Lattner2008-07-261-5/+9
| | | | | | ASTContext::getCanonicalType instead (PR2189) llvm-svn: 54105
* Change self/_cmd to be instances of ImplicitParamDecl instead of ParmVarDecl.Chris Lattner2008-06-171-1/+8
| | | | | | Patch by David Chisnall! llvm-svn: 52422
* This patch is motivated by numerous strict-aliasing warnings when compilingTed Kremenek2008-06-171-12/+18
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | clang as a Release build. The big change is that all AST nodes (subclasses of Stmt) whose children are Expr* store their children as Stmt* or arrays of Stmt*. This is to remove strict-aliasing warnings when using StmtIterator. None of the interfaces of any of the classes have changed (except those with arg_iterators, see below), as the accessor methods introduce the needed casts (via cast<>). While this extra casting may seem cumbersome, it actually adds some important sanity checks throughout the codebase, as clients using StmtIterator can potentially overwrite children that are expected to be Expr* with Stmt* (that aren't Expr*). The casts provide extra sanity checks that are operational in debug builds to catch invariant violations such as these. For classes that have arg_iterators (e.g., CallExpr), the definition of arg_iterator has been replaced. Instead of it being Expr**, it is an actual class (called ExprIterator) that wraps a Stmt**, and provides the necessary operators for iteration. The nice thing about this class is that it also uses cast<> to type-checking, which introduces extra sanity checks throughout the codebase that are useful for debugging. A few of the CodeGen functions that use arg_iterator (especially from OverloadExpr) have been modified to take begin and end iterators instead of a base Expr** and the number of arguments. This matches more with the abstraction of iteration. This still needs to be cleaned up a little bit, as clients expect that ExprIterator is a RandomAccessIterator (which we may or may not wish to allow for efficiency of representation). This is a fairly large patch. It passes the tests (except CodeGen/bitfield.c, which was already broken) on both a Debug and Release build, but it should obviously be reviewed. llvm-svn: 52378
* Basic support for volatile loads and stores. Stores the volatile Eli Friedman2008-06-131-38/+64
| | | | | | | | | | qualifier in the lvalue, and changes lvalue loads/stores to honor the volatile flag. Places which need some further attention are marked with FIXMEs. Patch by Cédric Venet. llvm-svn: 52264
* First cut at setting attributes for functions and calls; this puts us Eli Friedman2008-06-011-0/+23
| | | | | | | | | | | | | | | much closer to passing the gcc struct layout tests. It might be possible to refactor this a bit, but I'm not sure there's actually enough common code for that to be useful. To get the calling convention completely correct, a bit of platform-specific code is necessary even for x86-Linux. On x86-Linux, the alignment of function parameters is extremely strange; as far as I can tell, it's always 4 except for SSE vectors or structs containing SSE vectors. I'm continuing to investigate this. llvm-svn: 51839
* Minor cleanup to use the ConvertTypeForMem helper.Eli Friedman2008-06-011-5/+3
| | | | llvm-svn: 51837
* Rearrange EmitLValueForField a bit to work properly for _Bool bitfields Eli Friedman2008-05-291-10/+9
| | | | | | | in unions (we don't want to do the union-specific bitcast for bit-fields). llvm-svn: 51678
* Change uses of llvm::Type::isFirstClassType to use the newDan Gohman2008-05-221-1/+1
| | | | | | | | | | | | llvm::Type::isSingleValueType. Currently these two functions have the same behavior, but soon isFirstClassType will return true for struct and array types. Clang may some day want to use of isFirstClassType for some of these some day as an optimization, but it'll require some consideration. llvm-svn: 51446
* Move getAccessedFieldNo out of lib/AST/Expr.cpp intoDan Gohman2008-05-221-5/+15
| | | | | | | | | lib/CodeGen/CGExpr.cpp and to change include/clang/AST/Attr.h to use its own enum for visibility types instead of using llvm::GlobalValue::VisibilityTypes. These changes eliminate dependencies in the AST library on LLVM's VMCore library. llvm-svn: 51398
* Remove an unnecessary/buggy if check. Ran into this with some other Eli Friedman2008-05-211-6/+4
| | | | | | changes in my tree, so I don't have a testcase which affects trunk. llvm-svn: 51371
* Fix the emission of expressions like char a[10] = "asdf"; previously, Eli Friedman2008-05-191-0/+7
| | | | | | | | they were causing bad code to be emitted. There are two fixes here: one makes sure we emit a string that is long enough, and one makes sure we properly handle string initialization in init lists. llvm-svn: 51259
* Fix support for _Bool bitfields. The issue is that the bitfield width Eli Friedman2008-05-171-4/+20
| | | | | | | | | | | | used for _Bool is not the same as the primitive width (which for _Bool is 1 bit). The load and store changes add some casts to make the types consistent. The EmitLValue changes make sure that the pointer is of an appropriate type for loading the bitfield. This isn't perfect, but it's an improvement, and getting everything right depends on actually laying out structs in an ABI-compliant way. llvm-svn: 51224
* Add codegen support for block-level compound literals.Eli Friedman2008-05-131-0/+20
| | | | llvm-svn: 51081
* Remove AST dependency on VMCore by switching ExtVectorElementExpr off Constant.Nate Begeman2008-05-131-21/+30
| | | | llvm-svn: 51068
* Extend vector member references to include {.hi, .lo, .e, .o} which return aNate Begeman2008-05-091-8/+27
| | | | | | | | | | | | | vector of the same element type and half the width, with the high, low, even, and odd elements respectively. Allow member references to member references, so that .hi.hi gives you the high quarter of a vector. This is fairly convenient syntax for some insert/extract operations. Remove some unnecessary methods/types in the ExtVectorElementExpr class. llvm-svn: 50892
* OCUVector -> ExtVector, shorthand for extended vector, per feedback from Chris.Nate Begeman2008-04-181-23/+25
| | | | llvm-svn: 49942
* Remove FileVarDecl and BlockVarDecl. They are replaced by ↵Steve Naroff2008-04-151-7/+7
| | | | | | | | VarDecl::isBlockVarDecl() and VarDecl::isFileVarDecl(). This is a fairly mechanical/large change. As a result, I avoided making any changes/simplifications that weren't directly related. I did break two Analysis tests. I also have a couple FIXME's in UninitializedValues.cpp. Ted, can you take a look? If the bug isn't obvious, I am happy to dig in and fix it (since I broke it). llvm-svn: 49748
* Since isComplexType() no longer returns true for _Complex integers, the codeChris Lattner2008-04-041-4/+4
| | | | | | generator needs to call isAnyComplexType(). This fixes PR1960. llvm-svn: 49220
* Codegen assignment to self correctly, patch by David Chisnall!Chris Lattner2008-04-041-2/+10
| | | | llvm-svn: 49201
OpenPOWER on IntegriCloud