diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-19 20:03:23 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2015-12-19 20:03:23 +0000 |
commit | e01e363fd9c5a93fe0a584a47a00703ae18090f4 (patch) | |
tree | c6bbd3bb4b1db671119ef34cb58afd2aa4f7d972 /llvm/lib/IR/Value.cpp | |
parent | 0334a047df7a1b9592221ac345e6c0663e56891d (diff) | |
download | bcm5719-llvm-e01e363fd9c5a93fe0a584a47a00703ae18090f4.tar.gz bcm5719-llvm-e01e363fd9c5a93fe0a584a47a00703ae18090f4.zip |
Assert that we have all use/users in the getters.
An error that is pretty easy to make is to use the lazy bitcode reader
and then do something like
if (V.use_empty())
The problem is that uses in unmaterialized functions are not accounted
for.
This patch adds asserts that all uses are known.
llvm-svn: 256105
Diffstat (limited to 'llvm/lib/IR/Value.cpp')
-rw-r--r-- | llvm/lib/IR/Value.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/lib/IR/Value.cpp b/llvm/lib/IR/Value.cpp index 925f2058e55..eb9deb6a07e 100644 --- a/llvm/lib/IR/Value.cpp +++ b/llvm/lib/IR/Value.cpp @@ -314,6 +314,16 @@ void Value::takeName(Value *V) { } #ifndef NDEBUG +void Value::assertModuleIsMaterialized() const { + const GlobalValue *GV = dyn_cast<GlobalValue>(this); + if (!GV) + return; + const Module *M = GV->getParent(); + if (!M) + return; + assert(M->isMaterialized()); +} + static bool contains(SmallPtrSetImpl<ConstantExpr *> &Cache, ConstantExpr *Expr, Constant *C) { if (!Cache.insert(Expr).second) |