зеркало из https://github.com/microsoft/clang-1.git
Remove false path where the default branch in a switch statement would
always be taken even if it was not feasible. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@50132 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Родитель
c66d0aa934
Коммит
5014ab113e
|
@ -562,6 +562,7 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
|
||||||
|
|
||||||
APSInt V1(bits, false);
|
APSInt V1(bits, false);
|
||||||
APSInt V2 = V1;
|
APSInt V2 = V1;
|
||||||
|
bool DefaultFeasible = false;
|
||||||
|
|
||||||
for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
|
for (iterator I = builder.begin(), EI = builder.end(); I != EI; ++I) {
|
||||||
|
|
||||||
|
@ -617,8 +618,10 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
|
||||||
isFeasible = false;
|
isFeasible = false;
|
||||||
StNew = Assume(DefaultSt, Res, false, isFeasible);
|
StNew = Assume(DefaultSt, Res, false, isFeasible);
|
||||||
|
|
||||||
if (isFeasible)
|
if (isFeasible) {
|
||||||
|
DefaultFeasible = true;
|
||||||
DefaultSt = StNew;
|
DefaultSt = StNew;
|
||||||
|
}
|
||||||
|
|
||||||
// Concretize the next value in the range.
|
// Concretize the next value in the range.
|
||||||
if (V1 == V2)
|
if (V1 == V2)
|
||||||
|
@ -632,7 +635,7 @@ void GRExprEngine::ProcessSwitch(SwitchNodeBuilder& builder) {
|
||||||
|
|
||||||
// If we reach here, than we know that the default branch is
|
// If we reach here, than we know that the default branch is
|
||||||
// possible.
|
// possible.
|
||||||
builder.generateDefaultCaseNode(DefaultSt);
|
if (DefaultFeasible) builder.generateDefaultCaseNode(DefaultSt);
|
||||||
}
|
}
|
||||||
|
|
||||||
//===----------------------------------------------------------------------===//
|
//===----------------------------------------------------------------------===//
|
||||||
|
|
Загрузка…
Ссылка в новой задаче