summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-01-25 01:21:06 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-01-25 01:21:06 +0000
commit529a99bcf4d2ac42d2ddff4909e3e7e61edf14b2 (patch)
tree535d7f00a484f1a303df28dbcfaceecf9ab857dd /clang/lib/CodeGen
parent8b7c52658bd5966c65a74d1404fa2fa96adc9edc (diff)
downloadbcm5719-llvm-529a99bcf4d2ac42d2ddff4909e3e7e61edf14b2.tar.gz
bcm5719-llvm-529a99bcf4d2ac42d2ddff4909e3e7e61edf14b2.zip
Fix the address of a label to be properly considered and emitted as a
constant. llvm-svn: 62948
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGExprConstant.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CGExprConstant.cpp b/clang/lib/CodeGen/CGExprConstant.cpp
index 9d709d3a509..0e31cacd1b0 100644
--- a/clang/lib/CodeGen/CGExprConstant.cpp
+++ b/clang/lib/CodeGen/CGExprConstant.cpp
@@ -619,6 +619,12 @@ public:
return CGM.GetAddrOfConstantCString(Str, ".tmp");
}
+ case Expr::AddrLabelExprClass: {
+ assert(CGF && "Invalid address of label expression outside function.");
+ unsigned id = CGF->GetIDForAddrOfLabel(cast<AddrLabelExpr>(E)->getLabel());
+ llvm::Constant *C = llvm::ConstantInt::get(llvm::Type::Int32Ty, id);
+ return llvm::ConstantExpr::getIntToPtr(C, ConvertType(E->getType()));
+ }
}
CGM.ErrorUnsupported(E, "constant l-value expression");
llvm::Type *Ty = llvm::PointerType::getUnqual(ConvertType(E->getType()));
OpenPOWER on IntegriCloud