Skip to content

Commit 163204a

Browse files
committed
Merge branch 'main' into xegpu_unroll_patterns
2 parents 96cb62b + 20d6def commit 163204a

File tree

564 files changed

+24333
-4929
lines changed

Some content is hidden

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

564 files changed

+24333
-4929
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,8 @@ Improvements to Clang's diagnostics
506506
behavior of the C99 feature as it was introduced into C++20. Fixes #GH47037
507507
- ``-Wreserved-identifier`` now fires on reserved parameter names in a function
508508
declaration which is not a definition.
509+
- Clang now prints the namespace for an attribute, if any,
510+
when emitting an unknown attribute diagnostic.
509511

510512
- Several compatibility diagnostics that were incorrectly being grouped under
511513
``-Wpre-c++20-compat`` are now part of ``-Wc++20-compat``. (#GH138775)
@@ -564,7 +566,7 @@ Bug Fixes in This Version
564566
- Fixed a bug where an attribute before a ``pragma clang attribute`` or
565567
``pragma clang __debug`` would cause an assertion. Instead, this now diagnoses
566568
the invalid attribute location appropriately. (#GH137861)
567-
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
569+
- Fixed a crash when a malformed ``_Pragma`` directive appears as part of an
568570
``#include`` directive. (#GH138094)
569571
- Fixed a crash during constant evaluation involving invalid lambda captures
570572
(#GH138832)
@@ -673,7 +675,6 @@ Bug Fixes to C++ Support
673675
- Fixed an assertion when trying to constant-fold various builtins when the argument
674676
referred to a reference to an incomplete type. (#GH129397)
675677
- Fixed a crash when a cast involved a parenthesized aggregate initialization in dependent context. (#GH72880)
676-
- Fixed a crash when forming an invalid function type in a dependent context. (#GH138657) (#GH115725) (#GH68852)
677678
- No longer crashes when instantiating invalid variable template specialization
678679
whose type depends on itself. (#GH51347), (#GH55872)
679680
- Improved parser recovery of invalid requirement expressions. In turn, this
@@ -900,6 +901,8 @@ OpenMP Support
900901
- Added support 'no_openmp_constructs' assumption clause.
901902
- Added support for 'self_maps' in map and requirement clause.
902903
- Added support for 'omp stripe' directive.
904+
- Fixed a crashing bug with ``omp tile sizes`` if the argument to ``sizes`` was
905+
an invalid expression. (#GH139073)
903906

904907
Improvements
905908
^^^^^^^^^^^^

clang/include/clang/AST/OpenMPClause.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9475,15 +9475,17 @@ class ConstOMPClauseVisitor :
94759475
class OMPClausePrinter final : public OMPClauseVisitor<OMPClausePrinter> {
94769476
raw_ostream &OS;
94779477
const PrintingPolicy &Policy;
9478+
unsigned Version;
94789479

94799480
/// Process clauses with list of variables.
94809481
template <typename T> void VisitOMPClauseList(T *Node, char StartSym);
94819482
/// Process motion clauses.
94829483
template <typename T> void VisitOMPMotionClause(T *Node);
94839484

94849485
public:
9485-
OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy)
9486-
: OS(OS), Policy(Policy) {}
9486+
OMPClausePrinter(raw_ostream &OS, const PrintingPolicy &Policy,
9487+
unsigned OpenMPVersion)
9488+
: OS(OS), Policy(Policy), Version(OpenMPVersion) {}
94879489

94889490
#define GEN_CLANG_CLAUSE_CLASS
94899491
#define CLAUSE_CLASS(Enum, Str, Class) void Visit##Class(Class *S);

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ class AttributeCommonInfo {
196196
/// with surrounding underscores removed as appropriate (e.g.
197197
/// __gnu__::__attr__ will be normalized to gnu::attr).
198198
std::string getNormalizedFullName() const;
199+
SourceRange getNormalizedRange() const;
199200

200201
bool isDeclspecAttribute() const { return SyntaxUsed == AS_Declspec; }
201202
bool isMicrosoftAttribute() const { return SyntaxUsed == AS_Microsoft; }

clang/include/clang/CIR/MissingFeatures.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ struct MissingFeatures {
104104
static bool opCallExtParameterInfo() { return false; }
105105
static bool opCallCIRGenFuncInfoParamInfo() { return false; }
106106
static bool opCallCIRGenFuncInfoExtParamInfo() { return false; }
107+
static bool opCallLandingPad() { return false; }
108+
static bool opCallContinueBlock() { return false; }
107109

108110
// ScopeOp handling
109111
static bool opScopeCleanupRegion() { return false; }

clang/include/clang/Driver/Options.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8452,6 +8452,11 @@ def objc_isystem : Separate<["-"], "objc-isystem">,
84528452
def objcxx_isystem : Separate<["-"], "objcxx-isystem">,
84538453
MetaVarName<"<directory>">,
84548454
HelpText<"Add directory to the ObjC++ SYSTEM include search path">;
8455+
def internal_iframework : Separate<["-"], "internal-iframework">,
8456+
MetaVarName<"<directory>">,
8457+
HelpText<"Add directory to the internal system framework search path; these "
8458+
"are assumed to not be user-provided and are used to model system "
8459+
"and standard frameworks' paths.">;
84558460
def internal_isystem : Separate<["-"], "internal-isystem">,
84568461
MetaVarName<"<directory>">,
84578462
HelpText<"Add directory to the internal system include search path; these "

clang/include/clang/Driver/ToolChain.h

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -226,6 +226,9 @@ class ToolChain {
226226

227227
/// \name Utilities for implementing subclasses.
228228
///@{
229+
static void addSystemFrameworkInclude(const llvm::opt::ArgList &DriverArgs,
230+
llvm::opt::ArgStringList &CC1Args,
231+
const Twine &Path);
229232
static void addSystemInclude(const llvm::opt::ArgList &DriverArgs,
230233
llvm::opt::ArgStringList &CC1Args,
231234
const Twine &Path);
@@ -236,6 +239,9 @@ class ToolChain {
236239
addExternCSystemIncludeIfExists(const llvm::opt::ArgList &DriverArgs,
237240
llvm::opt::ArgStringList &CC1Args,
238241
const Twine &Path);
242+
static void addSystemFrameworkIncludes(const llvm::opt::ArgList &DriverArgs,
243+
llvm::opt::ArgStringList &CC1Args,
244+
ArrayRef<StringRef> Paths);
239245
static void addSystemIncludes(const llvm::opt::ArgList &DriverArgs,
240246
llvm::opt::ArgStringList &CC1Args,
241247
ArrayRef<StringRef> Paths);

clang/include/clang/InstallAPI/DylibVerifier.h

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,31 @@ enum class VerificationMode {
2525
Pedantic,
2626
};
2727

28-
using LibAttrs = llvm::StringMap<ArchitectureSet>;
2928
using ReexportedInterfaces = llvm::SmallVector<llvm::MachO::InterfaceFile, 8>;
3029

30+
/// Represents dynamic library specific attributes that are tied to
31+
/// architecture slices. It is commonly used for comparing options
32+
/// passed on the command line to installapi and what exists in dylib load
33+
/// commands.
34+
class LibAttrs {
35+
public:
36+
using Entry = std::pair<std::string, ArchitectureSet>;
37+
using AttrsToArchs = llvm::SmallVector<Entry, 10>;
38+
39+
// Mutable access to architecture set tied to the input attribute.
40+
ArchitectureSet &getArchSet(StringRef Attr);
41+
// Get entry based on the attribute.
42+
std::optional<Entry> find(StringRef Attr) const;
43+
// Immutable access to underlying container.
44+
const AttrsToArchs &get() const { return LibraryAttributes; };
45+
// Mutable access to underlying container.
46+
AttrsToArchs &get() { return LibraryAttributes; };
47+
bool operator==(const LibAttrs &Other) const { return Other.get() == get(); };
48+
49+
private:
50+
AttrsToArchs LibraryAttributes;
51+
};
52+
3153
// Pointers to information about a zippered declaration used for
3254
// querying and reporting violations against different
3355
// declarations that all map to the same symbol.

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 61 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -238,8 +238,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
238238
case CK_DerivedToBaseMemberPointer: {
239239
assert(classifyPrim(CE->getType()) == PT_MemberPtr);
240240
assert(classifyPrim(SubExpr->getType()) == PT_MemberPtr);
241-
const auto *FromMP = SubExpr->getType()->getAs<MemberPointerType>();
242-
const auto *ToMP = CE->getType()->getAs<MemberPointerType>();
241+
const auto *FromMP = SubExpr->getType()->castAs<MemberPointerType>();
242+
const auto *ToMP = CE->getType()->castAs<MemberPointerType>();
243243

244244
unsigned DerivedOffset =
245245
Ctx.collectBaseOffset(ToMP->getMostRecentCXXRecordDecl(),
@@ -254,8 +254,8 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
254254
case CK_BaseToDerivedMemberPointer: {
255255
assert(classifyPrim(CE) == PT_MemberPtr);
256256
assert(classifyPrim(SubExpr) == PT_MemberPtr);
257-
const auto *FromMP = SubExpr->getType()->getAs<MemberPointerType>();
258-
const auto *ToMP = CE->getType()->getAs<MemberPointerType>();
257+
const auto *FromMP = SubExpr->getType()->castAs<MemberPointerType>();
258+
const auto *ToMP = CE->getType()->castAs<MemberPointerType>();
259259

260260
unsigned DerivedOffset =
261261
Ctx.collectBaseOffset(FromMP->getMostRecentCXXRecordDecl(),
@@ -320,37 +320,38 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
320320
}
321321

322322
case CK_IntegralToFloating: {
323-
std::optional<PrimType> FromT = classify(SubExpr->getType());
324-
if (!FromT)
323+
if (!CE->getType()->isRealFloatingType())
325324
return false;
326-
327325
if (!this->visit(SubExpr))
328326
return false;
329-
330327
const auto *TargetSemantics = &Ctx.getFloatSemantics(CE->getType());
331-
return this->emitCastIntegralFloating(*FromT, TargetSemantics,
332-
getFPOptions(CE), CE);
328+
return this->emitCastIntegralFloating(
329+
classifyPrim(SubExpr), TargetSemantics, getFPOptions(CE), CE);
333330
}
334331

335-
case CK_FloatingToBoolean:
336-
case CK_FloatingToIntegral: {
337-
338-
std::optional<PrimType> ToT = classify(CE->getType());
339-
340-
if (!ToT)
332+
case CK_FloatingToBoolean: {
333+
if (!SubExpr->getType()->isRealFloatingType() ||
334+
!CE->getType()->isBooleanType())
341335
return false;
342-
336+
if (const auto *FL = dyn_cast<FloatingLiteral>(SubExpr))
337+
return this->emitConstBool(FL->getValue().isNonZero(), CE);
343338
if (!this->visit(SubExpr))
344339
return false;
340+
return this->emitCastFloatingIntegralBool(getFPOptions(CE), CE);
341+
}
345342

343+
case CK_FloatingToIntegral: {
344+
if (!this->visit(SubExpr))
345+
return false;
346+
PrimType ToT = classifyPrim(CE);
346347
if (ToT == PT_IntAP)
347348
return this->emitCastFloatingIntegralAP(Ctx.getBitWidth(CE->getType()),
348349
getFPOptions(CE), CE);
349350
if (ToT == PT_IntAPS)
350351
return this->emitCastFloatingIntegralAPS(Ctx.getBitWidth(CE->getType()),
351352
getFPOptions(CE), CE);
352353

353-
return this->emitCastFloatingIntegral(*ToT, getFPOptions(CE), CE);
354+
return this->emitCastFloatingIntegral(ToT, getFPOptions(CE), CE);
354355
}
355356

356357
case CK_NullToPointer:
@@ -395,9 +396,7 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
395396
case CK_ArrayToPointerDecay: {
396397
if (!this->visit(SubExpr))
397398
return false;
398-
if (!this->emitArrayDecay(CE))
399-
return false;
400-
return true;
399+
return this->emitArrayDecay(CE);
401400
}
402401

403402
case CK_IntegralToPointer: {
@@ -480,47 +479,63 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
480479
return this->emitBuiltinBitCast(CE);
481480

482481
case CK_IntegralToBoolean:
483-
case CK_FixedPointToBoolean:
482+
case CK_FixedPointToBoolean: {
483+
// HLSL uses this to cast to one-element vectors.
484+
std::optional<PrimType> FromT = classify(SubExpr->getType());
485+
if (!FromT)
486+
return false;
487+
488+
if (const auto *IL = dyn_cast<IntegerLiteral>(SubExpr))
489+
return this->emitConst(IL->getValue(), CE);
490+
if (!this->visit(SubExpr))
491+
return false;
492+
return this->emitCast(*FromT, classifyPrim(CE), CE);
493+
}
494+
484495
case CK_BooleanToSignedIntegral:
485496
case CK_IntegralCast: {
486497
std::optional<PrimType> FromT = classify(SubExpr->getType());
487498
std::optional<PrimType> ToT = classify(CE->getType());
488-
489499
if (!FromT || !ToT)
490500
return false;
491501

492-
if (!this->visit(SubExpr))
493-
return false;
502+
// Try to emit a casted known constant value directly.
503+
if (const auto *IL = dyn_cast<IntegerLiteral>(SubExpr)) {
504+
if (ToT != PT_IntAP && ToT != PT_IntAPS && FromT != PT_IntAP &&
505+
FromT != PT_IntAPS && !CE->getType()->isEnumeralType())
506+
return this->emitConst(IL->getValue(), CE);
507+
if (!this->emitConst(IL->getValue(), SubExpr))
508+
return false;
509+
} else {
510+
if (!this->visit(SubExpr))
511+
return false;
512+
}
494513

495514
// Possibly diagnose casts to enum types if the target type does not
496515
// have a fixed size.
497516
if (Ctx.getLangOpts().CPlusPlus && CE->getType()->isEnumeralType()) {
498-
if (const auto *ET = CE->getType().getCanonicalType()->getAs<EnumType>();
499-
ET && !ET->getDecl()->isFixed()) {
517+
if (const auto *ET = CE->getType().getCanonicalType()->castAs<EnumType>();
518+
!ET->getDecl()->isFixed()) {
500519
if (!this->emitCheckEnumValue(*FromT, ET->getDecl(), CE))
501520
return false;
502521
}
503522
}
504523

505-
auto maybeNegate = [&]() -> bool {
506-
if (CE->getCastKind() == CK_BooleanToSignedIntegral)
507-
return this->emitNeg(*ToT, CE);
508-
return true;
509-
};
510-
511-
if (ToT == PT_IntAP)
512-
return this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
513-
maybeNegate();
514-
if (ToT == PT_IntAPS)
515-
return this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE) &&
516-
maybeNegate();
517-
518-
if (FromT == ToT)
519-
return true;
520-
if (!this->emitCast(*FromT, *ToT, CE))
521-
return false;
522-
523-
return maybeNegate();
524+
if (ToT == PT_IntAP) {
525+
if (!this->emitCastAP(*FromT, Ctx.getBitWidth(CE->getType()), CE))
526+
return false;
527+
} else if (ToT == PT_IntAPS) {
528+
if (!this->emitCastAPS(*FromT, Ctx.getBitWidth(CE->getType()), CE))
529+
return false;
530+
} else {
531+
if (FromT == ToT)
532+
return true;
533+
if (!this->emitCast(*FromT, *ToT, CE))
534+
return false;
535+
}
536+
if (CE->getCastKind() == CK_BooleanToSignedIntegral)
537+
return this->emitNeg(*ToT, CE);
538+
return true;
524539
}
525540

526541
case CK_PointerToBoolean:

clang/lib/AST/ByteCode/Context.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -219,10 +219,6 @@ std::optional<PrimType> Context::classify(QualType T) const {
219219
if (T->isBooleanType())
220220
return PT_Bool;
221221

222-
// We map these to primitive arrays.
223-
if (T->isAnyComplexType() || T->isVectorType())
224-
return std::nullopt;
225-
226222
if (T->isSignedIntegerOrEnumerationType()) {
227223
switch (Ctx.getIntWidth(T)) {
228224
case 64:
@@ -259,13 +255,9 @@ std::optional<PrimType> Context::classify(QualType T) const {
259255
if (T->isNullPtrType())
260256
return PT_Ptr;
261257

262-
if (T->isFloatingType())
258+
if (T->isRealFloatingType())
263259
return PT_Float;
264260

265-
if (T->isSpecificBuiltinType(BuiltinType::BoundMember) ||
266-
T->isMemberPointerType())
267-
return PT_MemberPtr;
268-
269261
if (T->isFunctionPointerType() || T->isFunctionReferenceType() ||
270262
T->isFunctionType() || T->isBlockPointerType())
271263
return PT_Ptr;
@@ -279,9 +271,14 @@ std::optional<PrimType> Context::classify(QualType T) const {
279271
if (const auto *DT = dyn_cast<DecltypeType>(T))
280272
return classify(DT->getUnderlyingType());
281273

274+
if (T->isSpecificBuiltinType(BuiltinType::BoundMember) ||
275+
T->isMemberPointerType())
276+
return PT_MemberPtr;
277+
282278
if (T->isFixedPointType())
283279
return PT_FixedPoint;
284280

281+
// Vector and complex types get here.
285282
return std::nullopt;
286283
}
287284

clang/lib/AST/Decl.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3350,7 +3350,8 @@ bool FunctionDecl::isMSVCRTEntryPoint() const {
33503350
// semantic analysis for these functions remains the same.
33513351

33523352
// MSVCRT entry points only exist on MSVCRT targets.
3353-
if (!TUnit->getASTContext().getTargetInfo().getTriple().isOSMSVCRT())
3353+
if (!TUnit->getASTContext().getTargetInfo().getTriple().isOSMSVCRT() &&
3354+
!TUnit->getASTContext().getTargetInfo().getTriple().isUEFI())
33543355
return false;
33553356

33563357
// Nameless functions like constructors cannot be entry points.

0 commit comments

Comments
 (0)