Fixes PR33569.
llvm-svn: 328462
// FIXME: (possibly) incomplete list of features that clang mangles that this
// file does not yet support:
-// - enable_if attribute
// - C++ modules TS
// - All C++14 and C++17 features
KElaboratedTypeSpefType,
KNameType,
KAbiTagAttr,
+ KEnableIfAttr,
KObjCProtoName,
KPointerType,
KLValueReferenceType,
}
};
+class EnableIfAttr : public Node {
+ NodeArray Conditions;
+public:
+ EnableIfAttr(NodeArray Conditions_)
+ : Node(KEnableIfAttr), Conditions(Conditions_) {}
+
+ void printLeft(OutputStream &S) const override {
+ S += " [enable_if:";
+ Conditions.printWithComma(S);
+ S += ']';
+ }
+};
+
class ObjCProtoName : public Node {
Node *Ty;
StringView Protocol;
const Node *Ret;
const Node *Name;
NodeArray Params;
+ Node *Attrs;
Qualifiers CVQuals;
FunctionRefQual RefQual;
public:
FunctionEncoding(Node *Ret_, Node *Name_, NodeArray Params_,
- Qualifiers CVQuals_, FunctionRefQual RefQual_)
+ Node *Attrs_, Qualifiers CVQuals_, FunctionRefQual RefQual_)
: Node(KFunctionEncoding, NoParameterPack,
/*RHSComponentCache=*/Cache::Yes, /*ArrayCache=*/Cache::No,
/*FunctionCache=*/Cache::Yes),
- Ret(Ret_), Name(Name_), Params(Params_), CVQuals(CVQuals_),
- RefQual(RefQual_) {
+ Ret(Ret_), Name(Name_), Params(Params_), Attrs(Attrs_),
+ CVQuals(CVQuals_), RefQual(RefQual_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
if (Ret)
S += " &";
else if (RefQual == FrefQualRValue)
S += " &&";
+
+ if (Attrs != nullptr)
+ Attrs->print(S);
}
};
TagTemplates = false;
+ Node *Attrs = nullptr;
+ if (consumeIf("Ua9enable_ifI")) {
+ size_t BeforeArgs = Names.size();
+ while (!consumeIf('E')) {
+ Node *Arg = parseTemplateArg();
+ if (Arg == nullptr)
+ return nullptr;
+ Names.push_back(Arg);
+ }
+ Attrs = make<EnableIfAttr>(popTrailingNodeArray(BeforeArgs));
+ }
+
Node *ReturnType = nullptr;
if (!NameInfo.CtorDtorConversion && NameInfo.EndsWithTemplateArgs) {
ReturnType = parseType();
if (consumeIf('v'))
return make<FunctionEncoding>(ReturnType, Name, NodeArray(),
- NameInfo.CVQualifiers,
+ Attrs, NameInfo.CVQualifiers,
NameInfo.ReferenceQualifier);
size_t ParamsBegin = Names.size();
return make<FunctionEncoding>(ReturnType, Name,
popTrailingNodeArray(ParamsBegin),
- NameInfo.CVQualifiers,
+ Attrs, NameInfo.CVQualifiers,
NameInfo.ReferenceQualifier);
}
{"_ZGR1bIvE2_", "reference temporary for b<void>"},
{"_ZZ18test_assign_throwsI20small_throws_on_copyLb0EEvvENKUlRNSt3__13anyEOT_E_clIRS0_EEDaS3_S5_", "auto void test_assign_throws<small_throws_on_copy, false>()::'lambda'(std::__1::any&, auto&&)::operator()<small_throws_on_copy&>(std::__1::any&, auto&&) const"},
+
+ // enable_if attributes:
+ {"_Z1fUa9enable_ifIXLi1EEEv", "f() [enable_if:1]"},
+ {"_ZN5test4IdE1fEUa9enable_ifIXeqfL0p_Li1EEXeqfL0p0_Li2EEEi", "test4<double>::f(int) [enable_if:(fp) == (1), (fp0) == (2)]"},
+ {"_Z3quxUa9enable_ifIXLi1EEXL_Z9TRUEFACTSEEEi", "qux(int) [enable_if:1, TRUEFACTS]"},
};
const unsigned N = sizeof(cases) / sizeof(cases[0]);
}
const char *xfail_cases[] = {
- "_Z1fUa9enable_ifIXLi1EEEv", // enable_if attribute
"_ZW6FooBarE2f3v", // C++ modules TS
// FIXME: Why does clang generate the "cp" expr?
// FIXME: (possibly) incomplete list of features that clang mangles that this
// file does not yet support:
-// - enable_if attribute
// - C++ modules TS
// - All C++14 and C++17 features
KElaboratedTypeSpefType,
KNameType,
KAbiTagAttr,
+ KEnableIfAttr,
KObjCProtoName,
KPointerType,
KLValueReferenceType,
}
};
+class EnableIfAttr : public Node {
+ NodeArray Conditions;
+public:
+ EnableIfAttr(NodeArray Conditions_)
+ : Node(KEnableIfAttr), Conditions(Conditions_) {}
+
+ void printLeft(OutputStream &S) const override {
+ S += " [enable_if:";
+ Conditions.printWithComma(S);
+ S += ']';
+ }
+};
+
class ObjCProtoName : public Node {
Node *Ty;
StringView Protocol;
const Node *Ret;
const Node *Name;
NodeArray Params;
+ Node *Attrs;
Qualifiers CVQuals;
FunctionRefQual RefQual;
public:
FunctionEncoding(Node *Ret_, Node *Name_, NodeArray Params_,
- Qualifiers CVQuals_, FunctionRefQual RefQual_)
+ Node *Attrs_, Qualifiers CVQuals_, FunctionRefQual RefQual_)
: Node(KFunctionEncoding, NoParameterPack,
/*RHSComponentCache=*/Cache::Yes, /*ArrayCache=*/Cache::No,
/*FunctionCache=*/Cache::Yes),
- Ret(Ret_), Name(Name_), Params(Params_), CVQuals(CVQuals_),
- RefQual(RefQual_) {
+ Ret(Ret_), Name(Name_), Params(Params_), Attrs(Attrs_),
+ CVQuals(CVQuals_), RefQual(RefQual_) {
for (Node *P : Params)
ParameterPackSize = std::min(ParameterPackSize, P->ParameterPackSize);
if (Ret)
S += " &";
else if (RefQual == FrefQualRValue)
S += " &&";
+
+ if (Attrs != nullptr)
+ Attrs->print(S);
}
};
TagTemplates = false;
+ Node *Attrs = nullptr;
+ if (consumeIf("Ua9enable_ifI")) {
+ size_t BeforeArgs = Names.size();
+ while (!consumeIf('E')) {
+ Node *Arg = parseTemplateArg();
+ if (Arg == nullptr)
+ return nullptr;
+ Names.push_back(Arg);
+ }
+ Attrs = make<EnableIfAttr>(popTrailingNodeArray(BeforeArgs));
+ }
+
Node *ReturnType = nullptr;
if (!NameInfo.CtorDtorConversion && NameInfo.EndsWithTemplateArgs) {
ReturnType = parseType();
if (consumeIf('v'))
return make<FunctionEncoding>(ReturnType, Name, NodeArray(),
- NameInfo.CVQualifiers,
+ Attrs, NameInfo.CVQualifiers,
NameInfo.ReferenceQualifier);
size_t ParamsBegin = Names.size();
return make<FunctionEncoding>(ReturnType, Name,
popTrailingNodeArray(ParamsBegin),
- NameInfo.CVQualifiers,
+ Attrs, NameInfo.CVQualifiers,
NameInfo.ReferenceQualifier);
}