Skip to content

Commit

Permalink
Update LLVM lib/Demangle from r371274 to r371469
Browse files Browse the repository at this point in the history
New:
  - [itanium] bug fixes for C++20 lambda expression extensions

Ran:

  cp ~/src/llvm-project/llvm/include/llvm/Demangle/*.h third_party/llvm/include/llvm/Demangle/
  cp ~/src/llvm-project/llvm/lib/Demangle/*.cpp third_party/llvm/lib/Demangle/
  cp ~/src/llvm-project/llvm/LICENSE.TXT third_party/llvm/LICENSE.txt

Related to #8.
  • Loading branch information
nico committed Sep 10, 2019
1 parent 6b6cb51 commit 3ee555c
Showing 1 changed file with 16 additions and 48 deletions.
64 changes: 16 additions & 48 deletions third_party/llvm/include/llvm/Demangle/ItaniumDemangle.h
Original file line number Diff line number Diff line change
Expand Up @@ -2063,16 +2063,15 @@ class StringLiteral : public Node {
class LambdaExpr : public Node {
const Node *Type;

void printLambdaDeclarator(OutputStream &S) const;

public:
LambdaExpr(const Node *Type_) : Node(KLambdaExpr), Type(Type_) {}

template<typename Fn> void match(Fn F) const { F(Type); }

void printLeft(OutputStream &S) const override {
S += "[]";
printLambdaDeclarator(S);
if (Type->getKind() == KClosureTypeName)
static_cast<const ClosureTypeName *>(Type)->printDeclarator(S);
S += "{...}";
}
};
Expand Down Expand Up @@ -2209,39 +2208,6 @@ FOR_EACH_NODE_KIND(SPECIALIZATION)

#undef FOR_EACH_NODE_KIND

inline void LambdaExpr::printLambdaDeclarator(OutputStream &S) const {
struct LambdaDeclaratorPrinter {
OutputStream &S;
void operator()(const ClosureTypeName *LambdaType) {
LambdaType->printDeclarator(S);
}

// Walk through any qualifiers to find the lambda-expression.
void operator()(const SpecialName *Name) {
Name->match([&](StringView, const Node *Name) { Name->visit(*this); });
}
void operator()(const NestedName *Name) {
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
}
void operator()(const LocalName *Name) {
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
}
void operator()(const QualifiedName *Name) {
Name->match([&](const Node *, const Node *Name) { Name->visit(*this); });
}
void operator()(const GlobalQualifiedName *Name) {
Name->match([&](const Node *Child) { Child->visit(*this); });
}
void operator()(const StdQualifiedName *Name) {
Name->match([&](const Node *Child) { Child->visit(*this); });
}
void operator()(const Node *) {
// If we can't find the lambda type, just print '[]{...}'.
}
};
return Type->visit(LambdaDeclaratorPrinter{S});
}

template <class T, size_t N>
class PODSmallVector {
static_assert(std::is_pod<T>::value,
Expand Down Expand Up @@ -2392,9 +2358,6 @@ template <typename Derived, typename Alloc> struct AbstractManglingParser {
assert(Parser->TemplateParams.size() >= OldNumTemplateParamLists);
Parser->TemplateParams.dropBack(OldNumTemplateParamLists);
}
void push_back(Node *Param) {
Params.push_back(Param);
}
};

// Template parameter table. Like the above, but referenced like "T42_".
Expand Down Expand Up @@ -2736,7 +2699,6 @@ AbstractManglingParser<Derived, Alloc>::parseUnnamedTypeName(NameState *State) {
Node *T = parseTemplateParamDecl();
if (!T)
return nullptr;
LambdaTemplateParams.push_back(T);
Names.push_back(T);
}
NodeArray TempParams = popTrailingNodeArray(ParamsBegin);
Expand Down Expand Up @@ -4324,20 +4286,26 @@ Node *AbstractManglingParser<Derived, Alloc>::parseExprPrimary() {
// Invalid mangled name per
// http://sourcerytools.com/pipermail/cxx-abi-dev/2011-August/002422.html
return nullptr;
case 'U': {
// FIXME: Should we support LUb... for block literals?
if (look(1) != 'l')
return nullptr;
Node *T = parseUnnamedTypeName(nullptr);
if (!T || !consumeIf('E'))
return nullptr;
return make<LambdaExpr>(T);
}
default: {
// might be named type
Node *T = getDerived().parseType();
if (T == nullptr)
return nullptr;
StringView N = parseNumber();
if (!N.empty()) {
if (!consumeIf('E'))
return nullptr;
return make<IntegerCastExpr>(T, N);
}
if (consumeIf('E'))
return make<LambdaExpr>(T);
return nullptr;
if (N.empty())
return nullptr;
if (!consumeIf('E'))
return nullptr;
return make<IntegerCastExpr>(T, N);
}
}
}
Expand Down

0 comments on commit 3ee555c

Please sign in to comment.