Replace tabs with spaces.

This commit is contained in:
John McCall 2019-12-15 23:51:44 -05:00
parent 00bc76eddd
commit 41d935f2c6
2 changed files with 130 additions and 130 deletions

View File

@ -10,26 +10,26 @@ class ASTNode;
/// The type of the property.
class PropertyType<string typeName = ""> {
/// The C++ type name for the type.
string CXXName = !if(!ne(typeName, ""), typeName, NAME);
/// The C++ type name for the type.
string CXXName = !if(!ne(typeName, ""), typeName, NAME);
/// Whether the C++ type should generally be passed around by reference.
bit PassByReference = 0;
/// Whether the C++ type should generally be passed around by reference.
bit PassByReference = 0;
/// Whether `const` should be prepended to the type when writing.
bit ConstWhenWriting = 0;
/// Whether `const` should be prepended to the type when writing.
bit ConstWhenWriting = 0;
/// Given a value of type Optional<CXXName> bound as 'value', yield a
/// CXXName that can be serialized into a DataStreamTypeWriter.
string PackOptional = "";
/// Given a value of type Optional<CXXName> bound as 'value', yield a
/// CXXName that can be serialized into a DataStreamTypeWriter.
string PackOptional = "";
/// Given a value of type CXXName bound as 'value' that was deserialized
/// by a DataStreamTypeReader, yield an Optional<CXXName>.
string UnpackOptional = "";
/// Given a value of type CXXName bound as 'value' that was deserialized
/// by a DataStreamTypeReader, yield an Optional<CXXName>.
string UnpackOptional = "";
/// A list of types for which buffeers must be passed to the read
/// operations.
list<PropertyType> BufferElementTypes = [];
/// A list of types for which buffeers must be passed to the read
/// operations.
list<PropertyType> BufferElementTypes = [];
}
/// Property types that correspond to specific C++ enums.
@ -38,36 +38,36 @@ class EnumPropertyType<string typeName = ""> : PropertyType<typeName> {}
/// Property types that correspond to a specific C++ class.
/// Supports optional values by using the null representation.
class RefPropertyType<string className> : PropertyType<className # "*"> {
let PackOptional =
"value ? *value : nullptr";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value) : llvm::None";
let PackOptional =
"value ? *value : nullptr";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value) : llvm::None";
}
/// Property types that correspond to a specific subclass of another type.
class SubclassPropertyType<string className, PropertyType base>
: RefPropertyType<className> {
PropertyType Base = base;
string SubclassName = className;
let ConstWhenWriting = base.ConstWhenWriting;
: RefPropertyType<className> {
PropertyType Base = base;
string SubclassName = className;
let ConstWhenWriting = base.ConstWhenWriting;
}
/// Property types that support optional values by using their
/// default value.
class DefaultValuePropertyType<string typeName = ""> : PropertyType<typeName> {
let PackOptional =
"value ? *value : " # CXXName # "()";
let UnpackOptional =
"value.isNull() ? llvm::None : llvm::Optional<" # CXXName # ">(value)";
let PackOptional =
"value ? *value : " # CXXName # "()";
let UnpackOptional =
"value.isNull() ? llvm::None : llvm::Optional<" # CXXName # ">(value)";
}
/// Property types that correspond to integer types and support optional
/// values by shifting the value over by 1.
class CountPropertyType<string typeName = ""> : PropertyType<typeName> {
let PackOptional =
"value ? *value + 1 : 0";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value - 1) : llvm::None";
let PackOptional =
"value ? *value + 1 : 0";
let UnpackOptional =
"value ? llvm::Optional<" # CXXName # ">(value - 1) : llvm::None";
}
def APInt : PropertyType<"llvm::APInt"> { let PassByReference = 1; }
@ -81,36 +81,36 @@ def CallingConv : EnumPropertyType;
def DeclarationName : PropertyType;
def DeclarationNameKind : EnumPropertyType<"DeclarationName::NameKind">;
def DeclRef : RefPropertyType<"Decl"> { let ConstWhenWriting = 1; }
def CXXRecordDeclRef :
SubclassPropertyType<"CXXRecordDecl", DeclRef>;
def FunctionDeclRef :
SubclassPropertyType<"FunctionDecl", DeclRef>;
def NamedDeclRef :
SubclassPropertyType<"NamedDecl", DeclRef>;
def NamespaceDeclRef :
SubclassPropertyType<"NamespaceDecl", DeclRef>;
def NamespaceAliasDeclRef :
SubclassPropertyType<"NamespaceAliasDecl", DeclRef>;
def ObjCProtocolDeclRef :
SubclassPropertyType<"ObjCProtocolDecl", DeclRef>;
def ObjCTypeParamDeclRef :
SubclassPropertyType<"ObjCTypeParamDecl", DeclRef>;
def TagDeclRef :
SubclassPropertyType<"TagDecl", DeclRef>;
def TemplateDeclRef :
SubclassPropertyType<"TemplateDecl", DeclRef>;
def TemplateTypeParmDeclRef :
SubclassPropertyType<"TemplateTypeParmDecl", DeclRef>;
def TemplateTemplateParmDeclRef :
SubclassPropertyType<"TemplateTemplateParmDecl", DeclRef>;
def ValueDeclRef :
SubclassPropertyType<"ValueDecl", DeclRef>;
def CXXRecordDeclRef :
SubclassPropertyType<"CXXRecordDecl", DeclRef>;
def FunctionDeclRef :
SubclassPropertyType<"FunctionDecl", DeclRef>;
def NamedDeclRef :
SubclassPropertyType<"NamedDecl", DeclRef>;
def NamespaceDeclRef :
SubclassPropertyType<"NamespaceDecl", DeclRef>;
def NamespaceAliasDeclRef :
SubclassPropertyType<"NamespaceAliasDecl", DeclRef>;
def ObjCProtocolDeclRef :
SubclassPropertyType<"ObjCProtocolDecl", DeclRef>;
def ObjCTypeParamDeclRef :
SubclassPropertyType<"ObjCTypeParamDecl", DeclRef>;
def TagDeclRef :
SubclassPropertyType<"TagDecl", DeclRef>;
def TemplateDeclRef :
SubclassPropertyType<"TemplateDecl", DeclRef>;
def TemplateTypeParmDeclRef :
SubclassPropertyType<"TemplateTypeParmDecl", DeclRef>;
def TemplateTemplateParmDeclRef :
SubclassPropertyType<"TemplateTemplateParmDecl", DeclRef>;
def ValueDeclRef :
SubclassPropertyType<"ValueDecl", DeclRef>;
def ElaboratedTypeKeyword : EnumPropertyType;
def ExtParameterInfo : PropertyType<"FunctionProtoType::ExtParameterInfo">;
def Identifier : PropertyType<"IdentifierInfo*">;
def NestedNameSpecifier : PropertyType<"NestedNameSpecifier *">;
def NestedNameSpecifierKind :
EnumPropertyType<"NestedNameSpecifier::SpecifierKind">;
EnumPropertyType<"NestedNameSpecifier::SpecifierKind">;
def OverloadedOperatorKind : EnumPropertyType;
def Qualifiers : PropertyType;
def QualType : DefaultValuePropertyType;
@ -118,7 +118,7 @@ def RefQualifierKind : EnumPropertyType;
def Selector : PropertyType;
def SourceLocation : PropertyType;
def StmtRef : RefPropertyType<"Stmt"> { let ConstWhenWriting = 1; }
def ExprRef : SubclassPropertyType<"Expr", StmtRef>;
def ExprRef : SubclassPropertyType<"Expr", StmtRef>;
def TemplateArgument : PropertyType;
def TemplateArgumentKind : EnumPropertyType<"TemplateArgument::ArgKind">;
def TemplateName : DefaultValuePropertyType;
@ -129,14 +129,14 @@ def UnaryTypeTransformKind : EnumPropertyType<"UnaryTransformType::UTTKind">;
def VectorKind : EnumPropertyType<"VectorType::VectorKind">;
def ExceptionSpecInfo : PropertyType<"FunctionProtoType::ExceptionSpecInfo"> {
let BufferElementTypes = [ QualType ];
let BufferElementTypes = [ QualType ];
}
/// Arrays. The corresponding C++ type is ArrayRef of the corresponding
/// C++ type of the element.
class Array<PropertyType element> : PropertyType {
PropertyType Element = element;
let BufferElementTypes = [ element ];
PropertyType Element = element;
let BufferElementTypes = [ element ];
}
/// llvm::Optional<T>. The corresponding C++ type is generally just the
@ -145,35 +145,35 @@ class Array<PropertyType element> : PropertyType {
/// Optional<Unsigned> may restrict the range of the operand for some
/// serialization clients.
class Optional<PropertyType element> : PropertyType {
PropertyType Element = element;
let PassByReference = element.PassByReference;
PropertyType Element = element;
let PassByReference = element.PassByReference;
}
/// A property of an AST node.
class Property<string name, PropertyType type> {
ASTNode Class;
string Name = name;
PropertyType Type = type;
ASTNode Class;
string Name = name;
PropertyType Type = type;
/// A function for reading the property, expressed in terms of a variable
/// "node".
code Read;
/// A function for reading the property, expressed in terms of a variable
/// "node".
code Read;
}
/// A rule for creating objects of this type.
class Creator<code create> {
ASTNode Class;
ASTNode Class;
/// A function for creating values of this kind, expressed in terms of a
/// variable `ctx` of type `ASTContext &`. Must also refer to all of the
/// properties by name.
code Create = create;
/// A function for creating values of this kind, expressed in terms of a
/// variable `ctx` of type `ASTContext &`. Must also refer to all of the
/// properties by name.
code Create = create;
}
/// A rule which overrides some of the normal rules.
class Override {
ASTNode Class;
ASTNode Class;
/// Properties from base classes that should be ignored.
list<string> IgnoredProperties = [];
/// Properties from base classes that should be ignored.
list<string> IgnoredProperties = [];
}

View File

@ -38,8 +38,8 @@ let Class = AdjustedType in {
let Class = DecayedType in {
def : Override {
// We don't need to serialize the adjusted type because we can always
// derive it by decaying the original type.
// We don't need to serialize the adjusted type because we can always
// derive it by decaying the original type.
let IgnoredProperties = [ "adjustedType" ];
}
@ -139,7 +139,7 @@ let Class = VariableArrayType in {
return ctx.getVariableArrayType(elementType, size, sizeModifier,
indexQualifiers.getCVRQualifiers(),
SourceRange(leftBracketLoc,
rightBracketLoc));
rightBracketLoc));
}]>;
}
@ -157,8 +157,8 @@ let Class = DependentSizedArrayType in {
def : Creator<[{
return ctx.getDependentSizedArrayType(elementType, size, sizeModifier,
indexQualifiers.getCVRQualifiers(),
SourceRange(leftBracketLoc,
rightBracketLoc));
SourceRange(leftBracketLoc,
rightBracketLoc));
}]>;
}
@ -194,7 +194,7 @@ let Class = DependentVectorType in {
def : Creator<[{
return ctx.getDependentVectorType(elementType, size, attributeLoc,
vectorKind);
vectorKind);
}]>;
}
@ -274,7 +274,7 @@ let Class = FunctionProtoType in {
let Read = [{ node->getRefQualifier() }];
}
def : Property<"exceptionSpecifier", ExceptionSpecInfo> {
let Read = [{ node->getExceptionSpecInfo() }];
let Read = [{ node->getExceptionSpecInfo() }];
}
def : Property<"parameters", Array<QualType>> {
let Read = [{ node->getParamTypes() }];
@ -331,9 +331,9 @@ let Class = TypedefType in {
}
def : Creator<[{
QualType finalCanonicalType =
canonicalType ? ctx.getCanonicalType(*canonicalType)
: QualType();
QualType finalCanonicalType =
canonicalType ? ctx.getCanonicalType(*canonicalType)
: QualType();
return ctx.getTypedefType(cast<TypedefNameDecl>(declaration),
finalCanonicalType);
}]>;
@ -425,8 +425,8 @@ let Class = DeducedTemplateSpecializationType in {
def : Creator<[{
return ctx.getDeducedTemplateSpecializationType(
makeNullableFromOptional(templateName),
deducedType, dependent);
makeNullableFromOptional(templateName),
deducedType, dependent);
}]>;
}
@ -435,8 +435,8 @@ let Class = TagType in {
let Read = [{ node->isDependentType() }];
}
def : Property<"declaration", DeclRef> {
// Serializing a reference to the canonical declaration is apparently
// necessary to make module-merging work.
// Serializing a reference to the canonical declaration is apparently
// necessary to make module-merging work.
let Read = [{ node->getDecl()->getCanonicalDecl() }];
}
}
@ -451,7 +451,7 @@ let Class = EnumType in {
let Class = RecordType in {
def : Creator<[{
auto record = cast<RecordDecl>(declaration);
auto record = cast<RecordDecl>(declaration);
QualType result = ctx.getRecordType(record);
const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
return result;
@ -474,7 +474,7 @@ let Class = ElaboratedType in {
def : Creator<[{
return ctx.getElaboratedType(keyword, qualifier, namedType,
makePointerFromOptional(ownedTag));
makePointerFromOptional(ownedTag));
}]>;
}
@ -577,11 +577,11 @@ let Class = TemplateSpecializationType in {
}
def : Property<"underlyingType", Optional<QualType>> {
let Read = [{
node->isTypeAlias()
? llvm::Optional<QualType>(node->getAliasedType())
: node->isCanonicalUnqualified()
? llvm::None
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
node->isTypeAlias()
? llvm::Optional<QualType>(node->getAliasedType())
: node->isCanonicalUnqualified()
? llvm::None
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
}];
}
@ -592,8 +592,8 @@ let Class = TemplateSpecializationType in {
templateArguments);
} else {
result = ctx.getTemplateSpecializationType(templateName,
templateArguments,
*underlyingType);
templateArguments,
*underlyingType);
}
const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
return result;
@ -615,8 +615,8 @@ let Class = DependentTemplateSpecializationType in {
}
def : Creator<[{
return ctx.getDependentTemplateSpecializationType(keyword, qualifier,
name, templateArguments);
return ctx.getDependentTemplateSpecializationType(keyword, qualifier,
name, templateArguments);
}]>;
}
@ -635,8 +635,8 @@ let Class = TemplateTypeParmType in {
}
def : Creator<[{
return ctx.getTemplateTypeParmType(depth, index, isParameterPack,
makePointerFromOptional(declaration));
return ctx.getTemplateTypeParmType(depth, index, isParameterPack,
makePointerFromOptional(declaration));
}]>;
}
@ -649,7 +649,7 @@ let Class = SubstTemplateTypeParmType in {
}
def : Creator<[{
// The call to getCanonicalType here existed in ASTReader.cpp, too.
// The call to getCanonicalType here existed in ASTReader.cpp, too.
return ctx.getSubstTemplateTypeParmType(
cast<TemplateTypeParmType>(replacedParameter),
ctx.getCanonicalType(replacementType));
@ -665,7 +665,7 @@ let Class = PackExpansionType in {
}
def : Creator<[{
return ctx.getPackExpansionType(pattern, numExpansions);
return ctx.getPackExpansionType(pattern, numExpansions);
}]>;
}
@ -678,8 +678,8 @@ let Class = SubstTemplateTypeParmPackType in {
}
def : Creator<[{
return ctx.getSubstTemplateTypeParmPackType(
cast<TemplateTypeParmType>(replacedParameter),
return ctx.getSubstTemplateTypeParmPackType(
cast<TemplateTypeParmType>(replacedParameter),
replacementPack);
}]>;
}
@ -689,7 +689,7 @@ let Class = BuiltinType in {
let Read = [{ node->getKind() }];
}
def : Creator<[{
def : Creator<[{
switch (kind) {
#define IMAGE_TYPE(IMGTYPE, ID, SINGLETON_ID, ACCESS, SUFFIX) \
case BuiltinType::ID: return ctx.SINGLETON_ID;
@ -708,7 +708,7 @@ let Class = BuiltinType in {
#include "clang/AST/BuiltinTypes.def"
}
llvm_unreachable("unreachable builtin case");
}]>;
}]>;
}
let Class = DependentNameType in {
@ -723,18 +723,18 @@ let Class = DependentNameType in {
}
def : Property<"underlyingType", Optional<QualType>> {
let Read = [{
node->isCanonicalUnqualified()
? llvm::None
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
node->isCanonicalUnqualified()
? llvm::None
: llvm::Optional<QualType>(node->getCanonicalTypeInternal())
}];
}
def : Creator<[{
QualType canon = (underlyingType
? ctx.getCanonicalType(*underlyingType)
: QualType());
return ctx.getDependentNameType(keyword, qualifier, name, canon);
}]>;
def : Creator<[{
QualType canon = (underlyingType
? ctx.getCanonicalType(*underlyingType)
: QualType());
return ctx.getDependentNameType(keyword, qualifier, name, canon);
}]>;
}
let Class = ObjCObjectType in {
@ -752,9 +752,9 @@ let Class = ObjCObjectType in {
}
def : Creator<[{
return ctx.getObjCObjectType(baseType, typeArgsAsWritten, qualifiers,
isKindOfTypeAsWritten);
}]>;
return ctx.getObjCObjectType(baseType, typeArgsAsWritten, qualifiers,
isKindOfTypeAsWritten);
}]>;
}
let Class = ObjCInterfaceType in {
@ -771,9 +771,9 @@ let Class = ObjCInterfaceType in {
}
def : Creator<[{
return ctx.getObjCInterfaceType(
cast<ObjCInterfaceDecl>(declaration->getCanonicalDecl()));
}]>;
return ctx.getObjCInterfaceType(
cast<ObjCInterfaceDecl>(declaration->getCanonicalDecl()));
}]>;
}
let Class = ObjCTypeParamType in {
@ -785,8 +785,8 @@ let Class = ObjCTypeParamType in {
}
def : Creator<[{
return ctx.getObjCTypeParamType(declaration, qualifiers);
}]>;
return ctx.getObjCTypeParamType(declaration, qualifiers);
}]>;
}
let Class = ObjCObjectPointerType in {
@ -795,8 +795,8 @@ let Class = ObjCObjectPointerType in {
}
def : Creator<[{
return ctx.getObjCObjectPointerType(pointeeType);
}]>;
return ctx.getObjCObjectPointerType(pointeeType);
}]>;
}
let Class = PipeType in {
@ -808,6 +808,6 @@ let Class = PipeType in {
}
def : Creator<[{
return ctx.getPipeType(elementType, isReadOnly);
}]>;
return ctx.getPipeType(elementType, isReadOnly);
}]>;
}