summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorEli Friedman <eli.friedman@gmail.com>2009-08-15 02:50:32 +0000
committerEli Friedman <eli.friedman@gmail.com>2009-08-15 02:50:32 +0000
commit04fddf0d1f3af5e79e9b00bdaa66ea19fe566a56 (patch)
tree7fd42cc39f666d62c1083b77d71377621ed1c4a3 /clang/lib/CodeGen/CodeGenFunction.cpp
parentdeb8448690c9a436e9fcbfb31dfe447f45c0c295 (diff)
downloadbcm5719-llvm-04fddf0d1f3af5e79e9b00bdaa66ea19fe566a56.tar.gz
bcm5719-llvm-04fddf0d1f3af5e79e9b00bdaa66ea19fe566a56.zip
Fix for PR4721: adjust CodeGen and ASTContext so that we have a
consistent model for handling size expressions for VLAs. The model is essentially as follows: VLA types own their associated expression. In some cases, we need to create multiple VLA types to represent a given VLA (for canonical types, or qualifiers on array types, or type merging). If we need to create multiple types based off of the same VLA declaration, we use the new refcounting functionality so they can all own the expression. The VLASizeMap in CodeGenFunction then uses the size expression to identify the group of VLA types based off of the same original declaration. I'm not particularly attached to the VLA types owning the expression, but we're stuck with at least until someone comes up with a way to walk the VLA expressions for a declaration. I did the parallel fix in ASTContext for DependentSizedArrayType, but I haven't really looked closely at it, so there might still be issues there. I'll clean up the code duplication in ASTContext in a followup commit. llvm-svn: 79071
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index e4a83bce029..1e8d05261db 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -477,7 +477,7 @@ void CodeGenFunction::EmitIndirectSwitches() {
}
llvm::Value *CodeGenFunction::GetVLASize(const VariableArrayType *VAT) {
- llvm::Value *&SizeEntry = VLASizeMap[VAT];
+ llvm::Value *&SizeEntry = VLASizeMap[VAT->getSizeExpr()];
assert(SizeEntry && "Did not emit size for type");
return SizeEntry;
@@ -490,7 +490,7 @@ llvm::Value *CodeGenFunction::EmitVLASize(QualType Ty) {
EnsureInsertPoint();
if (const VariableArrayType *VAT = getContext().getAsVariableArrayType(Ty)) {
- llvm::Value *&SizeEntry = VLASizeMap[VAT];
+ llvm::Value *&SizeEntry = VLASizeMap[VAT->getSizeExpr()];
if (!SizeEntry) {
const llvm::Type *SizeTy = ConvertType(getContext().getSizeType());
OpenPOWER on IntegriCloud