summaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorBob Wilson <bob.wilson@apple.com>2009-11-22 03:58:57 +0000
committerBob Wilson <bob.wilson@apple.com>2009-11-22 03:58:57 +0000
commit2214dc07649d36e47d11914e1ffc7c56eb40ad73 (patch)
tree7681abaab8da58a814deacdd0f7bc5c22224f977 /utils
parentf27f115ef5d62b9dccfb0201da0008a8b8914cd3 (diff)
downloadllvm-2214dc07649d36e47d11914e1ffc7c56eb40ad73.tar.gz
llvm-2214dc07649d36e47d11914e1ffc7c56eb40ad73.tar.bz2
llvm-2214dc07649d36e47d11914e1ffc7c56eb40ad73.tar.xz
Fix pr5470. Tablegen handles template arguments by temporarily setting their
values, resolving references to them, and then removing the definitions. If a template argument is set to an undefined value, we need to resolve references to that argument to an explicit undefined value. The current code leaves the reference to the template argument as it is, which causes an assertion failure later when the definition of the template argument is removed. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@89581 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'utils')
-rw-r--r--utils/TableGen/Record.cpp28
1 files changed, 20 insertions, 8 deletions
diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp
index 7e84d008e6..fbe120759d 100644
--- a/utils/TableGen/Record.cpp
+++ b/utils/TableGen/Record.cpp
@@ -490,8 +490,11 @@ Init *ListInit::resolveListElementReference(Record &R, const RecordVal *IRV,
if (Elt >= getSize())
return 0; // Out of range reference.
Init *E = getElement(Elt);
- if (!dynamic_cast<UnsetInit*>(E)) // If the element is set
- return E; // Replace the VarListElementInit with it.
+ // If the element is set to some value, or if we are resolving a reference
+ // to a specific variable and that variable is explicitly unset, then
+ // replace the VarListElementInit with it.
+ if (IRV || !dynamic_cast<UnsetInit*>(E))
+ return E;
return 0;
}
@@ -1116,8 +1119,11 @@ Init *VarInit::resolveBitReference(Record &R, const RecordVal *IRV,
assert(Bit < BI->getNumBits() && "Bit reference out of range!");
Init *B = BI->getBit(Bit);
- if (!dynamic_cast<UnsetInit*>(B)) // If the bit is not set...
- return B; // Replace the VarBitInit with it.
+ // If the bit is set to some value, or if we are resolving a reference to a
+ // specific variable and that variable is explicitly unset, then replace the
+ // VarBitInit with it.
+ if (IRV || !dynamic_cast<UnsetInit*>(B))
+ return B;
return 0;
}
@@ -1138,8 +1144,11 @@ Init *VarInit::resolveListElementReference(Record &R, const RecordVal *IRV,
if (Elt >= LI->getSize())
return 0; // Out of range reference.
Init *E = LI->getElement(Elt);
- if (!dynamic_cast<UnsetInit*>(E)) // If the element is set
- return E; // Replace the VarListElementInit with it.
+ // If the element is set to some value, or if we are resolving a reference
+ // to a specific variable and that variable is explicitly unset, then
+ // replace the VarListElementInit with it.
+ if (IRV || !dynamic_cast<UnsetInit*>(E))
+ return E;
return 0;
}
@@ -1246,8 +1255,11 @@ Init *FieldInit::resolveListElementReference(Record &R, const RecordVal *RV,
if (Elt >= LI->getSize()) return 0;
Init *E = LI->getElement(Elt);
- if (!dynamic_cast<UnsetInit*>(E)) // If the bit is set...
- return E; // Replace the VarListElementInit with it.
+ // If the element is set to some value, or if we are resolving a
+ // reference to a specific variable and that variable is explicitly
+ // unset, then replace the VarListElementInit with it.
+ if (RV || !dynamic_cast<UnsetInit*>(E))
+ return E;
}
return 0;
}