summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/Record.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/TableGen/Record.cpp')
-rw-r--r--llvm/lib/TableGen/Record.cpp39
1 files changed, 20 insertions, 19 deletions
diff --git a/llvm/lib/TableGen/Record.cpp b/llvm/lib/TableGen/Record.cpp
index 990ef928f66..8b3ecebcf07 100644
--- a/llvm/lib/TableGen/Record.cpp
+++ b/llvm/lib/TableGen/Record.cpp
@@ -1517,36 +1517,37 @@ void Record::setName(Init *NewName) {
// this. See TGParser::ParseDef and TGParser::ParseDefm.
}
-void Record::resolveReferencesTo(const RecordVal *RV) {
- RecordResolver RecResolver(*this);
- RecordValResolver RecValResolver(*this, RV);
- Resolver *R;
- if (RV)
- R = &RecValResolver;
- else
- R = &RecResolver;
-
+void Record::resolveReferences(Resolver &R, const RecordVal *SkipVal) {
for (RecordVal &Value : Values) {
- if (RV == &Value) // Skip resolve the same field as the given one
+ if (SkipVal == &Value) // Skip resolve the same field as the given one
continue;
- if (Init *V = Value.getValue())
- if (Value.setValue(V->resolveReferences(*R)))
+ if (Init *V = Value.getValue()) {
+ Init *VR = V->resolveReferences(R);
+ if (Value.setValue(VR))
PrintFatalError(getLoc(), "Invalid value is found when setting '" +
- Value.getNameInitAsString() +
- "' after resolving references" +
- (RV ? " against '" + RV->getNameInitAsString() +
- "' of (" + RV->getValue()->getAsUnquotedString() +
- ")"
- : "") + "\n");
+ Value.getNameInitAsString() +
+ "' after resolving references: " +
+ VR->getAsUnquotedString() + "\n");
+ }
}
Init *OldName = getNameInit();
- Init *NewName = Name->resolveReferences(*R);
+ Init *NewName = Name->resolveReferences(R);
if (NewName != OldName) {
// Re-register with RecordKeeper.
setName(NewName);
}
}
+void Record::resolveReferences() {
+ RecordResolver R(*this);
+ resolveReferences(R);
+}
+
+void Record::resolveReferencesTo(const RecordVal *RV) {
+ RecordValResolver R(*this, RV);
+ resolveReferences(R, RV);
+}
+
#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
LLVM_DUMP_METHOD void Record::dump() const { errs() << *this; }
#endif
OpenPOWER on IntegriCloud