diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-02-05 06:37:34 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-02-05 06:37:34 +0000 |
| commit | b977b6a59b768dd0507abd3c152b562e24b79306 (patch) | |
| tree | 2c7d948a81680c184acb6811e3ce7be10cd3e4ad /clang/CodeGen/CodeGenModule.cpp | |
| parent | f4ed277135dbee2a4295c338464f4de7a4498aad (diff) | |
| download | bcm5719-llvm-b977b6a59b768dd0507abd3c152b562e24b79306.tar.gz bcm5719-llvm-b977b6a59b768dd0507abd3c152b562e24b79306.zip | |
Relax an assertion, fixing PR1968
llvm-svn: 46742
Diffstat (limited to 'clang/CodeGen/CodeGenModule.cpp')
| -rw-r--r-- | clang/CodeGen/CodeGenModule.cpp | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/clang/CodeGen/CodeGenModule.cpp b/clang/CodeGen/CodeGenModule.cpp index 382f651272f..9de5d3426f0 100644 --- a/clang/CodeGen/CodeGenModule.cpp +++ b/clang/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. |

