summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/TGParser.cpp
diff options
context:
space:
mode:
authorNicolai Haehnle <nhaehnle@gmail.com>2018-02-23 10:46:13 +0000
committerNicolai Haehnle <nhaehnle@gmail.com>2018-02-23 10:46:13 +0000
commitaecb68b54990fd888aebe7a9f6189b1ab00abfc6 (patch)
tree99ebbcab680e20e83e95e5d9876a38cae374fe45 /llvm/lib/TableGen/TGParser.cpp
parent0243aaf42c6c766ea64868b67357dc761ea95b99 (diff)
downloadbcm5719-llvm-aecb68b54990fd888aebe7a9f6189b1ab00abfc6.tar.gz
bcm5719-llvm-aecb68b54990fd888aebe7a9f6189b1ab00abfc6.zip
TableGen: Fix typeIsConvertibleTo for record types
Summary: Only check whether the left-hand side type is a subclass (or equal to) the right-hand side type. This requires a further fix in handling !if expressions and in type resolution. Furthermore, reverse the order of superclasses so that resolveTypes will find a least common ancestor at least in simple cases. Add a test that used to be accepted without flagging the obvious type error. Change-Id: Ib366db1a4e6a079f1a0851e469b402cddae76714 Reviewers: arsenm, craig.topper, tra, MartinO Subscribers: wdng, llvm-commits Differential Revision: https://reviews.llvm.org/D43559 llvm-svn: 325884
Diffstat (limited to 'llvm/lib/TableGen/TGParser.cpp')
-rw-r--r--llvm/lib/TableGen/TGParser.cpp17
1 files changed, 6 insertions, 11 deletions
diff --git a/llvm/lib/TableGen/TGParser.cpp b/llvm/lib/TableGen/TGParser.cpp
index 72ab8d3838d..86344d33450 100644
--- a/llvm/lib/TableGen/TGParser.cpp
+++ b/llvm/lib/TableGen/TGParser.cpp
@@ -198,6 +198,8 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
// Since everything went well, we can now set the "superclass" list for the
// current record.
+ CurRec->addSuperClass(SC, SubClass.RefRange);
+
ArrayRef<std::pair<Record *, SMRange>> SCs = SC->getSuperClasses();
for (const auto &SCPair : SCs) {
if (CurRec->isSubClassOf(SCPair.first))
@@ -205,11 +207,6 @@ bool TGParser::AddSubClass(Record *CurRec, SubClassReference &SubClass) {
"Already subclass of '" + SCPair.first->getName() + "'!\n");
CurRec->addSuperClass(SCPair.first, SCPair.second);
}
-
- if (CurRec->isSubClassOf(SC))
- return Error(SubClass.RefRange.Start,
- "Already subclass of '" + SC->getName() + "'!\n");
- CurRec->addSuperClass(SC, SubClass.RefRange);
return false;
}
@@ -1067,12 +1064,10 @@ Init *TGParser::ParseOperation(Record *CurRec, RecTy *ItemType) {
return nullptr;
}
- if (MHSTy->typeIsConvertibleTo(RHSTy)) {
- Type = RHSTy;
- } else if (RHSTy->typeIsConvertibleTo(MHSTy)) {
- Type = MHSTy;
- } else {
- TokError("inconsistent types for !if");
+ Type = resolveTypes(MHSTy, RHSTy);
+ if (!Type) {
+ TokError(Twine("inconsistent types '") + MHSTy->getAsString() +
+ "' and '" + RHSTy->getAsString() + "' for !if");
return nullptr;
}
break;
OpenPOWER on IntegriCloud