Finally fix PR2189. This makes a fairly invasive but important change to
move getAsArrayType into ASTContext instead of being a method on type.
This is required because getAsArrayType(const AT), where AT is a typedef
for "int[10]" needs to return ArrayType(const int, 10).
Fixing this greatly simplifies getArrayDecayedType, which is a good sign.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@54317 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGDebugInfo.cpp b/lib/CodeGen/CGDebugInfo.cpp
index d232fd9..0b63463 100644
--- a/lib/CodeGen/CGDebugInfo.cpp
+++ b/lib/CodeGen/CGDebugInfo.cpp
@@ -108,10 +108,8 @@
delete GlobalVariableAnchor;
}
-void CGDebugInfo::setLocation(SourceLocation loc)
-{
- SourceManager &SM = M->getContext().getSourceManager();
- CurLoc = SM.getLogicalLoc(loc);
+void CGDebugInfo::setLocation(SourceLocation loc) {
+ CurLoc = M->getContext().getSourceManager().getLogicalLoc(loc);
}
/// getCastValueFor - Return a llvm representation for a given debug information
@@ -481,20 +479,20 @@
// Add the dimensions of the array.
std::vector<llvm::DebugInfoDesc *> &Elements = ArrayTy->getElements();
do {
+ const ArrayType *AT = M->getContext().getAsArrayType(type);
llvm::SubrangeDesc *Subrange = new llvm::SubrangeDesc();
// push it back on the subrange desc list so that we can free it later.
SubrangeDescList.push_back(Subrange);
uint64_t Upper = 0;
- if (type->getTypeClass() == Type::ConstantArray) {
- const ConstantArrayType *ConstArrTy = type->getAsConstantArrayType();
+ if (const ConstantArrayType *ConstArrTy = dyn_cast<ConstantArrayType>(AT)) {
Upper = ConstArrTy->getSize().getZExtValue() - 1;
}
Subrange->setLo(0);
Subrange->setHi(Upper);
Elements.push_back(Subrange);
- type = type->getAsArrayType()->getElementType();
+ type = AT->getElementType();
} while (type->isArrayType());
ArrayTy->setFromType(getOrCreateType(type, Unit));