aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CodeGenFunction.h
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
commitbbed6b964414145b29e7b60b3e538093734ea3f8 (patch)
tree5ce93321b1e4dabf6726a859e40cd6c650f0a099 /lib/CodeGen/CodeGenFunction.h
parent07a5c22bb6fb0674c95205ae189365bf8e1b695e (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@79071 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/CodeGen/CodeGenFunction.h')
-rw-r--r--lib/CodeGen/CodeGenFunction.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/CodeGen/CodeGenFunction.h b/lib/CodeGen/CodeGenFunction.h
index aa4bcceae2..b4469c503b 100644
--- a/lib/CodeGen/CodeGenFunction.h
+++ b/lib/CodeGen/CodeGenFunction.h
@@ -224,9 +224,12 @@ private:
llvm::BasicBlock *InvokeDest;
// VLASizeMap - This keeps track of the associated size for each VLA type.
+ // We track this by the size expression rather than the type itself because
+ // in certain situations, like a const qualifier applied to an VLA typedef,
+ // multiple VLA types can share the same size expression.
// FIXME: Maybe this could be a stack of maps that is pushed/popped as we
// enter/leave scopes.
- llvm::DenseMap<const VariableArrayType*, llvm::Value*> VLASizeMap;
+ llvm::DenseMap<const Expr*, llvm::Value*> VLASizeMap;
/// DidCallStackSave - Whether llvm.stacksave has been called. Used to avoid
/// calling llvm.stacksave for multiple VLAs in the same scope.