aboutsummaryrefslogtreecommitdiff
path: root/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2008-02-05 06:37:34 +0000
committerChris Lattner <sabre@nondot.org>2008-02-05 06:37:34 +0000
commitc4b23a530b04ee77b56772a70191d32119eadc3e (patch)
tree74c0ba63bd02a50217bc8e3cb6fad482c5921fa6 /CodeGen/CodeGenModule.cpp
parent768ad16a4ab79fbc52f6f3bdc9362fd4e1d51d53 (diff)
Relax an assertion, fixing PR1968
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46742 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'CodeGen/CodeGenModule.cpp')
-rw-r--r--CodeGen/CodeGenModule.cpp13
1 files changed, 12 insertions, 1 deletions
diff --git a/CodeGen/CodeGenModule.cpp b/CodeGen/CodeGenModule.cpp
index 382f651272..9de5d3426f 100644
--- a/CodeGen/CodeGenModule.cpp
+++ b/CodeGen/CodeGenModule.cpp
@@ -123,6 +123,12 @@ llvm::Constant *CodeGenModule::GetAddrOfFunctionDecl(const FunctionDecl *D,
return Entry = NewFn;
}
+static bool IsZeroElementArray(const llvm::Type *Ty) {
+ if (const llvm::ArrayType *ATy = dyn_cast<llvm::ArrayType>(Ty))
+ return ATy->getNumElements() == 0;
+ return false;
+}
+
llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
bool isDefinition) {
assert(D->hasGlobalStorage() && "Not a global variable");
@@ -178,8 +184,13 @@ llvm::Constant *CodeGenModule::GetAddrOfGlobalVar(const VarDecl *D,
// is incredibly slow!
ReplaceMapValuesWith(GV, NewPtrForOldDecl);
+ // Verify that GV was a declaration or something like x[] which turns into
+ // [0 x type].
+ assert((GV->isDeclaration() ||
+ IsZeroElementArray(GV->getType()->getElementType())) &&
+ "Shouldn't replace non-declaration");
+
// Ok, delete the old global now, which is dead.
- assert(GV->isDeclaration() && "Shouldn't replace non-declaration");
GV->eraseFromParent();
// Return the new global which has the right type.