Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 39 additions & 50 deletions clang/include/clang/AST/ExprCXX.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,12 +495,10 @@ class CXXDynamicCastExpr final
friend class CastExpr;
friend TrailingObjects;

static CXXDynamicCastExpr *Create(const ASTContext &Context, QualType T,
ExprValueKind VK, CastKind Kind, Expr *Op,
const CXXCastPath *Path,
TypeSourceInfo *Written, SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets);
static CXXDynamicCastExpr *
Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
Expr *Op, const CXXCastPath *Path, TypeSourceInfo *Written,
SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);

static CXXDynamicCastExpr *CreateEmpty(const ASTContext &Context,
unsigned pathSize);
Expand Down Expand Up @@ -540,12 +538,10 @@ class CXXReinterpretCastExpr final
friend class CastExpr;
friend TrailingObjects;

static CXXReinterpretCastExpr *Create(const ASTContext &Context, QualType T,
ExprValueKind VK, CastKind Kind,
Expr *Op, const CXXCastPath *Path,
TypeSourceInfo *WrittenTy, SourceLocation L,
SourceLocation RParenLoc,
SourceRange AngleBrackets);
static CXXReinterpretCastExpr *
Create(const ASTContext &Context, QualType T, ExprValueKind VK, CastKind Kind,
Expr *Op, const CXXCastPath *Path, TypeSourceInfo *WrittenTy,
SourceLocation L, SourceLocation RParenLoc, SourceRange AngleBrackets);
static CXXReinterpretCastExpr *CreateEmpty(const ASTContext &Context,
unsigned pathSize);

