summaryrefslogtreecommitdiffstats
path: root/clang/CodeGen/CodeGenTypes.cpp
diff options
context:
space:
mode:
authorSteve Naroff <snaroff@apple.com>2007-08-30 01:06:46 +0000
committerSteve Naroff <snaroff@apple.com>2007-08-30 01:06:46 +0000
commit5c13180a27eb60e146f86bbc7e2fcf2183255d0b (patch)
tree2e695e83378d6941c88d59210674407bbf144c29 /clang/CodeGen/CodeGenTypes.cpp
parent84ca3762ae59fac2d2a58aac4f904862063b8f86 (diff)
downloadbcm5719-llvm-5c13180a27eb60e146f86bbc7e2fcf2183255d0b.tar.gz
bcm5719-llvm-5c13180a27eb60e146f86bbc7e2fcf2183255d0b.zip
Fix the following redefinition errors submitted by Keith Bauer...
[dylan:~/llvm/tools/clang] admin% cat tentative_decls.c // incorrectly generates redefinition error extern int array[3]; int array[3]; // incorrectly generates a redefinition error extern void nup(int a[3]); void nup(int a[3]) {} It turns out that this exposed a fairly major flaw in the type system, array types were never getting uniqued! This is because all array types contained an expression, which aren't unique. To solve this, we now have 2 array types, ConstantArrayType and VariableArrayType. ConstantArrayType's are unique, VAT's aren't. This is a fairly extensive set of fundamental changes. Fortunately, all the tests pass. Nevertheless, there may be some collateral damage:-) If so, let me know! llvm-svn: 41592
Diffstat (limited to 'clang/CodeGen/CodeGenTypes.cpp')
-rw-r--r--clang/CodeGen/CodeGenTypes.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/clang/CodeGen/CodeGenTypes.cpp b/clang/CodeGen/CodeGenTypes.cpp
index 08c46b54bd0..85d55844b4e 100644
--- a/clang/CodeGen/CodeGenTypes.cpp
+++ b/clang/CodeGen/CodeGenTypes.cpp
@@ -83,23 +83,23 @@ const llvm::Type *CodeGenTypes::ConvertType(QualType T) {
return llvm::PointerType::get(ConvertType(R.getReferenceeType()));
}
- case Type::Array: {
- const ArrayType &A = cast<ArrayType>(Ty);
+ case Type::VariableArray: {
+ const VariableArrayType &A = cast<VariableArrayType>(Ty);
assert(A.getSizeModifier() == ArrayType::Normal &&
A.getIndexTypeQualifier() == 0 &&
"FIXME: We only handle trivial array types so far!");
-
- llvm::APSInt Size(32);
if (A.getSizeExpr() == 0) {
// int X[] -> [0 x int]
return llvm::ArrayType::get(ConvertType(A.getElementType()), 0);
- } else if (A.getSizeExpr()->isIntegerConstantExpr(Size, Context)) {
- const llvm::Type *EltTy = ConvertType(A.getElementType());
- return llvm::ArrayType::get(EltTy, Size.getZExtValue());
} else {
assert(0 && "FIXME: VLAs not implemented yet!");
}
}
+ case Type::ConstantArray: {
+ const ConstantArrayType &A = cast<ConstantArrayType>(Ty);
+ const llvm::Type *EltTy = ConvertType(A.getElementType());
+ return llvm::ArrayType::get(EltTy, A.getSize().getZExtValue());
+ }
case Type::OCUVector:
case Type::Vector: {
const VectorType &VT = cast<VectorType>(Ty);
OpenPOWER on IntegriCloud