/// 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.
/// 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; }
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;
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;
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
/// 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 = [];
}
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" ];
}
return ctx.getVariableArrayType(elementType, size, sizeModifier,
indexQualifiers.getCVRQualifiers(),
SourceRange(leftBracketLoc,
- rightBracketLoc));
+ rightBracketLoc));
}]>;
}
def : Creator<[{
return ctx.getDependentSizedArrayType(elementType, size, sizeModifier,
indexQualifiers.getCVRQualifiers(),
- SourceRange(leftBracketLoc,
- rightBracketLoc));
+ SourceRange(leftBracketLoc,
+ rightBracketLoc));
}]>;
}
def : Creator<[{
return ctx.getDependentVectorType(elementType, size, attributeLoc,
- vectorKind);
+ vectorKind);
}]>;
}
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() }];
}
def : Creator<[{
- QualType finalCanonicalType =
- canonicalType ? ctx.getCanonicalType(*canonicalType)
- : QualType();
+ QualType finalCanonicalType =
+ canonicalType ? ctx.getCanonicalType(*canonicalType)
+ : QualType();
return ctx.getTypedefType(cast<TypedefNameDecl>(declaration),
finalCanonicalType);
}]>;
def : Creator<[{
return ctx.getDeducedTemplateSpecializationType(
- makeNullableFromOptional(templateName),
- deducedType, dependent);
+ makeNullableFromOptional(templateName),
+ deducedType, dependent);
}]>;
}
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() }];
}
}
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;
def : Creator<[{
return ctx.getElaboratedType(keyword, qualifier, namedType,
- makePointerFromOptional(ownedTag));
+ makePointerFromOptional(ownedTag));
}]>;
}
}
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())
}];
}
templateArguments);
} else {
result = ctx.getTemplateSpecializationType(templateName,
- templateArguments,
- *underlyingType);
+ templateArguments,
+ *underlyingType);
}
const_cast<Type*>(result.getTypePtr())->setDependent(dependent);
return result;
}
def : Creator<[{
- return ctx.getDependentTemplateSpecializationType(keyword, qualifier,
- name, templateArguments);
+ return ctx.getDependentTemplateSpecializationType(keyword, qualifier,
+ name, templateArguments);
}]>;
}
}
def : Creator<[{
- return ctx.getTemplateTypeParmType(depth, index, isParameterPack,
- makePointerFromOptional(declaration));
+ return ctx.getTemplateTypeParmType(depth, index, isParameterPack,
+ makePointerFromOptional(declaration));
}]>;
}
}
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));
}
def : Creator<[{
- return ctx.getPackExpansionType(pattern, numExpansions);
+ return ctx.getPackExpansionType(pattern, numExpansions);
}]>;
}
}
def : Creator<[{
- return ctx.getSubstTemplateTypeParmPackType(
- cast<TemplateTypeParmType>(replacedParameter),
+ return ctx.getSubstTemplateTypeParmPackType(
+ cast<TemplateTypeParmType>(replacedParameter),
replacementPack);
}]>;
}
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;
#include "clang/AST/BuiltinTypes.def"
}
llvm_unreachable("unreachable builtin case");
- }]>;
+ }]>;
}
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 {
}
def : Creator<[{
- return ctx.getObjCObjectType(baseType, typeArgsAsWritten, qualifiers,
- isKindOfTypeAsWritten);
- }]>;
+ return ctx.getObjCObjectType(baseType, typeArgsAsWritten, qualifiers,
+ isKindOfTypeAsWritten);
+ }]>;
}
let Class = ObjCInterfaceType in {
}
def : Creator<[{
- return ctx.getObjCInterfaceType(
- cast<ObjCInterfaceDecl>(declaration->getCanonicalDecl()));
- }]>;
+ return ctx.getObjCInterfaceType(
+ cast<ObjCInterfaceDecl>(declaration->getCanonicalDecl()));
+ }]>;
}
let Class = ObjCTypeParamType in {
}
def : Creator<[{
- return ctx.getObjCTypeParamType(declaration, qualifiers);
- }]>;
+ return ctx.getObjCTypeParamType(declaration, qualifiers);
+ }]>;
}
let Class = ObjCObjectPointerType in {
}
def : Creator<[{
- return ctx.getObjCObjectPointerType(pointeeType);
- }]>;
+ return ctx.getObjCObjectPointerType(pointeeType);
+ }]>;
}
let Class = PipeType in {
}
def : Creator<[{
- return ctx.getPipeType(elementType, isReadOnly);
- }]>;
+ return ctx.getPipeType(elementType, isReadOnly);
+ }]>;
}