Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: I30dfad49e2aade3865dfde87deee1281c7fb69dc
  • Loading branch information
Jenkins committed Nov 24, 2024
2 parents d12b14c + c790d6f commit b94cd44
Show file tree
Hide file tree
Showing 64 changed files with 923 additions and 435 deletions.
8 changes: 4 additions & 4 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,10 @@ Changes in existing checks
<clang-tidy/checks/misc/unconventional-assign-operator>` check to avoid
false positive for C++23 deducing this.

- Improved :doc:`misc-use-internal-linkage
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static`` keyword
before type qualifiers such as ``const`` and ``volatile``.

- Improved :doc:`modernize-avoid-c-arrays
<clang-tidy/checks/modernize/avoid-c-arrays>` check to suggest using
``std::span`` as a replacement for parameters of incomplete C array type in
Expand All @@ -237,10 +241,6 @@ Changes in existing checks
<clang-tidy/checks/modernize/loop-convert>` check to fix false positive when
using loop variable in initializer of lambda capture.

- Improved :doc:`misc-use-internal-linkage
<clang-tidy/checks/misc/use-internal-linkage>` check to insert ``static`` keyword
before type qualifiers such as ``const`` and ``volatile``.

- Improved :doc:`modernize-min-max-use-initializer-list
<clang-tidy/checks/modernize/min-max-use-initializer-list>` check by fixing
a false positive when only an implicit conversion happened inside an
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/ASTConcept.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@ static void
CreateUnsatisfiedConstraintRecord(const ASTContext &C,
const UnsatisfiedConstraintRecord &Detail,
UnsatisfiedConstraintRecord *TrailingObject) {
if (Detail.is<Expr *>())
new (TrailingObject) UnsatisfiedConstraintRecord(Detail.get<Expr *>());
if (auto *E = dyn_cast<Expr *>(Detail))
new (TrailingObject) UnsatisfiedConstraintRecord(E);
else {
auto &SubstitutionDiagnostic =
*Detail.get<std::pair<SourceLocation, StringRef> *>();
*cast<std::pair<SourceLocation, StringRef> *>(Detail);
StringRef Message = C.backupStr(SubstitutionDiagnostic.second);
auto *NewSubstDiag = new (C) std::pair<SourceLocation, StringRef>(
SubstitutionDiagnostic.first, Message);
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/ASTContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,10 +374,10 @@ static const Decl &adjustDeclToTemplate(const Decl &D) {
llvm::PointerUnion<ClassTemplateDecl *,
ClassTemplatePartialSpecializationDecl *>
PU = CTSD->getSpecializedTemplateOrPartial();
return PU.is<ClassTemplateDecl *>()
? *static_cast<const Decl *>(PU.get<ClassTemplateDecl *>())
return isa<ClassTemplateDecl *>(PU)
? *static_cast<const Decl *>(cast<ClassTemplateDecl *>(PU))
: *static_cast<const Decl *>(
PU.get<ClassTemplatePartialSpecializationDecl *>());
cast<ClassTemplatePartialSpecializationDecl *>(PU));
}

// Class is instantiated from a member definition of a class template?
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Compiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4033,7 +4033,7 @@ unsigned Compiler<Emitter>::allocateLocalPrimitive(DeclTy &&Src, PrimType Ty,
// (int){12} in C. Consider using Expr::isTemporaryObject() instead
// or isa<MaterializeTemporaryExpr>().
Descriptor *D = P.createDescriptor(Src, Ty, Descriptor::InlineDescMD, IsConst,
Src.is<const Expr *>());
isa<const Expr *>(Src));
Scope::Local Local = this->createLocal(D);
if (auto *VD = dyn_cast_if_present<ValueDecl>(Src.dyn_cast<const Decl *>()))
Locals.insert({VD, Local});
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/AST/ByteCode/Program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ unsigned Program::getOrCreateDummy(const DeclTy &D) {
if (const auto *E = D.dyn_cast<const Expr *>()) {
QT = E->getType();
} else {
const ValueDecl *VD = cast<ValueDecl>(D.get<const Decl *>());
const ValueDecl *VD = cast<ValueDecl>(cast<const Decl *>(D));
IsWeak = VD->isWeak();
QT = VD->getType();
if (const auto *RT = QT->getAs<ReferenceType>())
Expand Down
34 changes: 17 additions & 17 deletions clang/lib/AST/Decl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1991,7 +1991,7 @@ void DeclaratorDecl::setQualifierInfo(NestedNameSpecifierLoc QualifierLoc) {
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
Expand All @@ -2010,7 +2010,7 @@ void DeclaratorDecl::setTrailingRequiresClause(Expr *TrailingRequiresClause) {
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
Expand All @@ -2026,7 +2026,7 @@ void DeclaratorDecl::setTemplateParameterListsInfo(
// Make sure the extended decl info is allocated.
if (!hasExtInfo()) {
// Save (non-extended) type source info pointer.
auto *savedTInfo = DeclInfo.get<TypeSourceInfo*>();
auto *savedTInfo = cast<TypeSourceInfo *>(DeclInfo);
// Allocate external info struct.
DeclInfo = new (getASTContext()) ExtInfo;
// Restore savedTInfo into (extended) decl info.
Expand Down Expand Up @@ -2534,7 +2534,7 @@ EvaluatedStmt *VarDecl::ensureEvaluatedStmt() const {
// work to avoid leaking those, but we do so in VarDecl::evaluateValue
// where we can detect whether there's anything to clean up or not.
Eval = new (getASTContext()) EvaluatedStmt;
Eval->Value = Init.get<Stmt *>();
Eval->Value = cast<Stmt *>(Init);
Init = Eval;
}
return Eval;
Expand Down Expand Up @@ -3017,7 +3017,7 @@ void ParmVarDecl::setUninstantiatedDefaultArg(Expr *arg) {
Expr *ParmVarDecl::getUninstantiatedDefaultArg() {
assert(hasUninstantiatedDefaultArg() &&
"Wrong kind of initialization expression!");
return cast_if_present<Expr>(Init.get<Stmt *>());
return cast_if_present<Expr>(cast<Stmt *>(Init));
}

bool ParmVarDecl::hasDefaultArg() const {
Expand Down Expand Up @@ -4010,12 +4010,12 @@ FunctionDecl::TemplatedKind FunctionDecl::getTemplatedKind() const {
"No other valid types in NamedDecl");
return TK_FunctionTemplate;
}
if (TemplateOrSpecialization.is<MemberSpecializationInfo *>())
if (isa<MemberSpecializationInfo *>(TemplateOrSpecialization))
return TK_MemberSpecialization;
if (TemplateOrSpecialization.is<FunctionTemplateSpecializationInfo *>())
if (isa<FunctionTemplateSpecializationInfo *>(TemplateOrSpecialization))
return TK_FunctionTemplateSpecialization;
if (TemplateOrSpecialization.is
<DependentFunctionTemplateSpecializationInfo*>())
if (isa<DependentFunctionTemplateSpecializationInfo *>(
TemplateOrSpecialization))
return TK_DependentFunctionTemplateSpecialization;

llvm_unreachable("Did we miss a TemplateOrSpecialization type?");
Expand Down Expand Up @@ -4062,9 +4062,9 @@ void FunctionDecl::setDescribedFunctionTemplate(
}

bool FunctionDecl::isFunctionTemplateSpecialization() const {
return TemplateOrSpecialization.is<FunctionTemplateSpecializationInfo *>() ||
TemplateOrSpecialization
.is<DependentFunctionTemplateSpecializationInfo *>();
return isa<FunctionTemplateSpecializationInfo *>(TemplateOrSpecialization) ||
isa<DependentFunctionTemplateSpecializationInfo *>(
TemplateOrSpecialization);
}

void FunctionDecl::setInstantiatedFromDecl(FunctionDecl *FD) {
Expand Down Expand Up @@ -4216,7 +4216,7 @@ void FunctionDecl::setFunctionTemplateSpecialization(
const TemplateArgumentListInfo *TemplateArgsAsWritten,
SourceLocation PointOfInstantiation) {
assert((TemplateOrSpecialization.isNull() ||
TemplateOrSpecialization.is<MemberSpecializationInfo *>()) &&
isa<MemberSpecializationInfo *>(TemplateOrSpecialization)) &&
"Member function is already a specialization");
assert(TSK != TSK_Undeclared &&
"Must specify the type of function template specialization");
Expand Down Expand Up @@ -4287,8 +4287,8 @@ TemplateSpecializationKind FunctionDecl::getTemplateSpecializationKind() const {

// A dependent function template specialization is an explicit specialization,
// except when it's a friend declaration.
if (TemplateOrSpecialization
.is<DependentFunctionTemplateSpecializationInfo *>() &&
if (isa<DependentFunctionTemplateSpecializationInfo *>(
TemplateOrSpecialization) &&
getFriendObjectKind() == FOK_None)
return TSK_ExplicitSpecialization;

Expand Down Expand Up @@ -4331,8 +4331,8 @@ FunctionDecl::getTemplateSpecializationKindForInstantiation() const {
TemplateOrSpecialization.dyn_cast<MemberSpecializationInfo *>())
return MSInfo->getTemplateSpecializationKind();

if (TemplateOrSpecialization
.is<DependentFunctionTemplateSpecializationInfo *>() &&
if (isa<DependentFunctionTemplateSpecializationInfo *>(
TemplateOrSpecialization) &&
getFriendObjectKind() == FOK_None)
return TSK_ExplicitSpecialization;

Expand Down
6 changes: 3 additions & 3 deletions clang/lib/AST/DeclCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2733,14 +2733,14 @@ int64_t CXXCtorInitializer::getID(const ASTContext &Context) const {

TypeLoc CXXCtorInitializer::getBaseClassLoc() const {
if (isBaseInitializer())
return Initializee.get<TypeSourceInfo*>()->getTypeLoc();
return cast<TypeSourceInfo *>(Initializee)->getTypeLoc();
else
return {};
}

const Type *CXXCtorInitializer::getBaseClass() const {
if (isBaseInitializer())
return Initializee.get<TypeSourceInfo*>()->getType().getTypePtr();
return cast<TypeSourceInfo *>(Initializee)->getType().getTypePtr();
else
return nullptr;
}
Expand All @@ -2752,7 +2752,7 @@ SourceLocation CXXCtorInitializer::getSourceLocation() const {
if (isAnyMemberInitializer())
return getMemberLocation();

if (const auto *TSInfo = Initializee.get<TypeSourceInfo *>())
if (const auto *TSInfo = cast<TypeSourceInfo *>(Initializee))
return TSInfo->getTypeLoc().getBeginLoc();

return {};
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/AST/DeclFriend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ FriendDecl::Create(ASTContext &C, DeclContext *DC, SourceLocation L,
SourceLocation EllipsisLoc,
ArrayRef<TemplateParameterList *> FriendTypeTPLists) {
#ifndef NDEBUG
if (Friend.is<NamedDecl *>()) {
const auto *D = Friend.get<NamedDecl*>();
if (const auto *D = dyn_cast<NamedDecl *>(Friend)) {
assert(isa<FunctionDecl>(D) ||
isa<CXXRecordDecl>(D) ||
isa<FunctionTemplateDecl>(D) ||
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/DeclTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,7 @@ ClassTemplateSpecializationDecl::getSpecializedTemplate() const {
if (const auto *PartialSpec =
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization*>())
return PartialSpec->PartialSpecialization->getSpecializedTemplate();
return SpecializedTemplate.get<ClassTemplateDecl*>();
return cast<ClassTemplateDecl *>(SpecializedTemplate);
}

SourceRange
Expand All @@ -1008,7 +1008,7 @@ ClassTemplateSpecializationDecl::getSourceRange() const {
if (const auto *CTPSD =
Pattern.dyn_cast<ClassTemplatePartialSpecializationDecl *>())
return CTPSD->getSourceRange();
return Pattern.get<ClassTemplateDecl *>()->getSourceRange();
return cast<ClassTemplateDecl *>(Pattern)->getSourceRange();
}
case TSK_ExplicitSpecialization: {
SourceRange Range = CXXRecordDecl::getSourceRange();
Expand Down Expand Up @@ -1404,7 +1404,7 @@ VarTemplateDecl *VarTemplateSpecializationDecl::getSpecializedTemplate() const {
if (const auto *PartialSpec =
SpecializedTemplate.dyn_cast<SpecializedPartialSpecialization *>())
return PartialSpec->PartialSpecialization->getSpecializedTemplate();
return SpecializedTemplate.get<VarTemplateDecl *>();
return cast<VarTemplateDecl *>(SpecializedTemplate);
}

SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
Expand All @@ -1419,7 +1419,7 @@ SourceRange VarTemplateSpecializationDecl::getSourceRange() const {
if (const auto *VTPSD =
Pattern.dyn_cast<VarTemplatePartialSpecializationDecl *>())
return VTPSD->getSourceRange();
VarTemplateDecl *VTD = Pattern.get<VarTemplateDecl *>();
VarTemplateDecl *VTD = cast<VarTemplateDecl *>(Pattern);
if (hasInit()) {
if (VarTemplateDecl *Definition = VTD->getDefinition())
return Definition->getSourceRange();
Expand Down
10 changes: 5 additions & 5 deletions clang/lib/AST/ExprCXX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ QualType CXXTypeidExpr::getTypeOperand(const ASTContext &Context) const {
assert(isTypeOperand() && "Cannot call getTypeOperand for typeid(expr)");
Qualifiers Quals;
return Context.getUnqualifiedArrayType(
Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
}

static bool isGLValueFromPointerDeref(const Expr *E) {
Expand Down Expand Up @@ -216,7 +216,7 @@ QualType CXXUuidofExpr::getTypeOperand(ASTContext &Context) const {
assert(isTypeOperand() && "Cannot call getTypeOperand for __uuidof(expr)");
Qualifiers Quals;
return Context.getUnqualifiedArrayType(
Operand.get<TypeSourceInfo *>()->getType().getNonReferenceType(), Quals);
cast<TypeSourceInfo *>(Operand)->getType().getNonReferenceType(), Quals);
}

// CXXScalarValueInitExpr
Expand Down Expand Up @@ -1829,11 +1829,11 @@ void MaterializeTemporaryExpr::setExtendingDecl(ValueDecl *ExtendedBy,

// We may need to allocate extra storage for the mangling number and the
// extended-by ValueDecl.
if (!State.is<LifetimeExtendedTemporaryDecl *>())
if (!isa<LifetimeExtendedTemporaryDecl *>(State))
State = LifetimeExtendedTemporaryDecl::Create(
cast<Expr>(State.get<Stmt *>()), ExtendedBy, ManglingNumber);
cast<Expr>(cast<Stmt *>(State)), ExtendedBy, ManglingNumber);

auto ES = State.get<LifetimeExtendedTemporaryDecl *>();
auto ES = cast<LifetimeExtendedTemporaryDecl *>(State);
ES->ExtendingDecl = ExtendedBy;
ES->ManglingNumber = ManglingNumber;
}
Expand Down
3 changes: 1 addition & 2 deletions clang/lib/AST/ExprConcepts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,7 @@ ConceptSpecializationExpr::Create(const ASTContext &C, ConceptReference *Loc,
const TypeConstraint *
concepts::ExprRequirement::ReturnTypeRequirement::getTypeConstraint() const {
assert(isTypeConstraint());
auto TPL =
TypeConstraintInfo.getPointer().get<TemplateParameterList *>();
auto TPL = cast<TemplateParameterList *>(TypeConstraintInfo.getPointer());
return cast<TemplateTypeParmDecl>(TPL->getParam(0))
->getTypeConstraint();
}
Expand Down
22 changes: 11 additions & 11 deletions clang/lib/AST/ParentMapContext.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ class ParentMapContext::ParentMap {
return DynTypedNode::create(*D);
if (const auto *S = U.dyn_cast<const Stmt *>())
return DynTypedNode::create(*S);
return *U.get<DynTypedNode *>();
return *cast<DynTypedNode *>(U);
}

template <typename NodeTy, typename MapTy>
Expand All @@ -127,17 +127,17 @@ class ParentMapContext::ParentMap {
ParentMap(ASTContext &Ctx);
~ParentMap() {
for (const auto &Entry : PointerParents) {
if (Entry.second.is<DynTypedNode *>()) {
delete Entry.second.get<DynTypedNode *>();
} else if (Entry.second.is<ParentVector *>()) {
delete Entry.second.get<ParentVector *>();
if (auto *DTN = dyn_cast<DynTypedNode *>(Entry.second)) {
delete DTN;
} else if (auto *PV = dyn_cast<ParentVector *>(Entry.second)) {
delete PV;
}
}
for (const auto &Entry : OtherParents) {
if (Entry.second.is<DynTypedNode *>()) {
delete Entry.second.get<DynTypedNode *>();
} else if (Entry.second.is<ParentVector *>()) {
delete Entry.second.get<ParentVector *>();
if (auto *DTN = dyn_cast<DynTypedNode *>(Entry.second)) {
delete DTN;
} else if (auto *PV = dyn_cast<ParentVector *>(Entry.second)) {
delete PV;
}
}
}
Expand Down Expand Up @@ -392,14 +392,14 @@ class ParentMapContext::ParentMap::ASTVisitor
else
NodeOrVector = new DynTypedNode(ParentStack.back());
} else {
if (!NodeOrVector.template is<ParentVector *>()) {
if (!isa<ParentVector *>(NodeOrVector)) {
auto *Vector = new ParentVector(
1, getSingleDynTypedNodeFromParentMap(NodeOrVector));
delete NodeOrVector.template dyn_cast<DynTypedNode *>();
NodeOrVector = Vector;
}

auto *Vector = NodeOrVector.template get<ParentVector *>();
auto *Vector = cast<ParentVector *>(NodeOrVector);
// Skip duplicates for types that have memoization data.
// We must check that the type has memoization data before calling
// llvm::is_contained() because DynTypedNode::operator== can't compare all
Expand Down
8 changes: 4 additions & 4 deletions clang/lib/AST/TemplateName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -151,13 +151,13 @@ TemplateName::NameKind TemplateName::getKind() const {
return Template;
}

if (Storage.is<DependentTemplateName *>())
if (isa<DependentTemplateName *>(Storage))
return DependentTemplate;
if (Storage.is<QualifiedTemplateName *>())
if (isa<QualifiedTemplateName *>(Storage))
return QualifiedTemplate;

UncommonTemplateNameStorage *uncommon
= Storage.get<UncommonTemplateNameStorage*>();
UncommonTemplateNameStorage *uncommon =
cast<UncommonTemplateNameStorage *>(Storage);
if (uncommon->getAsOverloadedStorage())
return OverloadedTemplate;
if (uncommon->getAsAssumedTemplateName())
Expand Down
10 changes: 4 additions & 6 deletions clang/tools/clang-shlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,11 @@ add_clang_library(clang-cpp
${_OBJECTS}
LINK_LIBS
${_DEPS})
# AIX linker does not support version script
if (NOT ${CMAKE_SYSTEM_NAME} MATCHES "AIX")
configure_file(simple_version_script.map.in simple_version_script.map)

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(clang-cpp PRIVATE LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
endif()
configure_file(simple_version_script.map.in simple_version_script.map)

if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
target_link_options(clang-cpp PRIVATE LINKER:--version-script,${CMAKE_CURRENT_BINARY_DIR}/simple_version_script.map)
endif()

# Optimize function calls for default visibility definitions to avoid PLT and
Expand Down
1 change: 1 addition & 0 deletions lld/COFF/Config.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,7 @@ struct Configuration {
bool is64() const { return llvm::COFF::is64Bit(machine); }

llvm::COFF::MachineTypes machine = IMAGE_FILE_MACHINE_UNKNOWN;
bool machineInferred = false;
size_t wordsize;
bool verbose = false;
WindowsSubsystem subsystem = llvm::COFF::IMAGE_SUBSYSTEM_UNKNOWN;
Expand Down
Loading

0 comments on commit b94cd44

Please sign in to comment.