Expand Down Expand Up @@ -694,7 +690,7 @@ class UserDefinedLiteral final : public CallExpr {
/// removed).
Expr *getCookedLiteral();
const Expr *getCookedLiteral() const {
return const_cast<UserDefinedLiteral*>(this)->getCookedLiteral();
return const_cast<UserDefinedLiteral *>(this)->getCookedLiteral();
}

SourceLocation getBeginLoc() const {
Expand Down Expand Up @@ -813,8 +809,8 @@ class CXXStdInitializerListExpr : public Expr {
setDependence(computeDependence(this));
}

Expr *getSubExpr() { return static_cast<Expr*>(SubExpr); }
const Expr *getSubExpr() const { return static_cast<const Expr*>(SubExpr); }
Expr *getSubExpr() { return static_cast<Expr *>(SubExpr); }
const Expr *getSubExpr() const { return static_cast<const Expr *>(SubExpr); }

SourceLocation getBeginLoc() const LLVM_READONLY {
return SubExpr->getBeginLoc();
Expand Down Expand Up @@ -868,9 +864,9 @@ class CXXTypeidExpr : public Expr {
CXXTypeidExpr(EmptyShell Empty, bool isExpr)
: Expr(CXXTypeidExprClass, Empty) {
if (isExpr)
Operand = (Expr*)nullptr;
Operand = (Expr *)nullptr;
else
Operand = (TypeSourceInfo*)nullptr;
Operand = (TypeSourceInfo *)nullptr;
}

/// Determine whether this typeid has a type operand which is potentially
Expand Down Expand Up @@ -968,13 +964,13 @@ class MSPropertyRefExpr : public Expr {
else if (QualifierLoc)
return QualifierLoc.getBeginLoc();
else
return MemberLoc;
return MemberLoc;
}

SourceLocation getEndLoc() const { return getMemberLoc(); }

child_range children() {
return child_range((Stmt**)&BaseExpr, (Stmt**)&BaseExpr + 1);
return child_range((Stmt **)&BaseExpr, (Stmt **)&BaseExpr + 1);
}

const_child_range children() const {
Expand Down Expand Up @@ -1089,11 +1085,11 @@ class CXXUuidofExpr : public Expr {
}

CXXUuidofExpr(EmptyShell Empty, bool isExpr)
: Expr(CXXUuidofExprClass, Empty) {
: Expr(CXXUuidofExprClass, Empty) {
if (isExpr)
Operand = (Expr*)nullptr;
Operand = (Expr *)nullptr;
else
Operand = (TypeSourceInfo*)nullptr;
Operand = (TypeSourceInfo *)nullptr;
}

bool isTypeOperand() const { return isa<TypeSourceInfo *>(Operand); }
Expand Down Expand Up @@ -1470,9 +1466,7 @@ class CXXTemporary {

const CXXDestructorDecl *getDestructor() const { return Destructor; }

void setDestructor(const CXXDestructorDecl *Dtor) {
Destructor = Dtor;
}
void setDestructor(const CXXDestructorDecl *Dtor) { Destructor = Dtor; }
};

/// Represents binding an expression to a temporary.
Expand Down Expand Up @@ -1507,7 +1501,7 @@ class CXXBindTemporaryExpr : public Expr {
: Expr(CXXBindTemporaryExprClass, Empty) {}

static CXXBindTemporaryExpr *Create(const ASTContext &C, CXXTemporary *Temp,
Expr* SubExpr);
Expr *SubExpr);

CXXTemporary *getTemporary() { return Temp; }
const CXXTemporary *getTemporary() const { return Temp; }
Expand Down Expand Up @@ -2214,9 +2208,7 @@ class CXXScalarValueInitExpr : public Expr {
explicit CXXScalarValueInitExpr(EmptyShell Shell)
: Expr(CXXScalarValueInitExprClass, Shell) {}

TypeSourceInfo *getTypeSourceInfo() const {
return TypeInfo;
}
TypeSourceInfo *getTypeSourceInfo() const { return TypeInfo; }

SourceLocation getRParenLoc() const {
return CXXScalarValueInitExprBits.RParenLoc;
Expand Down Expand Up @@ -2777,12 +2769,11 @@ class CXXPseudoDestructorExpr : public Expr {
PseudoDestructorTypeStorage DestroyedType;

public:
CXXPseudoDestructorExpr(const ASTContext &Context,
Expr *Base, bool isArrow, SourceLocation OperatorLoc,
CXXPseudoDestructorExpr(const ASTContext &Context, Expr *Base, bool isArrow,
SourceLocation OperatorLoc,
NestedNameSpecifierLoc QualifierLoc,
TypeSourceInfo *ScopeType,
SourceLocation ColonColonLoc,
SourceLocation TildeLoc,
SourceLocation ColonColonLoc, SourceLocation TildeLoc,
PseudoDestructorTypeStorage DestroyedType);

explicit CXXPseudoDestructorExpr(EmptyShell Shell)
Expand Down Expand Up @@ -2925,8 +2916,7 @@ class TypeTraitExpr final
static TypeTraitExpr *Create(const ASTContext &C, QualType T,
SourceLocation Loc, TypeTrait Kind,
ArrayRef<TypeSourceInfo *> Args,
SourceLocation RParenLoc,
bool Value);
SourceLocation RParenLoc, bool Value);

static TypeTraitExpr *Create(const ASTContext &C, QualType T,
SourceLocation Loc, TypeTrait Kind,
Expand Down Expand Up @@ -3043,7 +3033,10 @@ class ArrayTypeTraitExpr : public Expr {

TypeSourceInfo *getQueriedTypeSourceInfo() const { return QueriedType; }

uint64_t getValue() const { assert(!isTypeDependent()); return Value; }
uint64_t getValue() const {
assert(!isTypeDependent());
return Value;
}

Expr *getDimensionExpression() const { return Dimension; }

Expand Down Expand Up @@ -3076,7 +3069,7 @@ class ExpressionTraitExpr : public Expr {
SourceLocation RParen;

/// The expression being queried.
Expr* QueriedExpression = nullptr;
Expr *QueriedExpression = nullptr;

public:
friend class ASTStmtReader;
Expand Down Expand Up @@ -3810,7 +3803,7 @@ class CXXUnresolvedConstructExpr final
arg_iterator arg_end() { return arg_begin() + getNumArgs(); }
arg_range arguments() { return arg_range(arg_begin(), arg_end()); }

using const_arg_iterator = const Expr* const *;
using const_arg_iterator = const Expr *const *;
using const_arg_range = llvm::iterator_range<const_arg_iterator>;

const_arg_iterator arg_begin() const { return getTrailingObjects(); }
Expand Down Expand Up @@ -4420,9 +4413,7 @@ class PackExpansionExpr : public Expr {
}

// Iterators
child_range children() {
return child_range(&Pattern, &Pattern + 1);
}
child_range children() { return child_range(&Pattern, &Pattern + 1); }

const_child_range children() const {
return const_child_range(&Pattern, &Pattern + 1);
Expand Down Expand Up @@ -4525,9 +4516,7 @@ class SizeOfPackExpr final
///
/// template<typename ...Ts> using X = int[sizeof...(Ts)];
/// template<typename ...Us> void f(X<Us..., 1, 2, 3, Us...>);
bool isPartiallySubstituted() const {
return isValueDependent() && Length;
}
bool isPartiallySubstituted() const { return isValueDependent() && Length; }

/// Get
ArrayRef<TemplateArgument> getPartialArguments() const {
Expand Down Expand Up @@ -5056,8 +5045,8 @@ class CXXFoldExpr : public Expr {
UnresolvedLookupExpr *getCallee() const {
return static_cast<UnresolvedLookupExpr *>(SubExprs[SubExpr::Callee]);
}
Expr *getLHS() const { return static_cast<Expr*>(SubExprs[SubExpr::LHS]); }
Expr *getRHS() const { return static_cast<Expr*>(SubExprs[SubExpr::RHS]); }
Expr *getLHS() const { return static_cast<Expr *>(SubExprs[SubExpr::LHS]); }
Expr *getRHS() const { return static_cast<Expr *>(SubExprs[SubExpr::RHS]); }

/// Does this produce a right-associated sequence of operators?
bool isRightFold() const {
Expand Down Expand Up @@ -5304,22 +5293,22 @@ class CoroutineSuspendExpr : public Expr {
}

Expr *getCommonExpr() const {
return static_cast<Expr*>(SubExprs[SubExpr::Common]);
return static_cast<Expr *>(SubExprs[SubExpr::Common]);
}

/// getOpaqueValue - Return the opaque value placeholder.
OpaqueValueExpr *getOpaqueValue() const { return OpaqueValue; }

Expr *getReadyExpr() const {
return static_cast<Expr*>(SubExprs[SubExpr::Ready]);
return static_cast<Expr *>(SubExprs[SubExpr::Ready]);
}

Expr *getSuspendExpr() const {
return static_cast<Expr*>(SubExprs[SubExpr::Suspend]);
return static_cast<Expr *>(SubExprs[SubExpr::Suspend]);
}

Expr *getResumeExpr() const {
return static_cast<Expr*>(SubExprs[SubExpr::Resume]);
return static_cast<Expr *>(SubExprs[SubExpr::Resume]);
}

// The syntactic operand written in the code
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/CIR/Dialect/IR/CIRDataLayout.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,10 @@ class CIRDataLayout {
return getAlignment(ty, true);
}

llvm::Align getPrefTypeAlign(mlir::Type ty) const {
return getAlignment(ty, false);
}

/// Returns the maximum number of bytes that may be overwritten by
/// storing the specified type.
///
Expand Down
2 changes: 1 addition & 1 deletion clang/include/clang/Sema/TemplateInstCallback.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ void initialize(TemplateInstantiationCallbackPtrs &Callbacks,
template <class TemplateInstantiationCallbackPtrs>
void finalize(TemplateInstantiationCallbackPtrs &Callbacks,
const Sema &TheSema) {
for (auto &C : Callbacks) {
for (auto &C : Callbacks) {
if (C)
C->finalize(TheSema);
}
Expand Down
14 changes: 14 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenCall.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -461,6 +461,20 @@ CIRGenTypes::arrangeFunctionDeclaration(const FunctionDecl *fd) {
return arrangeFreeFunctionType(funcTy.castAs<FunctionProtoType>());
}

RValue CallArg::getAsRValue(CIRGenFunction &cgf, mlir::Location loc) const {
if (!hasLV) {
// If callarg is an RValue, return it directly
return rv;
}

// Otherwise make a temporary copy
LValue copy = cgf.makeAddrLValue(cgf.createMemTemp(ty, loc), ty);
cgf.emitAggregateCopy(copy, lv, ty, AggValueSlot::DoesNotOverlap,
lv.isVolatile());
isUsed = true;
return RValue::getAggregate(copy.getAddress());
}

static cir::CIRCallOpInterface
emitCallLikeOp(CIRGenFunction &cgf, mlir::Location callLoc,
cir::FuncType indirectFuncTy, mlir::Value indirectFuncVal,
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/CIR/CodeGen/CIRGenCall.h
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ struct CallArg {
CallArg(LValue lv, clang::QualType ty)
: lv(lv), hasLV(true), isUsed(false), ty(ty) {}

/// \returns an independent RValue. If the CallArg contains an LValue,
/// a temporary copy is returned.
RValue getAsRValue(CIRGenFunction &cgf, mlir::Location loc) const;

bool hasLValue() const { return hasLV; }

LValue getKnownLValue() const {
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/CIR/CodeGen/CIRGenClass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct CallBaseDtor final : EHScopeStack::Cleanup {
CallBaseDtor(const CXXRecordDecl *base, bool baseIsVirtual)
: baseClass(base), baseIsVirtual(baseIsVirtual) {}

void emit(CIRGenFunction &cgf) override {
void emit(CIRGenFunction &cgf, Flags flags) override {
const CXXRecordDecl *derivedClass =
cast<CXXMethodDecl>(cgf.curFuncDecl)->getParent();

Expand Down Expand Up @@ -904,9 +904,9 @@ mlir::Value loadThisForDtorDelete(CIRGenFunction &cgf,

/// Call the operator delete associated with the current destructor.
struct CallDtorDelete final : EHScopeStack::Cleanup {
CallDtorDelete() {}
CallDtorDelete() = default;

void emit(CIRGenFunction &cgf) override {
void emit(CIRGenFunction &cgf, Flags flags) override {
const CXXDestructorDecl *dtor = cast<CXXDestructorDecl>(cgf.curFuncDecl);
const CXXRecordDecl *classDecl = dtor->getParent();
cgf.emitDeleteCall(dtor->getOperatorDelete(),
Expand All @@ -923,7 +923,7 @@ class DestroyField final : public EHScopeStack::Cleanup {
DestroyField(const FieldDecl *field, CIRGenFunction::Destroyer *destroyer)
: field(field), destroyer(destroyer) {}

void emit(CIRGenFunction &cgf) override {
void emit(CIRGenFunction &cgf, Flags flags) override {
// Find the address of the field.
Address thisValue = cgf.loadCXXThisAddress();
CanQualType recordTy =
Expand Down
Loading