Skip to content

Commit be046e8

Browse files
committed
Add more tests and clarify the visibility
1 parent 78aca78 commit be046e8

File tree

4 files changed

+14
-5
lines changed

4 files changed

+14
-5
lines changed

llvm/docs/TableGen/ProgRef.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1842,6 +1842,9 @@ and non-0 as true.
18421842
will be included. The format of *regex* is ERE (Extended POSIX Regular
18431843
Expressions).
18441844

1845+
Only these records that can be seen when class record is instantiated will
1846+
be considered.
1847+
18451848
``!interleave(``\ *list*\ ``,`` *delim*\ ``)``
18461849
This operator concatenates the items in the *list*, interleaving the
18471850
*delim* string between each pair, and produces the resulting string.

llvm/include/llvm/TableGen/Record.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1217,7 +1217,7 @@ class InstancesOpInit final : public TypedInit, public FoldingSetNode {
12171217

12181218
void Profile(FoldingSetNodeID &ID) const;
12191219

1220-
const Init *Fold() const;
1220+
const Init *Fold(const Record *CurRec, bool IsFinal = false) const;
12211221

12221222
bool isComplete() const override { return false; }
12231223

@@ -2018,6 +2018,9 @@ class RecordKeeper {
20182018
bool Ins = Defs.try_emplace(std::string(R->getName()), std::move(R)).second;
20192019
(void)Ins;
20202020
assert(Ins && "Record already exists");
2021+
// Clear cache
2022+
if (!Cache.empty())
2023+
Cache.clear();
20212024
}
20222025

20232026
void addExtraGlobal(StringRef Name, const Init *I) {

llvm/lib/TableGen/Record.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2247,7 +2247,10 @@ void InstancesOpInit::Profile(FoldingSetNodeID &ID) const {
22472247
ProfileInstancesOpInit(ID, Type, Regex);
22482248
}
22492249

2250-
const Init *InstancesOpInit::Fold() const {
2250+
const Init *InstancesOpInit::Fold(const Record *CurRec, bool IsFinal) const {
2251+
if (CurRec && !IsFinal)
2252+
return this;
2253+
22512254
const auto *RegexInit = dyn_cast<StringInit>(Regex);
22522255
if (!RegexInit)
22532256
return this;
@@ -2268,8 +2271,8 @@ const Init *InstancesOpInit::Fold() const {
22682271

22692272
const Init *InstancesOpInit::resolveReferences(Resolver &R) const {
22702273
const Init *NewRegex = Regex->resolveReferences(R);
2271-
if (Regex != NewRegex)
2272-
return get(Type, NewRegex)->Fold();
2274+
if (Regex != NewRegex || R.isFinal())
2275+
return get(Type, NewRegex)->Fold(R.getCurrentRecord(), R.isFinal());
22732276
return this;
22742277
}
22752278

llvm/lib/TableGen/TGParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1495,7 +1495,7 @@ const Init *TGParser::ParseOperation(Record *CurRec, const RecTy *ItemType) {
14951495
return nullptr;
14961496
}
14971497

1498-
return InstancesOpInit::get(Type, Regex)->Fold();
1498+
return InstancesOpInit::get(Type, Regex)->Fold(CurRec);
14991499
}
15001500

15011501
case tgtok::XConcat:

0 commit comments

Comments
 (0)