]> granicus.if.org Git - clang/commitdiff
Add an assertion that our use-marking actually covers all uses of a variable. The...
authorEli Friedman <eli.friedman@gmail.com>
Sat, 21 Jan 2012 04:52:58 +0000 (04:52 +0000)
committerEli Friedman <eli.friedman@gmail.com>
Sat, 21 Jan 2012 04:52:58 +0000 (04:52 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@148625 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/CGExpr.cpp

index 97a2f05466681028164e3326f81dee20c75b4c5e..db87cba9a0fb51077eea327de9ed57417be2df2c 100644 (file)
@@ -1381,6 +1381,13 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
   CharUnits Alignment = getContext().getDeclAlign(ND);
   QualType T = E->getType();
 
+  // FIXME: We should be able to assert this for FunctionDecls as well!
+  // FIXME: We should be able to assert this for all DeclRefExprs, not just
+  // those with a valid source location.
+  assert((ND->isUsed(false) || !isa<VarDecl>(ND) ||
+          !E->getLocation().isValid()) &&
+         "Should not use decl without marking it used!");
+
   if (ND->hasAttr<WeakRefAttr>()) {
     const ValueDecl *VD = cast<ValueDecl>(ND);
     llvm::Constant *Aliasee = CGM.GetWeakRefReference(VD);