diff options
author | Jordy Rose <jediknil@belkadan.com> | 2010-06-04 01:14:56 +0000 |
---|---|---|
committer | Jordy Rose <jediknil@belkadan.com> | 2010-06-04 01:14:56 +0000 |
commit | 2e2226890403383daea4100958cf07493178cf7f (patch) | |
tree | 8e252cb320eaf261798a0ec85cafe1e4aa69bd98 /clang/lib/Analysis/LiveVariables.cpp | |
parent | b190a2c74a1fe8b1078b293b2621cbfc52ef59f4 (diff) | |
download | bcm5719-llvm-2e2226890403383daea4100958cf07493178cf7f.tar.gz bcm5719-llvm-2e2226890403383daea4100958cf07493178cf7f.zip |
Assignments to reference variables shouldn't kill the variable.
llvm-svn: 105452
Diffstat (limited to 'clang/lib/Analysis/LiveVariables.cpp')
-rw-r--r-- | clang/lib/Analysis/LiveVariables.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/clang/lib/Analysis/LiveVariables.cpp b/clang/lib/Analysis/LiveVariables.cpp index 01a36a1074e..4efe25ea1e0 100644 --- a/clang/lib/Analysis/LiveVariables.cpp +++ b/clang/lib/Analysis/LiveVariables.cpp @@ -256,17 +256,21 @@ void TransferFuncs::VisitAssign(BinaryOperator* B) { // Assigning to a variable? if (DeclRefExpr* DR = dyn_cast<DeclRefExpr>(LHS->IgnoreParens())) { + // Assignments to references don't kill the ref's address + if (DR->getDecl()->getType()->isReferenceType()) { + VisitDeclRefExpr(DR); + } else { + // Update liveness inforamtion. + unsigned bit = AD.getIdx(DR->getDecl()); + LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit); - // Update liveness inforamtion. - unsigned bit = AD.getIdx(DR->getDecl()); - LiveState.getDeclBit(bit) = Dead | AD.AlwaysLive.getDeclBit(bit); - - if (AD.Observer) { AD.Observer->ObserverKill(DR); } + if (AD.Observer) { AD.Observer->ObserverKill(DR); } - // Handle things like +=, etc., which also generate "uses" - // of a variable. Do this just by visiting the subexpression. - if (B->getOpcode() != BinaryOperator::Assign) - VisitDeclRefExpr(DR); + // Handle things like +=, etc., which also generate "uses" + // of a variable. Do this just by visiting the subexpression. + if (B->getOpcode() != BinaryOperator::Assign) + VisitDeclRefExpr(DR); + } } else // Not assigning to a variable. Process LHS as usual. Visit(LHS); |