[llvm-commits] [dragonegg] r156177 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Fri May 4 09:33:15 PDT 2012
Author: baldrick
Date: Fri May 4 11:33:15 2012
New Revision: 156177
URL: http://llvm.org/viewvc/llvm-project?rev=156177&view=rev
Log:
Handling taking the address of a constant constructor, using the same code that
handles taking the address of 3 and similar simple constants. While there, move
the code for handling COMPOUND_LITERAL_EXPR to its own subroutine.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=156177&r1=156176&r2=156177&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Fri May 4 11:33:15 2012
@@ -1479,8 +1479,9 @@
// ... AddressOf ...
//===----------------------------------------------------------------------===//
-/// AddressOfCST - Return the address of a simple constant, eg a of number.
-static Constant *AddressOfCST(tree exp, TargetFolder &Folder) {
+/// AddressOfSimpleConstant - Return the address of a simple constant, such as a
+/// number or constructor.
+static Constant *AddressOfSimpleConstant(tree exp, TargetFolder &Folder) {
Constant *Init = ConvertInitializerImpl(exp, Folder);
// Cache the constants to avoid making obvious duplicates that have to be
@@ -1580,6 +1581,12 @@
return FieldPtr;
}
+/// AddressOfCOMPOUND_LITERAL_EXPR - Return the address of a compound literal.
+static Constant *AddressOfCOMPOUND_LITERAL_EXPR(tree exp, TargetFolder &Folder){
+ tree decl = DECL_EXPR_DECL(COMPOUND_LITERAL_EXPR_DECL_EXPR(exp));
+ return AddressOfImpl(decl, Folder);
+}
+
/// AddressOfDecl - Return the address of a global.
static Constant *AddressOfDecl(tree exp, TargetFolder &) {
return cast<Constant>(DEFINITION_LLVM(exp));
@@ -1640,7 +1647,7 @@
case REAL_CST:
case STRING_CST:
case VECTOR_CST:
- Addr = AddressOfCST(exp, Folder);
+ Addr = AddressOfSimpleConstant(exp, Folder);
break;
case ARRAY_RANGE_REF:
case ARRAY_REF:
@@ -1650,7 +1657,10 @@
Addr = AddressOfCOMPONENT_REF(exp, Folder);
break;
case COMPOUND_LITERAL_EXPR:
- Addr = AddressOfImpl(DECL_EXPR_DECL(TREE_OPERAND(exp, 0)), Folder);
+ Addr = AddressOfCOMPOUND_LITERAL_EXPR(exp, Folder);
+ break;
+ case CONSTRUCTOR:
+ Addr = AddressOfSimpleConstant(exp, Folder);
break;
case CONST_DECL:
case FUNCTION_DECL:
More information about the llvm-commits
mailing list