Skip to content

Commit

Permalink
[AST] Fix inconsistencies in handling of Hyperobject types in the AST.
Browse files Browse the repository at this point in the history
  • Loading branch information
neboat committed Nov 16, 2024
1 parent 51fa56f commit 33286d5
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions clang/include/clang/AST/ASTContext.h
Original file line number Diff line number Diff line change
Expand Up @@ -1332,9 +1332,9 @@ class ASTContext : public RefCountedBase<ASTContext> {
return CanQualType::CreateUnsafe(getComplexType((QualType) T));
}

QualType getHyperobjectType(QualType T, Expr *R, Expr *I) const;
CanQualType getHyperobjectType(CanQualType T, Expr *R, Expr *I) const {
return CanQualType::CreateUnsafe(getHyperobjectType((QualType) T, R, I));
QualType getHyperobjectType(QualType T, Expr *I, Expr *R) const;
CanQualType getHyperobjectType(CanQualType T, Expr *I, Expr *R) const {
return CanQualType::CreateUnsafe(getHyperobjectType((QualType) T, I, R));
}

/// Return the uniqued reference to the type for a pointer to
Expand Down
8 changes: 4 additions & 4 deletions clang/include/clang/AST/TypeProperties.td
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ let Class = HyperobjectType in {
def : Property<"elementType", QualType> {
let Read = [{ node->getElementType() }];
}
def : Property<"reduce", ExprRef> {
let Read = [{ node->getReduce() }];
}
def : Property<"identity", ExprRef> {
let Read = [{ node->getIdentity() }];
}
def : Property<"reduce", ExprRef> {
let Read = [{ node->getReduce() }];
}

def : Creator<[{
return ctx.getHyperobjectType(elementType, reduce, identity);
return ctx.getHyperobjectType(elementType, identity, reduce);
}]>;
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTImporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1161,7 +1161,7 @@ ExpectedType ASTNodeImporter::VisitHyperobjectType(const HyperobjectType *T) {
return ToReduceOrErr.takeError();

return Importer.getToContext().getHyperobjectType(
*ToElementTypeOrErr, *ToReduceOrErr, *ToIdentityOrErr);
*ToElementTypeOrErr, *ToIdentityOrErr, *ToReduceOrErr);
}

ExpectedType ASTNodeImporter::VisitComplexType(const ComplexType *T) {
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ASTStructuralEquivalence.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -844,7 +844,7 @@ static bool IsStructurallyEquivalent(StructuralEquivalenceContext &Context,
const HyperobjectType *H2 = cast<HyperobjectType>(T2);
Expr *R1 = H1->getReduce(), *R2 = H2->getReduce();
Expr *I1 = H1->getIdentity(), *I2 = H2->getIdentity();
if (!!I2 != !!I2 || !!R1 != !!R2)
if (!!I1 != !!I2 || !!R1 != !!R2)
return false;
if (I1 && !IsStructurallyEquivalent(Context, I1, I2))
return false;
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -1272,8 +1272,8 @@ class TreeTransform {
QualType RebuildDependentBitIntType(bool IsUnsigned, Expr *NumBitsExpr,
SourceLocation Loc);

QualType RebuildHyperobjectType(QualType ElementType, Expr *R,
Expr *I, SourceLocation Loc);
QualType RebuildHyperobjectType(QualType ElementType, Expr *I,
Expr *R, SourceLocation Loc);

/// Build a new template name given a nested name specifier, a flag
/// indicating whether the "template" keyword was provided, and the template
Expand Down

0 comments on commit 33286d5

Please sign in to comment.