[demangler][NFC] Tweak legacy uuidof handling
We have to special-case 'u 8__uuidof [tz]' demangling for legacy support. That handling is a little duplicative. * It seems better to just push the single expected node. * We can also use 'consumeIf' rather than open-coding the peeking and increment. * We don't need the numLeft < 2 check, as if there are few than that other paths will end up with detecting the error. FWIW This simplifies a future change adding operator precedence. Reviewed By: ChuanqiXu Differential Revision: https://reviews.llvm.org/D119543
This commit is contained in:
parent
995c4f3068
commit
880e87580a
@ -5032,30 +5032,29 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
|
|||||||
// interpreted as <type> node 'short' or 'ellipsis'. However, neither
|
// interpreted as <type> node 'short' or 'ellipsis'. However, neither
|
||||||
// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
|
// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
|
||||||
// actual conflict here.
|
// actual conflict here.
|
||||||
|
bool IsUUID = false;
|
||||||
|
Node *UUID = nullptr;
|
||||||
if (Name->getBaseName() == "__uuidof") {
|
if (Name->getBaseName() == "__uuidof") {
|
||||||
if (numLeft() < 2)
|
if (consumeIf('t')) {
|
||||||
return nullptr;
|
UUID = getDerived().parseType();
|
||||||
if (*First == 't') {
|
IsUUID = true;
|
||||||
++First;
|
} else if (consumeIf('z')) {
|
||||||
Node *Ty = getDerived().parseType();
|
UUID = getDerived().parseExpr();
|
||||||
if (!Ty)
|
IsUUID = true;
|
||||||
return nullptr;
|
|
||||||
return make<CallExpr>(Name, makeNodeArray(&Ty, &Ty + 1));
|
|
||||||
}
|
|
||||||
if (*First == 'z') {
|
|
||||||
++First;
|
|
||||||
Node *Ex = getDerived().parseExpr();
|
|
||||||
if (!Ex)
|
|
||||||
return nullptr;
|
|
||||||
return make<CallExpr>(Name, makeNodeArray(&Ex, &Ex + 1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t ExprsBegin = Names.size();
|
size_t ExprsBegin = Names.size();
|
||||||
while (!consumeIf('E')) {
|
if (IsUUID) {
|
||||||
Node *E = getDerived().parseTemplateArg();
|
if (UUID == nullptr)
|
||||||
if (E == nullptr)
|
return nullptr;
|
||||||
return E;
|
Names.push_back(UUID);
|
||||||
Names.push_back(E);
|
} else {
|
||||||
|
while (!consumeIf('E')) {
|
||||||
|
Node *E = getDerived().parseTemplateArg();
|
||||||
|
if (E == nullptr)
|
||||||
|
return E;
|
||||||
|
Names.push_back(E);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin));
|
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin));
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5032,30 +5032,29 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExpr() {
|
|||||||
// interpreted as <type> node 'short' or 'ellipsis'. However, neither
|
// interpreted as <type> node 'short' or 'ellipsis'. However, neither
|
||||||
// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
|
// __uuidof(short) nor __uuidof(...) can actually appear, so there is no
|
||||||
// actual conflict here.
|
// actual conflict here.
|
||||||
|
bool IsUUID = false;
|
||||||
|
Node *UUID = nullptr;
|
||||||
if (Name->getBaseName() == "__uuidof") {
|
if (Name->getBaseName() == "__uuidof") {
|
||||||
if (numLeft() < 2)
|
if (consumeIf('t')) {
|
||||||
return nullptr;
|
UUID = getDerived().parseType();
|
||||||
if (*First == 't') {
|
IsUUID = true;
|
||||||
++First;
|
} else if (consumeIf('z')) {
|
||||||
Node *Ty = getDerived().parseType();
|
UUID = getDerived().parseExpr();
|
||||||
if (!Ty)
|
IsUUID = true;
|
||||||
return nullptr;
|
|
||||||
return make<CallExpr>(Name, makeNodeArray(&Ty, &Ty + 1));
|
|
||||||
}
|
|
||||||
if (*First == 'z') {
|
|
||||||
++First;
|
|
||||||
Node *Ex = getDerived().parseExpr();
|
|
||||||
if (!Ex)
|
|
||||||
return nullptr;
|
|
||||||
return make<CallExpr>(Name, makeNodeArray(&Ex, &Ex + 1));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
size_t ExprsBegin = Names.size();
|
size_t ExprsBegin = Names.size();
|
||||||
while (!consumeIf('E')) {
|
if (IsUUID) {
|
||||||
Node *E = getDerived().parseTemplateArg();
|
if (UUID == nullptr)
|
||||||
if (E == nullptr)
|
return nullptr;
|
||||||
return E;
|
Names.push_back(UUID);
|
||||||
Names.push_back(E);
|
} else {
|
||||||
|
while (!consumeIf('E')) {
|
||||||
|
Node *E = getDerived().parseTemplateArg();
|
||||||
|
if (E == nullptr)
|
||||||
|
return E;
|
||||||
|
Names.push_back(E);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin));
|
return make<CallExpr>(Name, popTrailingNodeArray(ExprsBegin));
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user