Add an assertion that our use-marking actually covers all uses of a variable. The assertion doesn't cover quite as much as it should, but it's a good start, at least.

llvm-svn: 148625
This commit is contained in:
Eli Friedman 2012-01-21 04:52:58 +00:00
parent 02b5851823
commit 5720e34955
1 changed files with 7 additions and 0 deletions

View File

@ -1381,6 +1381,13 @@ LValue CodeGenFunction::EmitDeclRefLValue(const DeclRefExpr *E) {
CharUnits Alignment = getContext().getDeclAlign(ND); CharUnits Alignment = getContext().getDeclAlign(ND);
QualType T = E->getType(); 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>()) { if (ND->hasAttr<WeakRefAttr>()) {
const ValueDecl *VD = cast<ValueDecl>(ND); const ValueDecl *VD = cast<ValueDecl>(ND);
llvm::Constant *Aliasee = CGM.GetWeakRefReference(VD); llvm::Constant *Aliasee = CGM.GetWeakRefReference(VD);