forked from OSchip/llvm-project
Use property-based serialization for DeclarationName.
This commit is contained in:
parent
efd0dfbd70
commit
867570a238
|
@ -197,48 +197,6 @@ public:
|
|||
return FunctionProtoType::ExtParameterInfo::getFromOpaqueValue(value);
|
||||
}
|
||||
|
||||
DeclarationName readDeclarationName() {
|
||||
auto &ctx = getASTContext();
|
||||
auto kind = asImpl().readDeclarationNameKind();
|
||||
switch (kind) {
|
||||
case DeclarationName::Identifier:
|
||||
return DeclarationName(asImpl().readIdentifier());
|
||||
|
||||
case DeclarationName::ObjCZeroArgSelector:
|
||||
case DeclarationName::ObjCOneArgSelector:
|
||||
case DeclarationName::ObjCMultiArgSelector:
|
||||
return DeclarationName(asImpl().readSelector());
|
||||
|
||||
case DeclarationName::CXXConstructorName:
|
||||
return ctx.DeclarationNames.getCXXConstructorName(
|
||||
ctx.getCanonicalType(asImpl().readQualType()));
|
||||
|
||||
case DeclarationName::CXXDestructorName:
|
||||
return ctx.DeclarationNames.getCXXDestructorName(
|
||||
ctx.getCanonicalType(asImpl().readQualType()));
|
||||
|
||||
case DeclarationName::CXXConversionFunctionName:
|
||||
return ctx.DeclarationNames.getCXXConversionFunctionName(
|
||||
ctx.getCanonicalType(asImpl().readQualType()));
|
||||
|
||||
case DeclarationName::CXXDeductionGuideName:
|
||||
return ctx.DeclarationNames.getCXXDeductionGuideName(
|
||||
asImpl().readTemplateDeclRef());
|
||||
|
||||
case DeclarationName::CXXOperatorName:
|
||||
return ctx.DeclarationNames.getCXXOperatorName(
|
||||
asImpl().readOverloadedOperatorKind());
|
||||
|
||||
case DeclarationName::CXXLiteralOperatorName:
|
||||
return ctx.DeclarationNames.getCXXLiteralOperatorName(
|
||||
asImpl().readIdentifier());
|
||||
|
||||
case DeclarationName::CXXUsingDirective:
|
||||
return DeclarationName::getUsingDirectiveName();
|
||||
}
|
||||
llvm_unreachable("bad name kind");
|
||||
}
|
||||
|
||||
TemplateName readTemplateName() {
|
||||
auto &ctx = getASTContext();
|
||||
auto kind = asImpl().readTemplateNameKind();
|
||||
|
|
|
@ -178,44 +178,6 @@ public:
|
|||
asImpl().writeUInt32(epi.getOpaqueValue());
|
||||
}
|
||||
|
||||
void writeDeclarationName(DeclarationName name) {
|
||||
asImpl().writeDeclarationNameKind(name.getNameKind());
|
||||
switch (name.getNameKind()) {
|
||||
case DeclarationName::Identifier:
|
||||
asImpl().writeIdentifier(name.getAsIdentifierInfo());
|
||||
return;
|
||||
|
||||
case DeclarationName::ObjCZeroArgSelector:
|
||||
case DeclarationName::ObjCOneArgSelector:
|
||||
case DeclarationName::ObjCMultiArgSelector:
|
||||
asImpl().writeSelector(name.getObjCSelector());
|
||||
return;
|
||||
|
||||
case DeclarationName::CXXConstructorName:
|
||||
case DeclarationName::CXXDestructorName:
|
||||
case DeclarationName::CXXConversionFunctionName:
|
||||
asImpl().writeQualType(name.getCXXNameType());
|
||||
return;
|
||||
|
||||
case DeclarationName::CXXDeductionGuideName:
|
||||
asImpl().writeDeclRef(name.getCXXDeductionGuideTemplate());
|
||||
return;
|
||||
|
||||
case DeclarationName::CXXOperatorName:
|
||||
asImpl().writeOverloadedOperatorKind(name.getCXXOverloadedOperator());
|
||||
return;
|
||||
|
||||
case DeclarationName::CXXLiteralOperatorName:
|
||||
asImpl().writeIdentifier(name.getCXXLiteralIdentifier());
|
||||
return;
|
||||
|
||||
case DeclarationName::CXXUsingDirective:
|
||||
// No extra data to emit
|
||||
return;
|
||||
}
|
||||
llvm_unreachable("bad name kind");
|
||||
}
|
||||
|
||||
void writeTemplateName(TemplateName name) {
|
||||
asImpl().writeTemplateNameKind(name.getKind());
|
||||
switch (name.getKind()) {
|
||||
|
|
|
@ -211,3 +211,64 @@ class PropertyTypeCase<PropertyType type, string name> : HasProperties {
|
|||
string Name = name;
|
||||
}
|
||||
|
||||
// DeclarationName
|
||||
def : PropertyTypeKind<DeclarationName, DeclarationNameKind,
|
||||
"node.getNameKind()">;
|
||||
let Class = PropertyTypeCase<DeclarationName, "Identifier"> in {
|
||||
def : Property<"identifier", Identifier> {
|
||||
let Read = [{ node.getAsIdentifierInfo() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return DeclarationName(identifier);
|
||||
}]>;
|
||||
}
|
||||
foreach count = ["Zero", "One", "Multi"] in {
|
||||
let Class = PropertyTypeCase<DeclarationName, "ObjC"#count#"ArgSelector"> in {
|
||||
def : Property<"selector", Selector> {
|
||||
let Read = [{ node.getObjCSelector() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return DeclarationName(selector);
|
||||
}]>;
|
||||
}
|
||||
}
|
||||
foreach kind = ["Constructor", "Destructor", "ConversionFunction"] in {
|
||||
let Class = PropertyTypeCase<DeclarationName, "CXX"#kind#"Name"> in {
|
||||
def : Property<"type", QualType> {
|
||||
let Read = [{ node.getCXXNameType() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return ctx.DeclarationNames.getCXX}]#kind#[{Name(
|
||||
ctx.getCanonicalType(type));
|
||||
}]>;
|
||||
}
|
||||
}
|
||||
let Class = PropertyTypeCase<DeclarationName, "CXXDeductionGuideName"> in {
|
||||
def : Property<"declaration", TemplateDeclRef> {
|
||||
let Read = [{ node.getCXXDeductionGuideTemplate() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return ctx.DeclarationNames.getCXXDeductionGuideName(declaration);
|
||||
}]>;
|
||||
}
|
||||
let Class = PropertyTypeCase<DeclarationName, "CXXOperatorName"> in {
|
||||
def : Property<"operatorKind", OverloadedOperatorKind> {
|
||||
let Read = [{ node.getCXXOverloadedOperator() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return ctx.DeclarationNames.getCXXOperatorName(operatorKind);
|
||||
}]>;
|
||||
}
|
||||
let Class = PropertyTypeCase<DeclarationName, "CXXLiteralOperatorName"> in {
|
||||
def : Property<"identifier", Identifier> {
|
||||
let Read = [{ node.getCXXLiteralIdentifier() }];
|
||||
}
|
||||
def : Creator<[{
|
||||
return ctx.DeclarationNames.getCXXLiteralOperatorName(identifier);
|
||||
}]>;
|
||||
}
|
||||
let Class = PropertyTypeCase<DeclarationName, "CXXUsingDirective"> in {
|
||||
def : Creator<[{
|
||||
return DeclarationName::getUsingDirectiveName();
|
||||
}]>;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue