Skip to content

Commit ff7c5db

Browse files
committed
Rebase
Created using spr 1.3.5
2 parents e157634 + 3e8db13 commit ff7c5db

File tree

232 files changed

+4834
-2260
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

232 files changed

+4834
-2260
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ Bug Fixes to C++ Support
170170
- Clang is now better at keeping track of friend function template instance contexts. (#GH55509)
171171
- The initialization kind of elements of structured bindings
172172
direct-list-initialized from an array is corrected to direct-initialization.
173+
- Clang no longer crashes when a coroutine is declared ``[[noreturn]]``. (#GH127327)
173174

174175
Bug Fixes to AST Handling
175176
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/Expr.h

Lines changed: 76 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4579,25 +4579,97 @@ class ShuffleVectorExpr : public Expr {
45794579
/// ConvertVectorExpr - Clang builtin function __builtin_convertvector
45804580
/// This AST node provides support for converting a vector type to another
45814581
/// vector type of the same arity.
4582-
class ConvertVectorExpr : public Expr {
4582+
class ConvertVectorExpr final
4583+
: public Expr,
4584+
private llvm::TrailingObjects<ConvertVectorExpr, FPOptionsOverride> {
45834585
private:
45844586
Stmt *SrcExpr;
45854587
TypeSourceInfo *TInfo;
45864588
SourceLocation BuiltinLoc, RParenLoc;
45874589

4590+
friend TrailingObjects;
45884591
friend class ASTReader;
45894592
friend class ASTStmtReader;
4590-
explicit ConvertVectorExpr(EmptyShell Empty) : Expr(ConvertVectorExprClass, Empty) {}
4593+
explicit ConvertVectorExpr(bool HasFPFeatures, EmptyShell Empty)
4594+
: Expr(ConvertVectorExprClass, Empty) {
4595+
ConvertVectorExprBits.HasFPFeatures = HasFPFeatures;
4596+
}
45914597

4592-
public:
45934598
ConvertVectorExpr(Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType,
45944599
ExprValueKind VK, ExprObjectKind OK,
4595-
SourceLocation BuiltinLoc, SourceLocation RParenLoc)
4600+
SourceLocation BuiltinLoc, SourceLocation RParenLoc,
4601+
FPOptionsOverride FPFeatures)
45964602
: Expr(ConvertVectorExprClass, DstType, VK, OK), SrcExpr(SrcExpr),
45974603
TInfo(TI), BuiltinLoc(BuiltinLoc), RParenLoc(RParenLoc) {
4604+
ConvertVectorExprBits.HasFPFeatures = FPFeatures.requiresTrailingStorage();
4605+
if (hasStoredFPFeatures())
4606+
setStoredFPFeatures(FPFeatures);
45984607
setDependence(computeDependence(this));
45994608
}
46004609

4610+
size_t numTrailingObjects(OverloadToken<FPOptionsOverride>) const {
4611+
return ConvertVectorExprBits.HasFPFeatures ? 1 : 0;
4612+
}
4613+
4614+
FPOptionsOverride &getTrailingFPFeatures() {
4615+
assert(ConvertVectorExprBits.HasFPFeatures);
4616+
return *getTrailingObjects<FPOptionsOverride>();
4617+
}
4618+
4619+
const FPOptionsOverride &getTrailingFPFeatures() const {
4620+
assert(ConvertVectorExprBits.HasFPFeatures);
4621+
return *getTrailingObjects<FPOptionsOverride>();
4622+
}
4623+
4624+
public:
4625+
static ConvertVectorExpr *CreateEmpty(const ASTContext &C,
4626+
bool hasFPFeatures);
4627+
4628+
static ConvertVectorExpr *Create(const ASTContext &C, Expr *SrcExpr,
4629+
TypeSourceInfo *TI, QualType DstType,
4630+
ExprValueKind VK, ExprObjectKind OK,
4631+
SourceLocation BuiltinLoc,
4632+
SourceLocation RParenLoc,
4633+
FPOptionsOverride FPFeatures);
4634+
4635+
/// Get the FP contractibility status of this operator. Only meaningful for
4636+
/// operations on floating point types.
4637+
bool isFPContractableWithinStatement(const LangOptions &LO) const {
4638+
return getFPFeaturesInEffect(LO).allowFPContractWithinStatement();
4639+
}
4640+
4641+
/// Is FPFeatures in Trailing Storage?
4642+
bool hasStoredFPFeatures() const {
4643+
return ConvertVectorExprBits.HasFPFeatures;
4644+
}
4645+
4646+
/// Get FPFeatures from trailing storage.
4647+
FPOptionsOverride getStoredFPFeatures() const {
4648+
return getTrailingFPFeatures();
4649+
}
4650+
4651+
/// Get the store FPOptionsOverride or default if not stored.
4652+
FPOptionsOverride getStoredFPFeaturesOrDefault() const {
4653+
return hasStoredFPFeatures() ? getStoredFPFeatures() : FPOptionsOverride();
4654+
}
4655+
4656+
/// Set FPFeatures in trailing storage, used by Serialization & ASTImporter.
4657+
void setStoredFPFeatures(FPOptionsOverride F) { getTrailingFPFeatures() = F; }
4658+
4659+
/// Get the FP features status of this operator. Only meaningful for
4660+
/// operations on floating point types.
4661+
FPOptions getFPFeaturesInEffect(const LangOptions &LO) const {
4662+
if (ConvertVectorExprBits.HasFPFeatures)
4663+
return getStoredFPFeatures().applyOverrides(LO);
4664+
return FPOptions::defaultWithoutTrailingStorage(LO);
4665+
}
4666+
4667+
FPOptionsOverride getFPOptionsOverride() const {
4668+
if (ConvertVectorExprBits.HasFPFeatures)
4669+
return getStoredFPFeatures();
4670+
return FPOptionsOverride();
4671+
}
4672+
46014673
/// getSrcExpr - Return the Expr to be converted.
46024674
Expr *getSrcExpr() const { return cast<Expr>(SrcExpr); }
46034675

clang/include/clang/AST/Stmt.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,20 @@ class alignas(void *) Stmt {
12151215
SourceLocation Loc;
12161216
};
12171217

1218+
class ConvertVectorExprBitfields {
1219+
friend class ConvertVectorExpr;
1220+
1221+
LLVM_PREFERRED_TYPE(ExprBitfields)
1222+
unsigned : NumExprBits;
1223+
1224+
//
1225+
/// This is only meaningful for operations on floating point
1226+
/// types when additional values need to be in trailing storage.
1227+
/// It is 0 otherwise.
1228+
LLVM_PREFERRED_TYPE(bool)
1229+
unsigned HasFPFeatures : 1;
1230+
};
1231+
12181232
union {
12191233
// Same order as in StmtNodes.td.
12201234
// Statements
@@ -1293,6 +1307,7 @@ class alignas(void *) Stmt {
12931307

12941308
// Clang Extensions
12951309
OpaqueValueExprBitfields OpaqueValueExprBits;
1310+
ConvertVectorExprBitfields ConvertVectorExprBits;
12961311
};
12971312

12981313
public:

clang/include/clang/AST/TextNodeDumper.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ class TextNodeDumper
425425
void VisitOpenACCAsteriskSizeExpr(const OpenACCAsteriskSizeExpr *S);
426426
void VisitEmbedExpr(const EmbedExpr *S);
427427
void VisitAtomicExpr(const AtomicExpr *AE);
428+
void VisitConvertVectorExpr(const ConvertVectorExpr *S);
428429
};
429430

430431
} // namespace clang

clang/include/clang/CIR/Dialect/IR/CIRDialect.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ def CIR_Dialect : Dialect {
2828
let useDefaultTypePrinterParser = 0;
2929

3030
let extraClassDeclaration = [{
31+
static llvm::StringRef getTripleAttrName() { return "cir.triple"; }
32+
3133
void registerAttributes();
3234
void registerTypes();
3335

clang/include/clang/CIR/FrontendAction/CIRGenAction.h

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ class CIRGenConsumer;
2525
class CIRGenAction : public clang::ASTFrontendAction {
2626
public:
2727
enum class OutputType {
28+
EmitAssembly,
2829
EmitCIR,
2930
EmitLLVM,
31+
EmitBC,
32+
EmitObj,
3033
};
3134

3235
private:
@@ -63,6 +66,27 @@ class EmitLLVMAction : public CIRGenAction {
6366
EmitLLVMAction(mlir::MLIRContext *MLIRCtx = nullptr);
6467
};
6568

69+
class EmitBCAction : public CIRGenAction {
70+
virtual void anchor();
71+
72+
public:
73+
EmitBCAction(mlir::MLIRContext *MLIRCtx = nullptr);
74+
};
75+
76+
class EmitAssemblyAction : public CIRGenAction {
77+
virtual void anchor();
78+
79+
public:
80+
EmitAssemblyAction(mlir::MLIRContext *MLIRCtx = nullptr);
81+
};
82+
83+
class EmitObjAction : public CIRGenAction {
84+
virtual void anchor();
85+
86+
public:
87+
EmitObjAction(mlir::MLIRContext *MLIRCtx = nullptr);
88+
};
89+
6690
} // namespace cir
6791

6892
#endif

clang/lib/AST/ASTImporter.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7386,9 +7386,10 @@ ExpectedStmt ASTNodeImporter::VisitConvertVectorExpr(ConvertVectorExpr *E) {
73867386
if (Err)
73877387
return std::move(Err);
73887388

7389-
return new (Importer.getToContext())
7390-
ConvertVectorExpr(ToSrcExpr, ToTSI, ToType, E->getValueKind(),
7391-
E->getObjectKind(), ToBuiltinLoc, ToRParenLoc);
7389+
return ConvertVectorExpr::Create(
7390+
Importer.getToContext(), ToSrcExpr, ToTSI, ToType, E->getValueKind(),
7391+
E->getObjectKind(), ToBuiltinLoc, ToRParenLoc,
7392+
E->getStoredFPFeaturesOrDefault());
73927393
}
73937394

73947395
ExpectedStmt ASTNodeImporter::VisitShuffleVectorExpr(ShuffleVectorExpr *E) {

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3397,7 +3397,8 @@ bool Compiler<Emitter>::VisitCXXNewExpr(const CXXNewExpr *E) {
33973397
CtorFunc = getFunction(CE->getConstructor());
33983398
if (!CtorFunc)
33993399
return false;
3400-
}
3400+
} else if (!DynamicInit)
3401+
DynamicInit = Init;
34013402

34023403
LabelTy EndLabel = this->getLabel();
34033404
LabelTy StartLabel = this->getLabel();

clang/lib/AST/DeclTemplate.cpp

Lines changed: 29 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -786,12 +786,16 @@ NonTypeTemplateParmDecl *NonTypeTemplateParmDecl::Create(
786786
QualType T, bool ParameterPack, TypeSourceInfo *TInfo) {
787787
AutoType *AT =
788788
C.getLangOpts().CPlusPlus20 ? T->getContainedAutoType() : nullptr;
789-
return new (C, DC,
790-
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
791-
Expr *>(0,
792-
AT && AT->isConstrained() ? 1 : 0))
793-
NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, ParameterPack,
794-
TInfo);
789+
const bool HasConstraint = AT && AT->isConstrained();
790+
auto *NTTP =
791+
new (C, DC,
792+
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>, Expr *>(
793+
0, HasConstraint ? 1 : 0))
794+
NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T,
795+
ParameterPack, TInfo);
796+
if (HasConstraint)
797+
NTTP->setPlaceholderTypeConstraint(nullptr);
798+
return NTTP;
795799
}
796800

797801
NonTypeTemplateParmDecl *NonTypeTemplateParmDecl::Create(
@@ -800,23 +804,30 @@ NonTypeTemplateParmDecl *NonTypeTemplateParmDecl::Create(
800804
QualType T, TypeSourceInfo *TInfo, ArrayRef<QualType> ExpandedTypes,
801805
ArrayRef<TypeSourceInfo *> ExpandedTInfos) {
802806
AutoType *AT = TInfo->getType()->getContainedAutoType();
803-
return new (C, DC,
804-
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>,
805-
Expr *>(
806-
ExpandedTypes.size(), AT && AT->isConstrained() ? 1 : 0))
807-
NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
808-
ExpandedTypes, ExpandedTInfos);
807+
const bool HasConstraint = AT && AT->isConstrained();
808+
auto *NTTP =
809+
new (C, DC,
810+
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>, Expr *>(
811+
ExpandedTypes.size(), HasConstraint ? 1 : 0))
812+
NonTypeTemplateParmDecl(DC, StartLoc, IdLoc, D, P, Id, T, TInfo,
813+
ExpandedTypes, ExpandedTInfos);
814+
if (HasConstraint)
815+
NTTP->setPlaceholderTypeConstraint(nullptr);
816+
return NTTP;
809817
}
810818

811819
NonTypeTemplateParmDecl *
812820
NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID,
813821
bool HasTypeConstraint) {
814-
return new (C, ID, additionalSizeToAlloc<std::pair<QualType,
815-
TypeSourceInfo *>,
816-
Expr *>(0,
817-
HasTypeConstraint ? 1 : 0))
822+
auto *NTTP =
823+
new (C, ID,
824+
additionalSizeToAlloc<std::pair<QualType, TypeSourceInfo *>, Expr *>(
825+
0, HasTypeConstraint ? 1 : 0))
818826
NonTypeTemplateParmDecl(nullptr, SourceLocation(), SourceLocation(),
819827
0, 0, nullptr, QualType(), false, nullptr);
828+
if (HasTypeConstraint)
829+
NTTP->setPlaceholderTypeConstraint(nullptr);
830+
return NTTP;
820831
}
821832

822833
NonTypeTemplateParmDecl *
@@ -830,6 +841,8 @@ NonTypeTemplateParmDecl::CreateDeserialized(ASTContext &C, GlobalDeclID ID,
830841
NonTypeTemplateParmDecl(nullptr, SourceLocation(), SourceLocation(),
831842
0, 0, nullptr, QualType(), nullptr, {}, {});
832843
NTTP->NumExpandedTypes = NumExpandedTypes;
844+
if (HasTypeConstraint)
845+
NTTP->setPlaceholderTypeConstraint(nullptr);
833846
return NTTP;
834847
}
835848

clang/lib/AST/Expr.cpp

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3911,6 +3911,8 @@ FPOptions Expr::getFPFeaturesInEffect(const LangOptions &LO) const {
39113911
return BO->getFPFeaturesInEffect(LO);
39123912
if (auto Cast = dyn_cast<CastExpr>(this))
39133913
return Cast->getFPFeaturesInEffect(LO);
3914+
if (auto ConvertVector = dyn_cast<ConvertVectorExpr>(this))
3915+
return ConvertVector->getFPFeaturesInEffect(LO);
39143916
return FPOptions::defaultWithoutTrailingStorage(LO);
39153917
}
39163918

@@ -5451,3 +5453,21 @@ OpenACCAsteriskSizeExpr *
54515453
OpenACCAsteriskSizeExpr::CreateEmpty(const ASTContext &C) {
54525454
return new (C) OpenACCAsteriskSizeExpr({}, C.IntTy);
54535455
}
5456+
5457+
ConvertVectorExpr *ConvertVectorExpr::CreateEmpty(const ASTContext &C,
5458+
bool hasFPFeatures) {
5459+
void *Mem = C.Allocate(totalSizeToAlloc<FPOptionsOverride>(hasFPFeatures),
5460+
alignof(ConvertVectorExpr));
5461+
return new (Mem) ConvertVectorExpr(hasFPFeatures, EmptyShell());
5462+
}
5463+
5464+
ConvertVectorExpr *ConvertVectorExpr::Create(
5465+
const ASTContext &C, Expr *SrcExpr, TypeSourceInfo *TI, QualType DstType,
5466+
ExprValueKind VK, ExprObjectKind OK, SourceLocation BuiltinLoc,
5467+
SourceLocation RParenLoc, FPOptionsOverride FPFeatures) {
5468+
bool HasFPFeatures = FPFeatures.requiresTrailingStorage();
5469+
unsigned Size = totalSizeToAlloc<FPOptionsOverride>(HasFPFeatures);
5470+
void *Mem = C.Allocate(Size, alignof(ConvertVectorExpr));
5471+
return new (Mem) ConvertVectorExpr(SrcExpr, TI, DstType, VK, OK, BuiltinLoc,
5472+
RParenLoc, FPFeatures);
5473+
}

0 commit comments

Comments
 (0)