15 changes: 13 additions & 2 deletions clang/lib/Driver/ToolChain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1307,9 +1307,14 @@ void ToolChain::AddCCKextLibArgs(const ArgList &Args,

bool ToolChain::isFastMathRuntimeAvailable(const ArgList &Args,
std::string &Path) const {
// Don't implicitly link in mode-changing libraries in a shared library, since
// this can have very deleterious effects. See the various links from
// https://github.com/llvm/llvm-project/issues/57589 for more information.
bool Default = !Args.hasArgNoClaim(options::OPT_shared);

// Do not check for -fno-fast-math or -fno-unsafe-math when -Ofast passed
// (to keep the linker options consistent with gcc and clang itself).
if (!isOptimizationLevelFast(Args)) {
if (Default && !isOptimizationLevelFast(Args)) {
// Check if -ffast-math or -funsafe-math.
Arg *A =
Args.getLastArg(options::OPT_ffast_math, options::OPT_fno_fast_math,
Expand All @@ -1318,8 +1323,14 @@ bool ToolChain::isFastMathRuntimeAvailable(const ArgList &Args,

if (!A || A->getOption().getID() == options::OPT_fno_fast_math ||
A->getOption().getID() == options::OPT_fno_unsafe_math_optimizations)
return false;
Default = false;
}

// Whatever decision came as a result of the above implicit settings, either
// -mdaz-ftz or -mno-daz-ftz is capable of overriding it.
if (!Args.hasFlag(options::OPT_mdaz_ftz, options::OPT_mno_daz_ftz, Default))
return false;

// If crtfastmath.o exists add it to the arguments.
Path = GetFilePath("crtfastmath.o");
return (Path != "crtfastmath.o"); // Not found.
Expand Down
2 changes: 0 additions & 2 deletions clang/lib/Driver/ToolChains/AIX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,9 +376,7 @@ void AIX::AddOpenMPIncludeArgs(const ArgList &DriverArgs,
addSystemInclude(DriverArgs, CC1Args, PathOpenMP.str());
break;
case Driver::OMPRT_IOMP5:
LLVM_FALLTHROUGH;
case Driver::OMPRT_GOMP:
LLVM_FALLTHROUGH;
case Driver::OMPRT_Unknown:
// Unknown / unsupported include paths.
break;
Expand Down
13 changes: 9 additions & 4 deletions clang/lib/Driver/ToolChains/Clang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7262,10 +7262,15 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
Args.addOptInFlag(CmdArgs, options::OPT_frelaxed_template_template_args,
options::OPT_fno_relaxed_template_template_args);

// -fsized-deallocation is off by default, as it is an ABI-breaking change for
// most platforms.
Args.addOptInFlag(CmdArgs, options::OPT_fsized_deallocation,
options::OPT_fno_sized_deallocation);
// -fsized-deallocation is on by default in C++14 onwards and otherwise off
// by default.
if (Arg *A = Args.getLastArg(options::OPT_fsized_deallocation,
options::OPT_fno_sized_deallocation)) {
if (A->getOption().matches(options::OPT_fno_sized_deallocation))
CmdArgs.push_back("-fno-sized-deallocation");
else
CmdArgs.push_back("-fsized-deallocation");
}

// -faligned-allocation is on by default in C++17 onwards and otherwise off
// by default.
Expand Down
58 changes: 55 additions & 3 deletions clang/lib/Driver/ToolChains/Darwin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2912,16 +2912,68 @@ static bool sdkSupportsBuiltinModules(const Darwin::DarwinPlatformKind &TargetPl
}
}

void Darwin::addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const {
static inline llvm::VersionTuple
sizedDeallocMinVersion(llvm::Triple::OSType OS) {
switch (OS) {
default:
break;
case llvm::Triple::Darwin:
case llvm::Triple::MacOSX: // Earliest supporting version is 10.12.
return llvm::VersionTuple(10U, 12U);
case llvm::Triple::IOS:
case llvm::Triple::TvOS: // Earliest supporting version is 10.0.0.
return llvm::VersionTuple(10U);
case llvm::Triple::WatchOS: // Earliest supporting version is 3.0.0.
return llvm::VersionTuple(3U);
}

llvm_unreachable("Unexpected OS");
}

bool Darwin::isSizedDeallocationUnavailable() const {
llvm::Triple::OSType OS;

if (isTargetMacCatalyst())
return TargetVersion < sizedDeallocMinVersion(llvm::Triple::MacOSX);
switch (TargetPlatform) {
case MacOS: // Earlier than 10.12.
OS = llvm::Triple::MacOSX;
break;
case IPhoneOS:
OS = llvm::Triple::IOS;
break;
case TvOS: // Earlier than 10.0.
OS = llvm::Triple::TvOS;
break;
case WatchOS: // Earlier than 3.0.
OS = llvm::Triple::WatchOS;
break;
case DriverKit:
case XROS:
// Always available.
return false;
}

return TargetVersion < sizedDeallocMinVersion(OS);
}

void Darwin::addClangTargetOptions(
const llvm::opt::ArgList &DriverArgs, llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const {
// Pass "-faligned-alloc-unavailable" only when the user hasn't manually
// enabled or disabled aligned allocations.
if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
options::OPT_fno_aligned_allocation) &&
isAlignedAllocationUnavailable())
CC1Args.push_back("-faligned-alloc-unavailable");

// Pass "-fno-sized-deallocation" only when the user hasn't manually enabled
// or disabled sized deallocations.
if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
options::OPT_fno_sized_deallocation) &&
isSizedDeallocationUnavailable())
CC1Args.push_back("-fno-sized-deallocation");

addClangCC1ASTargetOptions(DriverArgs, CC1Args);

// Enable compatibility mode for NSItemProviderCompletionHandler in
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/Driver/ToolChains/Darwin.h
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,10 @@ class LLVM_LIBRARY_VISIBILITY Darwin : public MachO {
/// targeting.
bool isAlignedAllocationUnavailable() const;

/// Return true if c++14 sized deallocation functions are not implemented in
/// the c++ standard library of the deployment target we are targeting.
bool isSizedDeallocationUnavailable() const;

void addClangTargetOptions(const llvm::opt::ArgList &DriverArgs,
llvm::opt::ArgStringList &CC1Args,
Action::OffloadKind DeviceOffloadKind) const override;
Expand Down
19 changes: 0 additions & 19 deletions clang/lib/Driver/ToolChains/Linux.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -842,25 +842,6 @@ void Linux::addProfileRTLibs(const llvm::opt::ArgList &Args,
ToolChain::addProfileRTLibs(Args, CmdArgs);
}

llvm::DenormalMode
Linux::getDefaultDenormalModeForType(const llvm::opt::ArgList &DriverArgs,
const JobAction &JA,
const llvm::fltSemantics *FPType) const {
switch (getTriple().getArch()) {
case llvm::Triple::x86:
case llvm::Triple::x86_64: {
std::string Unused;
// DAZ and FTZ are turned on in crtfastmath.o
if (!DriverArgs.hasArg(options::OPT_nostdlib, options::OPT_nostartfiles) &&
isFastMathRuntimeAvailable(DriverArgs, Unused))
return llvm::DenormalMode::getPreserveSign();
return llvm::DenormalMode::getIEEE();
}
default:
return llvm::DenormalMode::getIEEE();
}
}

void Linux::addExtraOpts(llvm::opt::ArgStringList &CmdArgs) const {
for (const auto &Opt : ExtraOpts)
CmdArgs.push_back(Opt.c_str());
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Driver/ToolChains/Linux.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,10 +59,6 @@ class LLVM_LIBRARY_VISIBILITY Linux : public Generic_ELF {

std::vector<std::string> ExtraOpts;

llvm::DenormalMode getDefaultDenormalModeForType(
const llvm::opt::ArgList &DriverArgs, const JobAction &JA,
const llvm::fltSemantics *FPType = nullptr) const override;

const char *getDefaultLinker() const override;

protected:
Expand Down
6 changes: 6 additions & 0 deletions clang/lib/Driver/ToolChains/ZOS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ void ZOS::addClangTargetOptions(const ArgList &DriverArgs,
if (!DriverArgs.hasArgNoClaim(options::OPT_faligned_allocation,
options::OPT_fno_aligned_allocation))
CC1Args.push_back("-faligned-alloc-unavailable");

// Pass "-fno-sized-deallocation" only when the user hasn't manually enabled
// or disabled sized deallocations.
if (!DriverArgs.hasArgNoClaim(options::OPT_fsized_deallocation,
options::OPT_fno_sized_deallocation))
CC1Args.push_back("-fno-sized-deallocation");
}

void zos::Assembler::ConstructJob(Compilation &C, const JobAction &JA,
Expand Down
3 changes: 3 additions & 0 deletions clang/lib/Format/Format.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3116,6 +3116,7 @@ static void sortCppIncludes(const FormatStyle &Style,
return;
}

const auto OldCursor = Cursor ? *Cursor : 0;
std::string result;
for (unsigned Index : Indices) {
if (!result.empty()) {
Expand All @@ -3139,6 +3140,8 @@ static void sortCppIncludes(const FormatStyle &Style,
// the entire range of blocks. Otherwise, no replacement is generated.
if (replaceCRLF(result) == replaceCRLF(std::string(Code.substr(
IncludesBeginOffset, IncludesBlockSize)))) {
if (Cursor)
*Cursor = OldCursor;
return;
}

Expand Down
3 changes: 1 addition & 2 deletions clang/lib/Frontend/InitPreprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,7 @@ static void InitializeStandardPredefinedMacros(const TargetInfo &TI,
Twine((unsigned)LangOpts.getHLSLVersion()));

if (LangOpts.NativeHalfType)
Builder.defineMacro("__HLSL_ENABLE_16_BIT",
Twine((unsigned)LangOpts.getHLSLVersion()));
Builder.defineMacro("__HLSL_ENABLE_16_BIT", "1");

// Shader target information
// "enums" for shader stages
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Headers/cpuid.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#ifndef __CPUID_H
#define __CPUID_H

#if !(__x86_64__ || __i386__)
#if !defined(__x86_64__) && !defined(__i386__)
#error this header is for x86 only
#endif

Expand Down Expand Up @@ -256,7 +256,7 @@
#define bit_AVX10_256 0x00020000
#define bit_AVX10_512 0x00040000

#if __i386__
#ifdef __i386__
#define __cpuid(__leaf, __eax, __ebx, __ecx, __edx) \
__asm("cpuid" : "=a"(__eax), "=b" (__ebx), "=c"(__ecx), "=d"(__edx) \
: "0"(__leaf))
Expand Down Expand Up @@ -285,7 +285,7 @@ static __inline unsigned int __get_cpuid_max (unsigned int __leaf,
unsigned int *__sig)
{
unsigned int __eax, __ebx, __ecx, __edx;
#if __i386__
#ifdef __i386__
int __cpuid_supported;

__asm(" pushfl\n"
Expand Down
26 changes: 17 additions & 9 deletions clang/lib/Parse/ParseExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include "clang/Sema/ParsedTemplate.h"
#include "clang/Sema/Scope.h"
#include "clang/Sema/SemaCUDA.h"
#include "clang/Sema/SemaOpenACC.h"
#include "clang/Sema/SemaOpenMP.h"
#include "clang/Sema/SemaSYCL.h"
#include "clang/Sema/TypoCorrection.h"
Expand Down Expand Up @@ -2070,15 +2071,22 @@ Parser::ParsePostfixExpressionSuffix(ExprResult LHS) {
if (!LHS.isInvalid() && !HasError && !Length.isInvalid() &&
!Stride.isInvalid() && Tok.is(tok::r_square)) {
if (ColonLocFirst.isValid() || ColonLocSecond.isValid()) {
// FIXME: OpenACC hasn't implemented Sema/Array section handling at a
// semantic level yet. For now, just reuse the OpenMP implementation
// as it gets the parsing/type management mostly right, and we can
// replace this call to ActOnOpenACCArraySectionExpr in the future.
// Eventually we'll genericize the OPenMPArraySectionExpr type as
// well.
LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(), RLoc);
// Like above, AllowOpenACCArraySections is 'more specific' and only
// enabled when actively parsing a 'var' in a 'var-list' during
// clause/'cache' construct parsing, so it is more specific. So we
// should do it first, so that the correct node gets created.
if (AllowOpenACCArraySections) {
assert(!Stride.isUsable() && !ColonLocSecond.isValid() &&
"Stride/second colon not allowed for OpenACC");
LHS = Actions.OpenACC().ActOnArraySectionExpr(
LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
ColonLocFirst, Length.get(), RLoc);
} else {
LHS = Actions.OpenMP().ActOnOMPArraySectionExpr(
LHS.get(), Loc, ArgExprs.empty() ? nullptr : ArgExprs[0],
ColonLocFirst, ColonLocSecond, Length.get(), Stride.get(),
RLoc);
}
} else {
LHS = Actions.ActOnArraySubscriptExpr(getCurScope(), LHS.get(), Loc,
ArgExprs, RLoc);
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Parse/ParseOpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -327,7 +327,7 @@ OpenACCReductionOperator ParseReductionOperator(Parser &P) {
return OpenACCReductionOperator::Max;
if (ReductionKindTok.getIdentifierInfo()->isStr("min"))
return OpenACCReductionOperator::Min;
LLVM_FALLTHROUGH;
[[fallthrough]];
default:
P.Diag(ReductionKindTok, diag::err_acc_invalid_reduction_operator);
return OpenACCReductionOperator::Invalid;
Expand Down Expand Up @@ -945,7 +945,7 @@ Parser::OpenACCClauseParseResult Parser::ParseOpenACCClauseParams(
// the 'update' clause, so we have to handle it here. U se an assert to
// make sure we get the right differentiator.
assert(DirKind == OpenACCDirectiveKind::Update);
LLVM_FALLTHROUGH;
[[fallthrough]];
case OpenACCClauseKind::Attach:
case OpenACCClauseKind::Copy:
case OpenACCClauseKind::Delete:
Expand Down
6 changes: 4 additions & 2 deletions clang/lib/Sema/SemaChecking.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18724,8 +18724,10 @@ void Sema::CheckArrayAccess(const Expr *expr) {
expr = cast<MemberExpr>(expr)->getBase();
break;
}
case Stmt::OMPArraySectionExprClass: {
const OMPArraySectionExpr *ASE = cast<OMPArraySectionExpr>(expr);
case Stmt::ArraySectionExprClass: {
const ArraySectionExpr *ASE = cast<ArraySectionExpr>(expr);
// FIXME: We should probably be checking all of the elements to the
// 'length' here as well.
if (ASE->getLowerBound())
CheckArrayAccess(ASE->getBase(), ASE->getLowerBound(),
/*ASE=*/nullptr, AllowOnePastEnd > 0);
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaExceptionSpec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1314,7 +1314,7 @@ CanThrowResult Sema::canThrow(const Stmt *S) {
// Some might be dependent for other reasons.
case Expr::ArraySubscriptExprClass:
case Expr::MatrixSubscriptExprClass:
case Expr::OMPArraySectionExprClass:
case Expr::ArraySectionExprClass:
case Expr::OMPArrayShapingExprClass:
case Expr::OMPIteratorExprClass:
case Expr::BinaryOperatorClass:
Expand Down
24 changes: 16 additions & 8 deletions clang/lib/Sema/SemaExpr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5069,11 +5069,18 @@ ExprResult Sema::ActOnArraySubscriptExpr(Scope *S, Expr *base,
SourceLocation rbLoc) {

if (base && !base->getType().isNull() &&
base->hasPlaceholderType(BuiltinType::OMPArraySection))
return OpenMP().ActOnOMPArraySectionExpr(base, lbLoc, ArgExprs.front(),
SourceLocation(), SourceLocation(),
/*Length*/ nullptr,
/*Stride=*/nullptr, rbLoc);
base->hasPlaceholderType(BuiltinType::ArraySection)) {
auto *AS = cast<ArraySectionExpr>(base);
if (AS->isOMPArraySection())
return OpenMP().ActOnOMPArraySectionExpr(
base, lbLoc, ArgExprs.front(), SourceLocation(), SourceLocation(),
/*Length*/ nullptr,
/*Stride=*/nullptr, rbLoc);

return OpenACC().ActOnArraySectionExpr(base, lbLoc, ArgExprs.front(),
SourceLocation(), /*Length*/ nullptr,
rbLoc);
}

// Since this might be a postfix expression, get rid of ParenListExprs.
if (isa<ParenListExpr>(base)) {
Expand Down Expand Up @@ -6361,7 +6368,7 @@ static bool isPlaceholderToRemoveAsArg(QualType type) {
case BuiltinType::BoundMember:
case BuiltinType::BuiltinFn:
case BuiltinType::IncompleteMatrixIdx:
case BuiltinType::OMPArraySection:
case BuiltinType::ArraySection:
case BuiltinType::OMPArrayShaping:
case BuiltinType::OMPIterator:
return true;
Expand Down Expand Up @@ -21343,8 +21350,9 @@ ExprResult Sema::CheckPlaceholderExpr(Expr *E) {
return ExprError();

// Expressions of unknown type.
case BuiltinType::OMPArraySection:
Diag(E->getBeginLoc(), diag::err_omp_array_section_use);
case BuiltinType::ArraySection:
Diag(E->getBeginLoc(), diag::err_array_section_use)
<< cast<ArraySectionExpr>(E)->isOMPArraySection();
return ExprError();

// Expressions of unknown type.
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Sema/SemaInit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7753,9 +7753,9 @@ static void visitLocalsRetainedByReferenceBinding(IndirectLocalPath &Path,
break;
}

case Stmt::OMPArraySectionExprClass: {
case Stmt::ArraySectionExprClass: {
visitLocalsRetainedByInitializer(Path,
cast<OMPArraySectionExpr>(Init)->getBase(),
cast<ArraySectionExpr>(Init)->getBase(),
Visit, true, EnableLifetimeWarnings);
break;
}
Expand Down
15 changes: 15 additions & 0 deletions clang/lib/Sema/SemaOpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -423,6 +423,21 @@ ExprResult SemaOpenACC::ActOnIntExpr(OpenACCDirectiveKind DK,
return IntExpr;
}

ExprResult SemaOpenACC::ActOnArraySectionExpr(Expr *Base, SourceLocation LBLoc,
Expr *LowerBound,
SourceLocation ColonLoc,
Expr *Length,
SourceLocation RBLoc) {
ASTContext &Context = getASTContext();

// TODO OpenACC: We likely have to reproduce a lot of the same logic from the
// OMP version of this, but at the moment we don't have a good way to test it,
// so for now we'll just create the node.
return new (Context)
ArraySectionExpr(Base, LowerBound, Length, Context.ArraySectionTy,
VK_LValue, OK_Ordinary, ColonLoc, RBLoc);
}

bool SemaOpenACC::ActOnStartStmtDirective(OpenACCDirectiveKind K,
SourceLocation StartLoc) {
return diagnoseConstructAppertainment(*this, K, StartLoc, /*IsStmt=*/true);
Expand Down
71 changes: 35 additions & 36 deletions clang/lib/Sema/SemaOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2230,7 +2230,7 @@ bool SemaOpenMP::isOpenMPCapturedByRef(const ValueDecl *D, unsigned Level,
dyn_cast<UnaryOperator>(Last->getAssociatedExpression());
if ((UO && UO->getOpcode() == UO_Deref) ||
isa<ArraySubscriptExpr>(Last->getAssociatedExpression()) ||
isa<OMPArraySectionExpr>(Last->getAssociatedExpression()) ||
isa<ArraySectionExpr>(Last->getAssociatedExpression()) ||
isa<MemberExpr>(EI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(Last->getAssociatedExpression())) {
IsVariableAssociatedWithSection = true;
Expand Down Expand Up @@ -3884,7 +3884,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
MappableComponent &MC) {
return MC.getAssociatedDeclaration() ==
nullptr &&
(isa<OMPArraySectionExpr>(
(isa<ArraySectionExpr>(
MC.getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(
MC.getAssociatedExpression()) ||
Expand Down Expand Up @@ -4062,7 +4062,7 @@ class DSAAttrChecker final : public StmtVisitor<DSAAttrChecker, void> {
// Do both expressions have the same kind?
if (CCI->getAssociatedExpression()->getStmtClass() !=
SC.getAssociatedExpression()->getStmtClass())
if (!((isa<OMPArraySectionExpr>(
if (!((isa<ArraySectionExpr>(
SC.getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(
SC.getAssociatedExpression())) &&
Expand Down Expand Up @@ -5428,9 +5428,9 @@ static std::pair<ValueDecl *, bool> getPrivateItem(Sema &S, Expr *&RefExpr,
Base = TempASE->getBase()->IgnoreParenImpCasts();
RefExpr = Base;
IsArrayExpr = ArraySubscript;
} else if (auto *OASE = dyn_cast_or_null<OMPArraySectionExpr>(RefExpr)) {
} else if (auto *OASE = dyn_cast_or_null<ArraySectionExpr>(RefExpr)) {
Expr *Base = OASE->getBase()->IgnoreParenImpCasts();
while (auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base))
while (auto *TempOASE = dyn_cast<ArraySectionExpr>(Base))
Base = TempOASE->getBase()->IgnoreParenImpCasts();
while (auto *TempASE = dyn_cast<ArraySubscriptExpr>(Base))
Base = TempASE->getBase()->IgnoreParenImpCasts();
Expand Down Expand Up @@ -6060,10 +6060,10 @@ processImplicitMapsWithDefaultMappers(Sema &S, DSAStackTy *Stack,
// Array section - need to check for the mapping of the array section
// element.
QualType CanonType = E->getType().getCanonicalType();
if (CanonType->isSpecificBuiltinType(BuiltinType::OMPArraySection)) {
const auto *OASE = cast<OMPArraySectionExpr>(E->IgnoreParenImpCasts());
if (CanonType->isSpecificBuiltinType(BuiltinType::ArraySection)) {
const auto *OASE = cast<ArraySectionExpr>(E->IgnoreParenImpCasts());
QualType BaseType =
OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
ArraySectionExpr::getBaseOriginalType(OASE->getBase());
QualType ElemType;
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
ElemType = ATy->getElementType();
Expand Down Expand Up @@ -19513,7 +19513,7 @@ struct ReductionData {
} // namespace

static bool checkOMPArraySectionConstantForReduction(
ASTContext &Context, const OMPArraySectionExpr *OASE, bool &SingleElement,
ASTContext &Context, const ArraySectionExpr *OASE, bool &SingleElement,
SmallVectorImpl<llvm::APSInt> &ArraySizes) {
const Expr *Length = OASE->getLength();
if (Length == nullptr) {
Expand All @@ -19540,7 +19540,7 @@ static bool checkOMPArraySectionConstantForReduction(

// We require length = 1 for all array sections except the right-most to
// guarantee that the memory region is contiguous and has no holes in it.
while (const auto *TempOASE = dyn_cast<OMPArraySectionExpr>(Base)) {
while (const auto *TempOASE = dyn_cast<ArraySectionExpr>(Base)) {
Length = TempOASE->getLength();
if (Length == nullptr) {
// For array sections of the form [1:] or [:], we would need to analyze
Expand Down Expand Up @@ -19745,12 +19745,12 @@ static bool actOnOMPReductionKindClause(
Expr *TaskgroupDescriptor = nullptr;
QualType Type;
auto *ASE = dyn_cast<ArraySubscriptExpr>(RefExpr->IgnoreParens());
auto *OASE = dyn_cast<OMPArraySectionExpr>(RefExpr->IgnoreParens());
auto *OASE = dyn_cast<ArraySectionExpr>(RefExpr->IgnoreParens());
if (ASE) {
Type = ASE->getType().getNonReferenceType();
} else if (OASE) {
QualType BaseType =
OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
Type = ATy->getElementType();
else
Expand Down Expand Up @@ -21284,10 +21284,10 @@ OMPClause *SemaOpenMP::ActOnOpenMPDependClause(
// List items used in depend clauses cannot be zero-length array
// sections.
QualType ExprTy = RefExpr->getType().getNonReferenceType();
const auto *OASE = dyn_cast<OMPArraySectionExpr>(SimpleExpr);
const auto *OASE = dyn_cast<ArraySectionExpr>(SimpleExpr);
if (OASE) {
QualType BaseType =
OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (BaseType.isNull())
return nullptr;
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
Expand Down Expand Up @@ -21346,7 +21346,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPDependClause(
Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf,
RefExpr->IgnoreParenImpCasts());
}
if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr) &&
if (!Res.isUsable() && !isa<ArraySectionExpr>(SimpleExpr) &&
!isa<OMPArrayShapingExpr>(SimpleExpr)) {
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
<< (getLangOpts().OpenMP >= 50 ? 1 : 0)
Expand Down Expand Up @@ -21447,7 +21447,7 @@ static bool checkTypeMappable(SourceLocation SL, SourceRange SR, Sema &SemaRef,
static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef,
const Expr *E,
QualType BaseQTy) {
const auto *OASE = dyn_cast<OMPArraySectionExpr>(E);
const auto *OASE = dyn_cast<ArraySectionExpr>(E);

// If this is an array subscript, it refers to the whole size if the size of
// the dimension is constant and equals 1. Also, an array section assumes the
Expand Down Expand Up @@ -21505,7 +21505,7 @@ static bool checkArrayExpressionDoesNotReferToWholeSize(Sema &SemaRef,
static bool checkArrayExpressionDoesNotReferToUnitySize(Sema &SemaRef,
const Expr *E,
QualType BaseQTy) {
const auto *OASE = dyn_cast<OMPArraySectionExpr>(E);
const auto *OASE = dyn_cast<ArraySectionExpr>(E);

// An array subscript always refer to a single element. Also, an array section
// assumes the format of an array subscript if no colon is used.
Expand Down Expand Up @@ -21720,14 +21720,14 @@ class MapBaseChecker final : public StmtVisitor<MapBaseChecker, bool> {
return RelevantExpr || Visit(E);
}

bool VisitOMPArraySectionExpr(OMPArraySectionExpr *OASE) {
bool VisitArraySectionExpr(ArraySectionExpr *OASE) {
// After OMP 5.0 Array section in reduction clause will be implicitly
// mapped
assert(!(SemaRef.getLangOpts().OpenMP < 50 && NoDiagnose) &&
"Array sections cannot be implicitly mapped.");
Expr *E = OASE->getBase()->IgnoreParenImpCasts();
QualType CurType =
OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();

// OpenMP 4.5 [2.15.5.1, map Clause, Restrictions, C++, p.1]
// If the type of a list item is a reference to a type T then the type
Expand Down Expand Up @@ -21900,7 +21900,7 @@ static const Expr *checkMapClauseExpressionBase(
auto CE = CurComponents.rend();
for (; CI != CE; ++CI) {
const auto *OASE =
dyn_cast<OMPArraySectionExpr>(CI->getAssociatedExpression());
dyn_cast<ArraySectionExpr>(CI->getAssociatedExpression());
if (!OASE)
continue;
if (OASE && OASE->getLength())
Expand Down Expand Up @@ -21970,10 +21970,10 @@ static bool checkMapConflicts(
// variable in map clauses of the same construct.
if (CurrentRegionOnly &&
(isa<ArraySubscriptExpr>(CI->getAssociatedExpression()) ||
isa<OMPArraySectionExpr>(CI->getAssociatedExpression()) ||
isa<ArraySectionExpr>(CI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(CI->getAssociatedExpression())) &&
(isa<ArraySubscriptExpr>(SI->getAssociatedExpression()) ||
isa<OMPArraySectionExpr>(SI->getAssociatedExpression()) ||
isa<ArraySectionExpr>(SI->getAssociatedExpression()) ||
isa<OMPArrayShapingExpr>(SI->getAssociatedExpression()))) {
SemaRef.Diag(CI->getAssociatedExpression()->getExprLoc(),
diag::err_omp_multiple_array_items_in_map_clause)
Expand Down Expand Up @@ -22001,11 +22001,10 @@ static bool checkMapConflicts(
if (const auto *ASE =
dyn_cast<ArraySubscriptExpr>(SI->getAssociatedExpression())) {
Type = ASE->getBase()->IgnoreParenImpCasts()->getType();
} else if (const auto *OASE = dyn_cast<OMPArraySectionExpr>(
} else if (const auto *OASE = dyn_cast<ArraySectionExpr>(
SI->getAssociatedExpression())) {
const Expr *E = OASE->getBase()->IgnoreParenImpCasts();
Type =
OMPArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
Type = ArraySectionExpr::getBaseOriginalType(E).getCanonicalType();
} else if (const auto *OASE = dyn_cast<OMPArrayShapingExpr>(
SI->getAssociatedExpression())) {
Type = OASE->getBase()->getType()->getPointeeType();
Expand Down Expand Up @@ -22480,13 +22479,13 @@ static void checkMappableExpressionList(
(void)I;
QualType Type;
auto *ASE = dyn_cast<ArraySubscriptExpr>(VE->IgnoreParens());
auto *OASE = dyn_cast<OMPArraySectionExpr>(VE->IgnoreParens());
auto *OASE = dyn_cast<ArraySectionExpr>(VE->IgnoreParens());
auto *OAShE = dyn_cast<OMPArrayShapingExpr>(VE->IgnoreParens());
if (ASE) {
Type = ASE->getType().getNonReferenceType();
} else if (OASE) {
QualType BaseType =
OMPArraySectionExpr::getBaseOriginalType(OASE->getBase());
ArraySectionExpr::getBaseOriginalType(OASE->getBase());
if (const auto *ATy = BaseType->getAsArrayTypeUnsafe())
Type = ATy->getElementType();
else
Expand Down Expand Up @@ -23955,7 +23954,7 @@ SemaOpenMP::ActOnOpenMPUseDeviceAddrClause(ArrayRef<Expr *> VarList,
MVLI.VarBaseDeclarations.push_back(D);
MVLI.VarComponents.emplace_back();
Expr *Component = SimpleRefExpr;
if (VD && (isa<OMPArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
if (VD && (isa<ArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
isa<ArraySubscriptExpr>(RefExpr->IgnoreParenImpCasts())))
Component =
SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
Expand Down Expand Up @@ -24105,7 +24104,7 @@ SemaOpenMP::ActOnOpenMPHasDeviceAddrClause(ArrayRef<Expr *> VarList,
// against other clauses later on.
Expr *Component = SimpleRefExpr;
auto *VD = dyn_cast<VarDecl>(D);
if (VD && (isa<OMPArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
if (VD && (isa<ArraySectionExpr>(RefExpr->IgnoreParenImpCasts()) ||
isa<ArraySubscriptExpr>(RefExpr->IgnoreParenImpCasts())))
Component =
SemaRef.DefaultFunctionArrayLvalueConversion(SimpleRefExpr).get();
Expand Down Expand Up @@ -24519,7 +24518,7 @@ OMPClause *SemaOpenMP::ActOnOpenMPAffinityClause(
Sema::TentativeAnalysisScope Trap(SemaRef);
Res = SemaRef.CreateBuiltinUnaryOp(ELoc, UO_AddrOf, SimpleExpr);
}
if (!Res.isUsable() && !isa<OMPArraySectionExpr>(SimpleExpr) &&
if (!Res.isUsable() && !isa<ArraySectionExpr>(SimpleExpr) &&
!isa<OMPArrayShapingExpr>(SimpleExpr)) {
Diag(ELoc, diag::err_omp_expected_addressable_lvalue_or_array_item)
<< 1 << 0 << RefExpr->getSourceRange();
Expand Down Expand Up @@ -24632,7 +24631,7 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
Expr *Stride, SourceLocation RBLoc) {
ASTContext &Context = getASTContext();
if (Base->hasPlaceholderType() &&
!Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
!Base->hasPlaceholderType(BuiltinType::ArraySection)) {
ExprResult Result = SemaRef.CheckPlaceholderExpr(Base);
if (Result.isInvalid())
return ExprError();
Expand Down Expand Up @@ -24672,13 +24671,13 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
(LowerBound->isTypeDependent() || LowerBound->isValueDependent())) ||
(Length && (Length->isTypeDependent() || Length->isValueDependent())) ||
(Stride && (Stride->isTypeDependent() || Stride->isValueDependent()))) {
return new (Context) OMPArraySectionExpr(
return new (Context) ArraySectionExpr(
Base, LowerBound, Length, Stride, Context.DependentTy, VK_LValue,
OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}

// Perform default conversions.
QualType OriginalTy = OMPArraySectionExpr::getBaseOriginalType(Base);
QualType OriginalTy = ArraySectionExpr::getBaseOriginalType(Base);
QualType ResultTy;
if (OriginalTy->isAnyPointerType()) {
ResultTy = OriginalTy->getPointeeType();
Expand Down Expand Up @@ -24801,14 +24800,14 @@ ExprResult SemaOpenMP::ActOnOMPArraySectionExpr(
}
}

if (!Base->hasPlaceholderType(BuiltinType::OMPArraySection)) {
if (!Base->hasPlaceholderType(BuiltinType::ArraySection)) {
ExprResult Result = SemaRef.DefaultFunctionArrayLvalueConversion(Base);
if (Result.isInvalid())
return ExprError();
Base = Result.get();
}
return new (Context) OMPArraySectionExpr(
Base, LowerBound, Length, Stride, Context.OMPArraySectionTy, VK_LValue,
return new (Context) ArraySectionExpr(
Base, LowerBound, Length, Stride, Context.ArraySectionTy, VK_LValue,
OK_Ordinary, ColonLocFirst, ColonLocSecond, RBLoc);
}

Expand Down
51 changes: 32 additions & 19 deletions clang/lib/Sema/TreeTransform.h
Original file line number Diff line number Diff line change
Expand Up @@ -2784,15 +2784,23 @@ class TreeTransform {
///
/// By default, performs semantic analysis to build the new expression.
/// Subclasses may override this routine to provide different behavior.
ExprResult RebuildOMPArraySectionExpr(Expr *Base, SourceLocation LBracketLoc,
Expr *LowerBound,
SourceLocation ColonLocFirst,
SourceLocation ColonLocSecond,
Expr *Length, Expr *Stride,
SourceLocation RBracketLoc) {
return getSema().OpenMP().ActOnOMPArraySectionExpr(
Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
Stride, RBracketLoc);
ExprResult RebuildArraySectionExpr(bool IsOMPArraySection, Expr *Base,
SourceLocation LBracketLoc,
Expr *LowerBound,
SourceLocation ColonLocFirst,
SourceLocation ColonLocSecond,
Expr *Length, Expr *Stride,
SourceLocation RBracketLoc) {
if (IsOMPArraySection)
return getSema().OpenMP().ActOnOMPArraySectionExpr(
Base, LBracketLoc, LowerBound, ColonLocFirst, ColonLocSecond, Length,
Stride, RBracketLoc);

assert(Stride == nullptr && !ColonLocSecond.isValid() &&
"Stride/second colon not allowed for OpenACC");

return getSema().OpenACC().ActOnArraySectionExpr(
Base, LBracketLoc, LowerBound, ColonLocFirst, Length, RBracketLoc);
}

/// Build a new array shaping expression.
Expand Down Expand Up @@ -11742,7 +11750,7 @@ TreeTransform<Derived>::TransformMatrixSubscriptExpr(MatrixSubscriptExpr *E) {

template <typename Derived>
ExprResult
TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) {
TreeTransform<Derived>::TransformArraySectionExpr(ArraySectionExpr *E) {
ExprResult Base = getDerived().TransformExpr(E->getBase());
if (Base.isInvalid())
return ExprError();
Expand All @@ -11762,20 +11770,25 @@ TreeTransform<Derived>::TransformOMPArraySectionExpr(OMPArraySectionExpr *E) {
}

ExprResult Stride;
if (Expr *Str = E->getStride()) {
Stride = getDerived().TransformExpr(Str);
if (Stride.isInvalid())
return ExprError();
if (E->isOMPArraySection()) {
if (Expr *Str = E->getStride()) {
Stride = getDerived().TransformExpr(Str);
if (Stride.isInvalid())
return ExprError();
}
}

if (!getDerived().AlwaysRebuild() && Base.get() == E->getBase() &&
LowerBound.get() == E->getLowerBound() && Length.get() == E->getLength())
LowerBound.get() == E->getLowerBound() &&
Length.get() == E->getLength() &&
(E->isOpenACCArraySection() || Stride.get() == E->getStride()))
return E;

return getDerived().RebuildOMPArraySectionExpr(
Base.get(), E->getBase()->getEndLoc(), LowerBound.get(),
E->getColonLocFirst(), E->getColonLocSecond(), Length.get(), Stride.get(),
E->getRBracketLoc());
return getDerived().RebuildArraySectionExpr(
E->isOMPArraySection(), Base.get(), E->getBase()->getEndLoc(),
LowerBound.get(), E->getColonLocFirst(),
E->isOMPArraySection() ? E->getColonLocSecond() : SourceLocation{},
Length.get(), Stride.get(), E->getRBracketLoc());
}

template <typename Derived>
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/Serialization/ASTCommon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -261,8 +261,8 @@ serialization::TypeIdxFromBuiltin(const BuiltinType *BT) {
case BuiltinType::IncompleteMatrixIdx:
ID = PREDEF_TYPE_INCOMPLETE_MATRIX_IDX;
break;
case BuiltinType::OMPArraySection:
ID = PREDEF_TYPE_OMP_ARRAY_SECTION;
case BuiltinType::ArraySection:
ID = PREDEF_TYPE_ARRAY_SECTION;
break;
case BuiltinType::OMPArrayShaping:
ID = PREDEF_TYPE_OMP_ARRAY_SHAPING;
Expand Down
6 changes: 3 additions & 3 deletions clang/lib/Serialization/ASTReader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7385,11 +7385,11 @@ QualType ASTReader::GetType(TypeID ID) {
case PREDEF_TYPE_INCOMPLETE_MATRIX_IDX:
T = Context.IncompleteMatrixIdxTy;
break;
case PREDEF_TYPE_OMP_ARRAY_SECTION:
T = Context.OMPArraySectionTy;
case PREDEF_TYPE_ARRAY_SECTION:
T = Context.ArraySectionTy;
break;
case PREDEF_TYPE_OMP_ARRAY_SHAPING:
T = Context.OMPArraySectionTy;
T = Context.OMPArrayShapingTy;
break;
case PREDEF_TYPE_OMP_ITERATOR:
T = Context.OMPIteratorTy;
Expand Down
18 changes: 13 additions & 5 deletions clang/lib/Serialization/ASTReaderStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -956,14 +956,22 @@ void ASTStmtReader::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
E->setRBracketLoc(readSourceLocation());
}

void ASTStmtReader::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
void ASTStmtReader::VisitArraySectionExpr(ArraySectionExpr *E) {
VisitExpr(E);
E->ASType = Record.readEnum<ArraySectionExpr::ArraySectionType>();

E->setBase(Record.readSubExpr());
E->setLowerBound(Record.readSubExpr());
E->setLength(Record.readSubExpr());
E->setStride(Record.readSubExpr());

if (E->isOMPArraySection())
E->setStride(Record.readSubExpr());

E->setColonLocFirst(readSourceLocation());
E->setColonLocSecond(readSourceLocation());

if (E->isOMPArraySection())
E->setColonLocSecond(readSourceLocation());

E->setRBracketLoc(readSourceLocation());
}

Expand Down Expand Up @@ -3090,8 +3098,8 @@ Stmt *ASTReader::ReadStmtFromStream(ModuleFile &F) {
S = new (Context) MatrixSubscriptExpr(Empty);
break;

case EXPR_OMP_ARRAY_SECTION:
S = new (Context) OMPArraySectionExpr(Empty);
case EXPR_ARRAY_SECTION:
S = new (Context) ArraySectionExpr(Empty);
break;

case EXPR_OMP_ARRAY_SHAPING:
Expand Down
13 changes: 9 additions & 4 deletions clang/lib/Serialization/ASTWriterStmt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -880,16 +880,21 @@ void ASTStmtWriter::VisitMatrixSubscriptExpr(MatrixSubscriptExpr *E) {
Code = serialization::EXPR_ARRAY_SUBSCRIPT;
}

void ASTStmtWriter::VisitOMPArraySectionExpr(OMPArraySectionExpr *E) {
void ASTStmtWriter::VisitArraySectionExpr(ArraySectionExpr *E) {
VisitExpr(E);
Record.writeEnum(E->ASType);
Record.AddStmt(E->getBase());
Record.AddStmt(E->getLowerBound());
Record.AddStmt(E->getLength());
Record.AddStmt(E->getStride());
if (E->isOMPArraySection())
Record.AddStmt(E->getStride());
Record.AddSourceLocation(E->getColonLocFirst());
Record.AddSourceLocation(E->getColonLocSecond());

if (E->isOMPArraySection())
Record.AddSourceLocation(E->getColonLocSecond());

Record.AddSourceLocation(E->getRBracketLoc());
Code = serialization::EXPR_OMP_ARRAY_SECTION;
Code = serialization::EXPR_ARRAY_SECTION;
}

void ASTStmtWriter::VisitOMPArrayShapingExpr(OMPArrayShapingExpr *E) {
Expand Down
4 changes: 2 additions & 2 deletions clang/lib/StaticAnalyzer/Checkers/DereferenceChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,9 +188,9 @@ void DereferenceChecker::reportBug(DerefKind K, ProgramStateRef State,
os << DerefStr1;
break;
}
case Stmt::OMPArraySectionExprClass: {
case Stmt::ArraySectionExprClass: {
os << "Array access";
const OMPArraySectionExpr *AE = cast<OMPArraySectionExpr>(S);
const ArraySectionExpr *AE = cast<ArraySectionExpr>(S);
AddDerefSource(os, Ranges, AE->getBase()->IgnoreParenCasts(),
State.get(), N->getLocationContext());
os << DerefStr1;
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Checkers/IdenticalExprChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,7 @@ static bool isIdenticalStmt(const ASTContext &Ctx, const Stmt *Stmt1,
return false;
case Stmt::CallExprClass:
case Stmt::ArraySubscriptExprClass:
case Stmt::OMPArraySectionExprClass:
case Stmt::ArraySectionExprClass:
case Stmt::OMPArrayShapingExprClass:
case Stmt::OMPIteratorExprClass:
case Stmt::ImplicitCastExprClass:
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/ExprEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1948,7 +1948,7 @@ void ExprEngine::Visit(const Stmt *S, ExplodedNode *Pred,
case Stmt::CXXPseudoDestructorExprClass:
case Stmt::SubstNonTypeTemplateParmExprClass:
case Stmt::CXXNullPtrLiteralExprClass:
case Stmt::OMPArraySectionExprClass:
case Stmt::ArraySectionExprClass:
case Stmt::OMPArrayShapingExprClass:
case Stmt::OMPIteratorExprClass:
case Stmt::SYCLUniqueStableNameExprClass:
Expand Down
16 changes: 16 additions & 0 deletions clang/test/AST/Interp/cxx23.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,3 +141,19 @@ struct check_ice {
};
};
static_assert(check_ice<42>::x == 42);


namespace VirtualBases {
namespace One {
struct U { int n; };
struct V : U { int n; };
struct A : virtual V { int n; };
struct Aa { int n; };
struct B : virtual A, Aa {};
struct C : virtual A, Aa {};
struct D : B, C {};

/// Calls the constructor of D.
D d;
}
}
79 changes: 79 additions & 0 deletions clang/test/AST/Interp/records.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1330,3 +1330,82 @@ namespace UnnamedBitFields {
static_assert(a.f == 1.0, "");
static_assert(a.c == 'a', "");
}

/// FIXME: This still doesn't work in the new interpreter because
/// we lack type information for dummy pointers.
namespace VirtualBases {
/// This used to crash.
namespace One {
class A {
protected:
int x;
};
class B : public virtual A {
public:
int getX() { return x; } // ref-note {{declared here}}
};

class DV : virtual public B{};

void foo() {
DV b;
int a[b.getX()]; // both-warning {{variable length arrays}} \
// ref-note {{non-constexpr function 'getX' cannot be used}}
}
}

namespace Two {
struct U { int n; };
struct A : virtual U { int n; };
struct B : A {};
B a;
static_assert((U*)(A*)(&a) == (U*)(&a), "");

struct C : virtual A {};
struct D : B, C {};
D d;
constexpr B *p = &d;
constexpr C *q = &d;
static_assert((A*)p == (A*)q, ""); // both-error {{failed}}
}

namespace Three {
struct U { int n; };
struct V : U { int n; };
struct A : virtual V { int n; };
struct Aa { int n; };
struct B : virtual A, Aa {};

struct C : virtual A, Aa {};

struct D : B, C {};

D d;

constexpr B *p = &d;
constexpr C *q = &d;

static_assert((void*)p != (void*)q, "");
static_assert((A*)p == (A*)q, "");
static_assert((Aa*)p != (Aa*)q, "");

constexpr V *v = p;
constexpr V *w = q;
constexpr V *x = (A*)p;
static_assert(v == w, "");
static_assert(v == x, "");

static_assert((U*)&d == p, "");
static_assert((U*)&d == q, "");
static_assert((U*)&d == v, "");
static_assert((U*)&d == w, "");
static_assert((U*)&d == x, "");

struct X {};
struct Y1 : virtual X {};
struct Y2 : X {};
struct Z : Y1, Y2 {};
Z z;
static_assert((X*)(Y1*)&z != (X*)(Y2*)&z, "");
}
}
2 changes: 1 addition & 1 deletion clang/test/AST/ast-dump-expr-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2333,7 +2333,7 @@ void TestNonADLCall3() {
// CHECK-NEXT: "kind": "FunctionDecl",
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *) noexcept"
// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
Expand Down
2 changes: 1 addition & 1 deletion clang/test/AST/ast-dump-expr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ void UnaryExpressions(int *p) {
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:8> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

::delete p;
// CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *) noexcept'
// CHECK: CXXDeleteExpr 0x{{[^ ]*}} <line:[[@LINE-1]]:3, col:12> 'void' global Function 0x{{[^ ]*}} 'operator delete' 'void (void *, unsigned long) noexcept'
// CHECK-NEXT: ImplicitCastExpr
// CHECK-NEXT: DeclRefExpr 0x{{[^ ]*}} <col:12> 'int *' lvalue ParmVar 0x{{[^ ]*}} 'p' 'int *'

Expand Down
244 changes: 241 additions & 3 deletions clang/test/AST/ast-dump-stmt-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -994,7 +994,7 @@ void TestDependentGenericSelectionExpr(Ty T) {
// CHECK-NEXT: "kind": "FunctionDecl",
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *) noexcept"
// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
Expand Down Expand Up @@ -1369,7 +1369,7 @@ void TestDependentGenericSelectionExpr(Ty T) {
// CHECK-NEXT: "kind": "FunctionDecl",
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *) noexcept"
// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
Expand Down Expand Up @@ -1722,7 +1722,6 @@ void TestDependentGenericSelectionExpr(Ty T) {
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "isUsed": true,
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "mangledName": "_ZdlPv",
// CHECK-NEXT: "type": {
Expand Down Expand Up @@ -1810,6 +1809,126 @@ void TestDependentGenericSelectionExpr(Ty T) {
// CHECK-NEXT: }


// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "isUsed": true,
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "mangledName": "_ZdlPvm",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept"
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void *"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "unsigned long"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "VisibilityAttr",
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "implicit": true,
// CHECK-NEXT: "visibility": "default"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }

// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "name": "operator delete",
// CHECK-NEXT: "mangledName": "_ZdlPvmSt11align_val_t",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *, unsigned long, std::align_val_t) noexcept"
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void *"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "unsigned long"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "std::align_val_t"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "VisibilityAttr",
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "implicit": true,
// CHECK-NEXT: "visibility": "default"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }

// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {},
Expand Down Expand Up @@ -1906,6 +2025,125 @@ void TestDependentGenericSelectionExpr(Ty T) {
// CHECK-NEXT: }


// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "name": "operator delete[]",
// CHECK-NEXT: "mangledName": "_ZdaPvm",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *, unsigned long) noexcept"
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void *"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "unsigned long"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "VisibilityAttr",
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "implicit": true,
// CHECK-NEXT: "visibility": "default"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }

// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "name": "operator delete[]",
// CHECK-NEXT: "mangledName": "_ZdaPvmSt11align_val_t",
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void (void *, unsigned long, std::align_val_t) noexcept"
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "void *"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "unsigned long"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "ParmVarDecl",
// CHECK-NEXT: "loc": {},
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "type": {
// CHECK-NEXT: "qualType": "std::align_val_t"
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "VisibilityAttr",
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {},
// CHECK-NEXT: "end": {}
// CHECK-NEXT: },
// CHECK-NEXT: "implicit": true,
// CHECK-NEXT: "visibility": "default"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }

// CHECK-NOT: {{^}}Dumping
// CHECK: "kind": "FunctionTemplateDecl",
// CHECK-NEXT: "loc": {
Expand Down
4 changes: 2 additions & 2 deletions clang/test/Analysis/cxxnewexpr-callback.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ void free(void *);
} // namespace std

void *operator new(size_t size) { return std::malloc(size); }
void operator delete(void *ptr) { std::free(ptr); }
void operator delete(void *ptr, size_t size) { std::free(ptr); }

struct S {
S() {}
Expand Down Expand Up @@ -49,7 +49,7 @@ void test() {
// CHECK-NEXT: PostCall (operator delete)
}

void operator delete(void *ptr) {
void operator delete(void *ptr, size_t size) {
std::free(ptr);
// CHECK-NO-INLINE-NEXT: PreCall (std::free)
// CHECK-NO-INLINE-NEXT: PostCall (std::free)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions -verify %s
// RUN: %clang_cc1 -std=c++1z -fexceptions -verify %s

using size_t = decltype(sizeof(0));

Expand Down
17 changes: 9 additions & 8 deletions clang/test/CXX/drs/cwg292.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK
// RUN: %clang_cc1 -std=c++98 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,CXX98-11
// RUN: %clang_cc1 -std=c++11 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,CXX98-11
// RUN: %clang_cc1 -std=c++14 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX14
// RUN: %clang_cc1 -std=c++17 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX14
// RUN: %clang_cc1 -std=c++20 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX14
// RUN: %clang_cc1 -std=c++23 %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX14
// RUN: %clang_cc1 -std=c++2c %s -triple x86_64-linux-gnu -emit-llvm -disable-llvm-passes -o - -fexceptions -fcxx-exceptions -pedantic-errors | llvm-cxxfilt -n | FileCheck %s --check-prefixes CHECK,SINCE-CXX14

namespace cwg292 { // cwg292: 2.9

Expand All @@ -23,7 +23,8 @@ void f() {
// CHECK: invoke {{.*}} i32 @cwg292::g()()
// CHECK-NEXT: to {{.*}} unwind label %lpad
// CHECK-LABEL: lpad:
// CHECK: call void @operator delete(void*)(ptr {{.*}} %[[CALL]])
// CXX98-11: call void @operator delete(void*)(ptr {{.*}} %[[CALL]])
// SINCE-CXX14: call void @operator delete(void*, unsigned long)(ptr {{.*}} %[[CALL]], i64 noundef 1)
// CHECK-LABEL: eh.resume:
// CHECK-LABEL: }

Expand Down
2 changes: 1 addition & 1 deletion clang/test/CXX/expr/expr.unary/expr.new/p14.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++1z -fsized-deallocation -fexceptions %s -verify
// RUN: %clang_cc1 -std=c++1z -fexceptions %s -verify

using size_t = decltype(sizeof(0));
namespace std { enum class align_val_t : size_t {}; }
Expand Down
8 changes: 4 additions & 4 deletions clang/test/CodeGen/X86/ms-x86-intrinsics.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ long long test__readfsqword(unsigned long Offset) {
__int64 test__emul(int a, int b) {
return __emul(a, b);
}
// CHECK-LABEL: define dso_local i64 @test__emul(i32 noundef %a, i32 noundef %b)
// CHECK-LABEL: define dso_local range(i64 -4611686016279904256, 4611686018427387905) i64 @test__emul(i32 noundef %a, i32 noundef %b)
// CHECK: [[X:%[0-9]+]] = sext i32 %a to i64
// CHECK: [[Y:%[0-9]+]] = sext i32 %b to i64
// CHECK: [[RES:%[0-9]+]] = mul nsw i64 [[Y]], [[X]]
Expand All @@ -57,7 +57,7 @@ __int64 test__emul(int a, int b) {
unsigned __int64 test__emulu(unsigned int a, unsigned int b) {
return __emulu(a, b);
}
// CHECK-LABEL: define dso_local i64 @test__emulu(i32 noundef %a, i32 noundef %b)
// CHECK-LABEL: define dso_local range(i64 0, -8589934590) i64 @test__emulu(i32 noundef %a, i32 noundef %b)
// CHECK: [[X:%[0-9]+]] = zext i32 %a to i64
// CHECK: [[Y:%[0-9]+]] = zext i32 %b to i64
// CHECK: [[RES:%[0-9]+]] = mul nuw i64 [[Y]], [[X]]
Expand Down Expand Up @@ -108,13 +108,13 @@ long long test__readgsqword(unsigned long Offset) {
__int64 test__mulh(__int64 a, __int64 b) {
return __mulh(a, b);
}
// CHECK-X64-LABEL: define dso_local i64 @test__mulh(i64 noundef %a, i64 noundef %b)
// CHECK-X64-LABEL: define dso_local range(i64 -4611686018427387904, 4611686018427387905) i64 @test__mulh(i64 noundef %a, i64 noundef %b)
// CHECK-X64: = mul nsw i128 %

unsigned __int64 test__umulh(unsigned __int64 a, unsigned __int64 b) {
return __umulh(a, b);
}
// CHECK-X64-LABEL: define dso_local i64 @test__umulh(i64 noundef %a, i64 noundef %b)
// CHECK-X64-LABEL: define dso_local range(i64 0, -1) i64 @test__umulh(i64 noundef %a, i64 noundef %b)
// CHECK-X64: = mul nuw i128 %

__int64 test_mul128(__int64 Multiplier,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
// CHECK-LABEL: @test_svaddqv_f16(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> [[PG:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x half> @llvm.aarch64.sve.addqv.v8f16.nxv8f16(<vscale x 8 x i1> [[TMP0]], <vscale x 8 x half> [[OP:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x half> @llvm.aarch64.sve.faddqv.v8f16.nxv8f16(<vscale x 8 x i1> [[TMP0]], <vscale x 8 x half> [[OP:%.*]])
// CHECK-NEXT: ret <8 x half> [[TMP1]]
//
// CPP-CHECK-LABEL: @_Z16test_svaddqv_f16u10__SVBool_tu13__SVFloat16_t(
// CPP-CHECK-NEXT: entry:
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> [[PG:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x half> @llvm.aarch64.sve.addqv.v8f16.nxv8f16(<vscale x 8 x i1> [[TMP0]], <vscale x 8 x half> [[OP:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <8 x half> @llvm.aarch64.sve.faddqv.v8f16.nxv8f16(<vscale x 8 x i1> [[TMP0]], <vscale x 8 x half> [[OP:%.*]])
// CPP-CHECK-NEXT: ret <8 x half> [[TMP1]]
//
float16x8_t test_svaddqv_f16(svbool_t pg, svfloat16_t op)
Expand All @@ -37,13 +37,13 @@ float16x8_t test_svaddqv_f16(svbool_t pg, svfloat16_t op)
// CHECK-LABEL: @test_svaddqv_f32(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> [[PG:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.aarch64.sve.addqv.v4f32.nxv4f32(<vscale x 4 x i1> [[TMP0]], <vscale x 4 x float> [[OP:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.aarch64.sve.faddqv.v4f32.nxv4f32(<vscale x 4 x i1> [[TMP0]], <vscale x 4 x float> [[OP:%.*]])
// CHECK-NEXT: ret <4 x float> [[TMP1]]
//
// CPP-CHECK-LABEL: @_Z16test_svaddqv_f32u10__SVBool_tu13__SVFloat32_t(
// CPP-CHECK-NEXT: entry:
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> [[PG:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.aarch64.sve.addqv.v4f32.nxv4f32(<vscale x 4 x i1> [[TMP0]], <vscale x 4 x float> [[OP:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <4 x float> @llvm.aarch64.sve.faddqv.v4f32.nxv4f32(<vscale x 4 x i1> [[TMP0]], <vscale x 4 x float> [[OP:%.*]])
// CPP-CHECK-NEXT: ret <4 x float> [[TMP1]]
//
float32x4_t test_svaddqv_f32(svbool_t pg, svfloat32_t op)
Expand All @@ -54,13 +54,13 @@ float32x4_t test_svaddqv_f32(svbool_t pg, svfloat32_t op)
// CHECK-LABEL: @test_svaddqv_f64(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> [[PG:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.aarch64.sve.addqv.v2f64.nxv2f64(<vscale x 2 x i1> [[TMP0]], <vscale x 2 x double> [[OP:%.*]])
// CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.aarch64.sve.faddqv.v2f64.nxv2f64(<vscale x 2 x i1> [[TMP0]], <vscale x 2 x double> [[OP:%.*]])
// CHECK-NEXT: ret <2 x double> [[TMP1]]
//
// CPP-CHECK-LABEL: @_Z16test_svaddqv_f64u10__SVBool_tu13__SVFloat64_t(
// CPP-CHECK-NEXT: entry:
// CPP-CHECK-NEXT: [[TMP0:%.*]] = tail call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> [[PG:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.aarch64.sve.addqv.v2f64.nxv2f64(<vscale x 2 x i1> [[TMP0]], <vscale x 2 x double> [[OP:%.*]])
// CPP-CHECK-NEXT: [[TMP1:%.*]] = tail call <2 x double> @llvm.aarch64.sve.faddqv.v2f64.nxv2f64(<vscale x 2 x i1> [[TMP0]], <vscale x 2 x double> [[OP:%.*]])
// CPP-CHECK-NEXT: ret <2 x double> [[TMP1]]
//
float64x2_t test_svaddqv_f64(svbool_t pg, svfloat64_t op)
Expand Down
72 changes: 36 additions & 36 deletions clang/test/CodeGen/attr-counted-by.c

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions clang/test/CodeGen/ms-mixed-ptr-sizes.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void test_other(struct Foo *f, __attribute__((address_space(10))) int *i) {
}

int test_compare1(int *__ptr32 __uptr i, int *__ptr64 j) {
// ALL-LABEL: define dso_local noundef i32 @test_compare1
// ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare1
// X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(271)
// X64: %cmp = icmp eq ptr addrspace(271) %{{.+}}, %i
// X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr addrspace(271)
Expand All @@ -58,7 +58,7 @@ int test_compare1(int *__ptr32 __uptr i, int *__ptr64 j) {
}

int test_compare2(int *__ptr32 __sptr i, int *__ptr64 j) {
// ALL-LABEL: define dso_local noundef i32 @test_compare2
// ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare2
// X64: %{{.+}} = addrspacecast ptr %j to ptr addrspace(270)
// X64: %cmp = icmp eq ptr addrspace(270) %{{.+}}, %i
// X86: %{{.+}} = addrspacecast ptr addrspace(272) %j to ptr
Expand All @@ -67,7 +67,7 @@ int test_compare2(int *__ptr32 __sptr i, int *__ptr64 j) {
}

int test_compare3(int *__ptr32 __uptr i, int *__ptr64 j) {
// ALL-LABEL: define dso_local noundef i32 @test_compare3
// ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare3
// X64: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr
// X64: %cmp = icmp eq ptr %{{.+}}, %j
// X86: %{{.+}} = addrspacecast ptr addrspace(271) %i to ptr addrspace(272)
Expand All @@ -76,7 +76,7 @@ int test_compare3(int *__ptr32 __uptr i, int *__ptr64 j) {
}

int test_compare4(int *__ptr32 __sptr i, int *__ptr64 j) {
// ALL-LABEL: define dso_local noundef i32 @test_compare4
// ALL-LABEL: define dso_local range(i32 0, 2) i32 @test_compare4
// X64: %{{.+}} = addrspacecast ptr addrspace(270) %i to ptr
// X64: %cmp = icmp eq ptr %{{.+}}, %j
// X86: %{{.+}} = addrspacecast ptr %i to ptr addrspace(272)
Expand Down
10 changes: 5 additions & 5 deletions clang/test/CodeGenCXX/cxx1y-sized-deallocation.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// Check that delete exprs call the sized deallocation function if
// -fsized-deallocation is passed in both C++11 and C++14.
// -fsized-deallocation is passed in C++11 or std >= C++14.
// RUN: %clang_cc1 -std=c++11 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++14 -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s

// Check that we don't used sized deallocation without -fsized-deallocation and
// C++14.
// Check that we don't used sized deallocation with -fno-sized-deallocation or without C++14.
// RUN: %clang_cc1 -std=c++11 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNSIZED
// RUN: %clang_cc1 -std=c++14 %s -emit-llvm -triple x86_64-linux-gnu -fno-sized-deallocation -o - \
// RUN: | FileCheck %s --check-prefix=CHECK-UNSIZED

// CHECK-UNSIZED-NOT: _ZdlPvm
// CHECK-UNSIZED-NOT: _ZdaPvm
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/cxx1z-aligned-allocation.cpp
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
// Check that delete exprs call aligned (de)allocation functions if
// -faligned-allocation is passed in both C++11 and C++14.
// RUN: %clang_cc1 -std=c++11 -fexceptions -fsized-deallocation -faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++14 -fexceptions -fsized-deallocation -faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++14 -fexceptions -faligned-allocation %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s
// RUN: %clang_cc1 -std=c++1z -fexceptions %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s

// RUN: %clang_cc1 -std=c++1z -fexceptions -fsized-deallocation %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck %s --check-prefix=CHECK-MS
// RUN: %clang_cc1 -std=c++1z -fexceptions %s -emit-llvm -triple x86_64-windows-msvc -o - | FileCheck %s --check-prefix=CHECK-MS

// Check that we don't used aligned (de)allocation without -faligned-allocation or C++1z.
// RUN: %clang_cc1 -std=c++14 -DUNALIGNED -fexceptions %s -emit-llvm -triple x86_64-linux-gnu -o - | FileCheck %s --check-prefix=CHECK-UNALIGNED
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenCXX/cxx2a-destroying-delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,10 @@ struct J {
// CHECK-MSABI-LABEL: define {{.*}}@"?j@@
J *j() {
// CHECK-ITANIUM: invoke {{.*}}@_ZN1JC1Ev(
// CHECK-ITANIUM: call {{.*}}@_ZdlPv(
// CHECK-ITANIUM: call {{.*}}@_ZdlPvm(
// CHECK-NOT: }
// CHECK-MSABI: invoke {{.*}}@"??0J@@Q{{AE|EAA}}@XZ"(
// CHECK-MSABI: call {{.*}}@"??3@YAXP{{E?}}AX@Z"(
// CHECK-MSABI: call {{.*}}@"??3@YAXP{{E?}}AX{{I|_K}}@Z"(
return new J;
// CHECK: }
}
Expand Down
4 changes: 3 additions & 1 deletion clang/test/CodeGenCXX/delete-two-arg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ namespace test2 {
// CHECK-NEXT: br i1 [[T1]],
// CHECK: [[T3:%.*]] = getelementptr inbounds i8, ptr [[T0]], i32 -4
// CHECK-NEXT: [[T5:%.*]] = load i32, ptr [[T3]]
// CHECK-NEXT: call void @_ZdaPv(ptr noundef [[T3]])
// CHECK-NEXT: [[T6:%.*]] = mul i32 4, [[T5]]
// CHECK-NEXT: [[T7:%.*]] = add i32 [[T6]], 4
// CHECK-NEXT: call void @_ZdaPvj(ptr noundef [[T3]], i32 noundef [[T7]])
// CHECK-NEXT: br label
::delete[] p;
}
Expand Down
12 changes: 7 additions & 5 deletions clang/test/CodeGenCXX/delete.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ void t3(S *s) {
// CHECK: icmp {{.*}} null
// CHECK: br i1

// CHECK: call void @_ZdlPv
// CHECK: call void @_ZdlPvm

// Check the delete is inside the 'if !null' check unless we're optimizing
// for size. FIXME: We could omit the branch entirely in this case.
Expand All @@ -35,7 +35,7 @@ struct T {
void t4(T *t) {
// CHECK: call void @_ZN1TD1Ev
// CHECK-SIZE-NEXT: br
// CHECK: call void @_ZdlPv
// CHECK: call void @_ZdlPvm
delete t;
}

Expand Down Expand Up @@ -93,14 +93,16 @@ namespace test1 {
// CHECK-NEXT: call void @_ZN5test11AD1Ev(ptr {{[^,]*}} [[CUR]])
// CHECK-NEXT: [[ISDONE:%.*]] = icmp eq ptr [[CUR]], [[BEGIN]]
// CHECK-NEXT: br i1 [[ISDONE]]
// CHECK: call void @_ZdaPv(ptr noundef [[ALLOC]])
// CHECK: [[MUL:%.*]] = mul i64 4, [[COUNT]]
// CHECK-NEXT: [[SIZE:%.*]] = add i64 [[MUL]], 8
// CHECK-NEXT: call void @_ZdaPvm(ptr noundef [[ALLOC]], i64 noundef [[SIZE]])
}
}

namespace test2 {
// CHECK-LABEL: define{{.*}} void @_ZN5test21fEPb
void f(bool *b) {
// CHECK: call void @_ZdlPv(ptr
// CHECK: call void @_ZdlPvm(ptr{{.*}}i64
delete b;
// CHECK: call void @_ZdaPv(ptr
delete [] b;
Expand Down Expand Up @@ -137,7 +139,7 @@ namespace test4 {
// CHECK-NEXT: [[DTOR:%.*]] = load ptr, ptr [[T0]]
// CHECK-NEXT: call void [[DTOR]](ptr {{[^,]*}} [[OBJ:%.*]])
// Call the global operator delete.
// CHECK-NEXT: call void @_ZdlPv(ptr noundef [[ALLOCATED]]) [[NUW:#[0-9]+]]
// CHECK-NEXT: call void @_ZdlPvm(ptr noundef [[ALLOCATED]], i64 noundef 8) [[NUW:#[0-9]+]]
::delete xp;
}
}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/CodeGenCXX/dllimport.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ USEVAR(VarTmpl<ExplicitSpec_Imported>)
// Functions
//===----------------------------------------------------------------------===//

// GNU-DAG: declare dso_local void @_ZdlPv(ptr)
// GNU-DAG: declare dso_local void @_ZdlPv{{j|y}}(ptr, i{{32|64}})

// Import function declaration.
// MSC-DAG: declare dllimport void @"?decl@@YAXXZ"()
Expand Down Expand Up @@ -358,7 +358,7 @@ __declspec(dllimport) void operator delete(void*);
__declspec(dllimport) inline int *ReferencingImportedNew() { return new int[2]; }
// MO1-DAG: define available_externally dllimport ptr @"?ReferencingImportedNew@@YAPAHXZ"
__declspec(dllimport) inline int *ReferencingImportedDelete() { delete (int*)nullptr; }
// MO1-DAG: define available_externally dllimport ptr @"?ReferencingImportedDelete@@YAPAHXZ"
// MO1-DAG: declare dllimport ptr @"?ReferencingImportedDelete@@YAPAHXZ"
USE(ReferencingImportedNew)
USE(ReferencingImportedDelete)
struct ClassWithDtor { ~ClassWithDtor() {} };
Expand Down
6 changes: 3 additions & 3 deletions clang/test/CodeGenCXX/new.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void t1() {
}

// CHECK: declare noundef nonnull ptr @_Znwm(i64 noundef) [[ATTR_NOBUILTIN:#[^ ]*]]
// CHECK: declare void @_ZdlPv(ptr noundef) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
// CHECK: declare void @_ZdlPvm(ptr noundef, i64 noundef) [[ATTR_NOBUILTIN_NOUNWIND:#[^ ]*]]
// CHECK: declare noundef nonnull ptr @_Znam(i64 noundef) [[ATTR_NOBUILTIN]]
// CHECK: declare void @_ZdaPv(ptr noundef) [[ATTR_NOBUILTIN_NOUNWIND]]

Expand Down Expand Up @@ -192,7 +192,7 @@ void f() {
// CHECK: store i64 200
delete[] new (nothrow) Alloc[10][20];
// CHECK: call noalias noundef nonnull ptr @_Znwm
// CHECK: call void @_ZdlPv(ptr
// CHECK: call void @_ZdlPvm(ptr noundef {{%.*}}, i64 noundef 1)
delete new bool;
// CHECK: ret void
}
Expand Down Expand Up @@ -317,7 +317,7 @@ namespace N3664 {
void f() {
// CHECK: call noalias noundef nonnull ptr @_Znwm(i64 noundef 4) [[ATTR_BUILTIN_NEW:#[^ ]*]]
int *p = new int; // expected-note {{allocated with 'new' here}}
// CHECK: call void @_ZdlPv({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
// CHECK: call void @_ZdlPvm({{.*}}) [[ATTR_BUILTIN_DELETE:#[^ ]*]]
delete p;

// CHECK: call noalias noundef nonnull ptr @_Znam(i64 noundef 12) [[ATTR_BUILTIN_NEW]]
Expand Down
2 changes: 0 additions & 2 deletions clang/test/CodeGenCoroutines/coro-aligned-alloc-2.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
// Tests that the combination of -fcoro-aligned-allocation and -fsized-deallocation works well.
// Test the compiler will chose sized deallocation correctly.
// This is only enabled with `-fsized-deallocation` which is off by default.
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
// RUN: -fcoro-aligned-allocation -S -emit-llvm %s -o - -disable-llvm-passes \
// RUN: -fsized-deallocation \
// RUN: | FileCheck %s

#include "Inputs/coroutine.h"
Expand Down
6 changes: 4 additions & 2 deletions clang/test/CodeGenCoroutines/coro-aligned-alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,9 @@ struct task {
// CHECK: %[[aligned_new:.+]] = call{{.*}}@_ZnwmSt11align_val_t({{.*}}%[[coro_size]],{{.*}}%[[coro_align]])

// CHECK: coro.free:
// CHECK: %[[coro_size_for_free:.+]] = call{{.*}}@llvm.coro.size
// CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
// CHECK: call void @_ZdlPvSt11align_val_t({{.*}}[[coro_align_for_free]]
// CHECK: call void @_ZdlPvmSt11align_val_t({{.*}}%[[coro_size_for_free]],{{.*}}%[[coro_align_for_free]])

task f() {
co_return 43;
Expand Down Expand Up @@ -58,8 +59,9 @@ void *operator new(std::size_t, std::align_val_t, std::nothrow_t) noexcept;
// CHECK: %[[aligned_new:.+]] = call{{.*}}@_ZnwmSt11align_val_tSt9nothrow_t({{.*}}%[[coro_size]],{{.*}}%[[coro_align]])

// CHECK: coro.free:
// CHECK: %[[coro_size_for_free:.+]] = call{{.*}}@llvm.coro.size
// CHECK: %[[coro_align_for_free:.+]] = call{{.*}}@llvm.coro.align
// CHECK: call void @_ZdlPvSt11align_val_t({{.*}}[[coro_align_for_free]]
// CHECK: call void @_ZdlPvmSt11align_val_t({{.*}}%[[coro_size_for_free]],{{.*}}%[[coro_align_for_free]])

task2 f2() {
co_return 43;
Expand Down
6 changes: 4 additions & 2 deletions clang/test/CodeGenCoroutines/coro-alloc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ extern "C" void f0(global_new_delete_tag) {
// CHECK: br i1 %[[NeedDealloc]], label %[[FreeBB:.+]], label %[[Afterwards:.+]]

// CHECK: [[FreeBB]]:
// CHECK: call void @_ZdlPv(ptr noundef %[[MEM]])
// CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
// CHECK: call void @_ZdlPvm(ptr noundef %[[MEM]], i64 noundef %[[SIZE]])
// CHECK: br label %[[Afterwards]]

// CHECK: [[Afterwards]]:
Expand Down Expand Up @@ -99,7 +100,8 @@ extern "C" void f1(promise_new_tag ) {

// CHECK: %[[FRAME:.+]] = call ptr @llvm.coro.begin(
// CHECK: %[[MEM:.+]] = call ptr @llvm.coro.free(token %[[ID]], ptr %[[FRAME]])
// CHECK: call void @_ZdlPv(ptr noundef %[[MEM]])
// CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
// CHECK: call void @_ZdlPvm(ptr noundef %[[MEM]], i64 noundef %[[SIZE]])
co_return;
}

Expand Down
6 changes: 4 additions & 2 deletions clang/test/CodeGenCoroutines/coro-cleanup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,13 @@ void f() {
// CHECK: [[Cleanup]]:
// CHECK: call void @_ZNSt16coroutine_traitsIJvEE12promise_typeD1Ev(
// CHECK: %[[Mem0:.+]] = call ptr @llvm.coro.free(
// CHECK: call void @_ZdlPv(ptr noundef %[[Mem0]]
// CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
// CHECK: call void @_ZdlPvm(ptr noundef %[[Mem0]], i64 noundef %[[SIZE]])

// CHECK: [[Dealloc]]:
// THROWEND: %[[Mem:.+]] = call ptr @llvm.coro.free(
// THROWEND: call void @_ZdlPv(ptr noundef %[[Mem]])
// THROWEND: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
// THROWEND: call void @_ZdlPvm(ptr noundef %[[Mem]], i64 noundef %[[SIZE]])

co_return;
}
Expand Down
2 changes: 0 additions & 2 deletions clang/test/CodeGenCoroutines/coro-dealloc.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -std=c++20 \
// RUN: -S -emit-llvm %s -o - -disable-llvm-passes \
// RUN: -fsized-deallocation \
// RUN: | FileCheck %s

#include "Inputs/coroutine.h"
Expand All @@ -21,7 +20,6 @@ struct task {
};

// Test the compiler will chose sized deallocation correctly.
// This is only enabled with `-fsized-deallocation` which is off by default.
void operator delete(void *ptr, std::size_t size) noexcept;

// CHECK: define{{.*}}@_Z1fv
Expand Down
3 changes: 2 additions & 1 deletion clang/test/CodeGenCoroutines/coro-gro.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ int f() {

// CHECK: call void @_ZNSt16coroutine_traitsIiJEE12promise_typeD1Ev(
// CHECK: %[[Mem:.+]] = call ptr @llvm.coro.free(
// CHECK: call void @_ZdlPv(ptr noundef %[[Mem]])
// CHECK: %[[SIZE:.+]] = call i64 @llvm.coro.size.i64()
// CHECK: call void @_ZdlPvm(ptr noundef %[[Mem]], i64 noundef %[[SIZE]])

// Initialize retval from Gro and destroy Gro
// Note this also tests delaying initialization when Gro and function return
Expand Down
9 changes: 6 additions & 3 deletions clang/test/CodeGenCoroutines/pr56919.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,15 @@ Task<void> Bar() { co_await Baz(); }

// CHECK: _Z3Quxv.destroy:{{.*}}
// CHECK-NEXT: #
// CHECK-NEXT: jmp _ZdlPv
// CHECK-NEXT: movl $40, %esi
// CHECK-NEXT: jmp _ZdlPvm@PLT

// CHECK: _Z3Bazv.destroy:{{.*}}
// CHECK-NEXT: #
// CHECK-NEXT: jmp _ZdlPv
// CHECK-NEXT: movl $80, %esi
// CHECK-NEXT: jmp _ZdlPvm

// CHECK: _Z3Barv.destroy:{{.*}}
// CHECK-NEXT: #
// CHECK-NEXT: jmp _ZdlPv
// CHECK-NEXT: movl $120, %esi
// CHECK-NEXT: jmp _ZdlPvm
77 changes: 77 additions & 0 deletions clang/test/CodeGenObjCXX/msabi-stret-arm64.mm
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
// RUN: %clang_cc1 -triple aarch64-pc-windows-msvc -fobjc-runtime=gnustep-2.2 -fobjc-dispatch-method=non-legacy -emit-llvm -o - %s | FileCheck %s

// Pass and return for type size <= 8 bytes.
struct S1 {
int a[2];
};

// Pass and return hfa <= 8 bytes
struct F1 {
float a[2];
};

// Pass and return for type size > 16 bytes.
struct S2 {
int a[5];
};

// Pass and return aggregate (of size < 16 bytes) with non-trivial destructor.
// Sret and inreg: Returned in x0
struct S3 {
int a[3];
~S3();
};
S3::~S3() {
}


@interface MsgTest { id isa; } @end
@implementation MsgTest
- (S1) smallS1 {
S1 x;
x.a[0] = 0;
x.a[1] = 1;
return x;

}
- (F1) smallF1 {
F1 x;
x.a[0] = 0.2f;
x.a[1] = 0.5f;
return x;
}
- (S2) stretS2 {
S2 x;
for (int i = 0; i < 5; i++) {
x.a[i] = i;
}
return x;
}
- (S3) stretInRegS3 {
S3 x;
for (int i = 0; i < 3; i++) {
x.a[i] = i;
}
return x;
}
+ (S3) msgTestStretInRegS3 {
S3 x;
for (int i = 0; i < 3; i++) {
x.a[i] = i;
}
return x;
}
@end

void test0(MsgTest *t) {
// CHECK: call {{.*}} @objc_msgSend
S1 ret = [t smallS1];
// CHECK: call {{.*}} @objc_msgSend
F1 ret2 = [t smallF1];
// CHECK: call {{.*}} @objc_msgSend_stret
S2 ret3 = [t stretS2];
// CHECK: call {{.*}} @objc_msgSend_stret2
S3 ret4 = [t stretInRegS3];
// CHECK: call {{.*}} @objc_msgSend_stret2
S3 ret5 = [MsgTest msgTestStretInRegS3];
}
6 changes: 6 additions & 0 deletions clang/test/Driver/aarch64-mcpu.c
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,16 @@
// NEOVERSE-V1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v1"
// RUN: %clang --target=aarch64 -mcpu=neoverse-v2 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V2 %s
// NEOVERSE-V2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v2"
// RUN: %clang --target=aarch64 -mcpu=neoverse-v3 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V3 %s
// NEOVERSE-V3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v3"
// RUN: %clang --target=aarch64 -mcpu=neoverse-v3ae -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-V3AE %s
// NEOVERSE-V3AE: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-v3ae"
// RUN: %clang --target=aarch64 -mcpu=neoverse-n1 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-N1 %s
// NEOVERSE-N1: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-n1"
// RUN: %clang --target=aarch64 -mcpu=neoverse-n2 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-N2 %s
// NEOVERSE-N2: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-n2"
// RUN: %clang --target=aarch64 -mcpu=neoverse-n3 -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-N3 %s
// NEOVERSE-N3: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-n3"
// RUN: %clang --target=aarch64 -mcpu=neoverse-512tvb -### -c %s 2>&1 | FileCheck -check-prefix=NEOVERSE-512TVB %s
// NEOVERSE-512TVB: "-cc1"{{.*}} "-triple" "aarch64{{.*}}" "-target-cpu" "neoverse-512tvb"
// RUN: %clang --target=aarch64 -mcpu=cortex-a520 -### -c %s 2>&1 | FileCheck -check-prefix=CORTEX-A520 %s
Expand Down
9 changes: 0 additions & 9 deletions clang/test/Driver/default-denormal-fp-math.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,6 @@

// RUN: %clang -### -target x86_64-unknown-linux-gnu --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s

// crtfastmath enables ftz and daz
// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s

// crt not linked in with nostartfiles
// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math -nostartfiles --sysroot=%S/Inputs/basic_linux_tree -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s

// If there's no crtfastmath, don't assume ftz/daz
// RUN: %clang -### -target x86_64-unknown-linux-gnu -ffast-math --sysroot=/dev/null -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-IEEE %s

// RUN: %clang -### -target x86_64-scei-ps4 -c %s -v 2>&1 | FileCheck -check-prefix=CHECK-PRESERVESIGN %s

// Flag omitted for default
Expand Down
26 changes: 26 additions & 0 deletions clang/test/Driver/linux-ld.c
Original file line number Diff line number Diff line change
Expand Up @@ -1446,6 +1446,32 @@
// RUN: %clang --target=i386-unknown-linux -no-pie -### %s -ffast-math \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// Don't link crtfastmath.o with -shared
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -ffast-math -shared \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -Ofast -shared \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// Check for effects of -mdaz-ftz
// RUN: %clang --target=x86_64-unknown-linux -### %s -ffast-math -shared -mdaz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -ffast-math -mdaz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -mdaz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-CRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -### %s -ffast-math -shared -mno-daz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -ffast-math -mno-daz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// RUN: %clang --target=x86_64-unknown-linux -no-pie -### %s -mno-daz-ftz \
// RUN: --sysroot=%S/Inputs/basic_linux_tree 2>&1 \
// RUN: | FileCheck --check-prefix=CHECK-NOCRTFASTMATH %s
// CHECK-CRTFASTMATH: usr/lib/gcc/x86_64-unknown-linux/10.2.0{{/|\\\\}}crtfastmath.o
// CHECK-NOCRTFASTMATH-NOT: crtfastmath.o

Expand Down
20 changes: 10 additions & 10 deletions clang/test/Lexer/cxx-features.cpp
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
// RUN: %clang_cc1 -std=c++98 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++11 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++23 -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++2c -fcxx-exceptions -fsized-deallocation -verify %s
// RUN: %clang_cc1 -std=c++14 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++20 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++23 -fcxx-exceptions -verify %s
// RUN: %clang_cc1 -std=c++2c -fcxx-exceptions -verify %s

//
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -fsized-deallocation -DCONCEPTS_TS=1 -verify %s
// RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS -fsized-deallocation
// RUN: %clang_cc1 -std=c++14 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify -fsized-deallocation %s
// RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify -fsized-deallocation %s
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -frelaxed-template-template-args -DRELAXED_TEMPLATE_TEMPLATE_ARGS=1 -verify %s
// RUN: %clang_cc1 -std=c++17 -fcxx-exceptions -DCONCEPTS_TS=1 -verify %s
// RUN: %clang_cc1 -std=c++14 -fno-rtti -fno-threadsafe-statics -verify %s -DNO_EXCEPTIONS -DNO_RTTI -DNO_THREADSAFE_STATICS
// RUN: %clang_cc1 -std=c++14 -fchar8_t -DNO_EXCEPTIONS -DCHAR8_T -verify %s
// RUN: %clang_cc1 -std=c++2a -fno-char8_t -DNO_EXCEPTIONS -DNO_CHAR8_T -verify %s

// expected-no-diagnostics

Expand Down
4 changes: 2 additions & 2 deletions clang/test/Misc/target-invalid-cpu-note.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64
// AARCH64: error: unknown target CPU 'not-a-cpu'
// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}

// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}
// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a520ae, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78ae, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-a720ae, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-n3, neoverse-512tvb, neoverse-v1, neoverse-v2, neoverse-v3, neoverse-v3ae, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}

// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
// X86: error: unknown target CPU 'not-a-cpu'
Expand Down
2 changes: 1 addition & 1 deletion clang/test/OpenMP/task_depend_messages.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ int main(int argc, char **argv, char *env[]) {
#pragma omp task depend(in : argv[ : argc][1 : argc - 1])
#pragma omp task depend(in : arr[0])
#pragma omp task depend(depobj:argc) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not 'int'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not 'int'}}
#pragma omp task depend(depobj : argv[ : argc][1 : argc - 1]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not '<OpenMP array section type>'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not '<OpenMP array section type>'}}
#pragma omp task depend(depobj : argv[ : argc][1 : argc - 1]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}} omp50-error {{expected lvalue expression of 'omp_depend_t' type, not '<array section type>'}} omp51-error {{expected lvalue expression of 'omp_depend_t' type, not '<array section type>'}}
#pragma omp task depend(depobj : arr[0]) // omp45-error {{expected 'in', 'out', 'inout' or 'mutexinoutset' in OpenMP clause 'depend'}}
#pragma omp task depend(in : ([ // expected-error {{expected variable name or 'this' in lambda capture list}} expected-error {{expected ')'}} expected-note {{to match this '('}}
#pragma omp task depend(in : ([] // expected-error {{expected body of lambda expression}} expected-error {{expected ')'}} expected-note {{to match this '('}}
Expand Down
10 changes: 5 additions & 5 deletions clang/test/PCH/cxx1z-aligned-alloc.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
// No PCH:
// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include %s -verify %s
// RUN: %clang_cc1 -pedantic -std=c++1z -include %s -verify %s
//
// With PCH:
// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -emit-pch %s -o %t
// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include-pch %t -verify %s
// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch %s -o %t
// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s

// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -emit-pch -fpch-instantiate-templates %s -o %t
// RUN: %clang_cc1 -pedantic -fsized-deallocation -std=c++1z -include-pch %t -verify %s
// RUN: %clang_cc1 -pedantic -std=c++1z -emit-pch -fpch-instantiate-templates %s -o %t
// RUN: %clang_cc1 -pedantic -std=c++1z -include-pch %t -verify %s

// expected-no-diagnostics

Expand Down
4 changes: 2 additions & 2 deletions clang/test/ParserOpenACC/parse-cache-construct.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ void use() {
for (int i = 0; i < 10; ++i) {
// FIXME: Once we have a new array-section type to represent OpenACC as
// well, change this error message.
// expected-error@+2{{OpenMP array section is not allowed here}}
// expected-error@+2{{OpenACC sub-array is not allowed here}}
// expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[1:4])
}
for (int i = 0; i < 10; ++i) {
// expected-error@+2{{OpenMP array section is not allowed here}}
// expected-error@+2{{OpenACC sub-array is not allowed here}}
// expected-warning@+1{{OpenACC construct 'cache' not yet implemented, pragma ignored}}
#pragma acc cache(Arrs.MemArr[3:4].array[4])
}
Expand Down
4 changes: 2 additions & 2 deletions clang/test/ParserOpenACC/parse-clauses.c
Original file line number Diff line number Diff line change
Expand Up @@ -482,13 +482,13 @@ void VarListClauses() {
#pragma acc serial copy(HasMem.MemArr[3].array[1:4]), seq
for(;;){}

// expected-error@+3{{OpenMP array section is not allowed here}}
// expected-error@+3{{OpenACC sub-array is not allowed here}}
// expected-warning@+2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning@+1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1]), seq
for(;;){}

// expected-error@+3{{OpenMP array section is not allowed here}}
// expected-error@+3{{OpenACC sub-array is not allowed here}}
// expected-warning@+2{{OpenACC clause 'copy' not yet implemented, clause ignored}}
// expected-warning@+1{{OpenACC clause 'seq' not yet implemented, clause ignored}}
#pragma acc serial copy(HasMem.MemArr[1:3].array[1:2]), seq
Expand Down
23 changes: 14 additions & 9 deletions clang/test/Preprocessor/predefined-macros-hlsl.hlsl
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-amplification | FileCheck -match-full-lines %s --check-prefixes=CHECK,AMPLIFICATION
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-compute | FileCheck -match-full-lines %s --check-prefixes=CHECK,COMPUTE
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-domain | FileCheck -match-full-lines %s --check-prefixes=CHECK,DOMAIN
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-geometry | FileCheck -match-full-lines %s --check-prefixes=CHECK,GEOMETRY
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-hull | FileCheck -match-full-lines %s --check-prefixes=CHECK,HULL
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-library | FileCheck -match-full-lines %s --check-prefixes=CHECK,LIBRARY
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-mesh | FileCheck -match-full-lines %s --check-prefixes=CHECK,MESH
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-pixel | FileCheck -match-full-lines %s --check-prefixes=CHECK,PIXEL
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-vertex | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-amplification | FileCheck -match-full-lines %s --check-prefixes=CHECK,AMPLIFICATION,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-compute | FileCheck -match-full-lines %s --check-prefixes=CHECK,COMPUTE,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-domain | FileCheck -match-full-lines %s --check-prefixes=CHECK,DOMAIN,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-geometry | FileCheck -match-full-lines %s --check-prefixes=CHECK,GEOMETRY,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-hull | FileCheck -match-full-lines %s --check-prefixes=CHECK,HULL,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-library | FileCheck -match-full-lines %s --check-prefixes=CHECK,LIBRARY,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-mesh | FileCheck -match-full-lines %s --check-prefixes=CHECK,MESH,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-pixel | FileCheck -match-full-lines %s --check-prefixes=CHECK,PIXEL,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.0-vertex | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX,NOHALF
// RUN: %clang_cc1 %s -E -dM -o - -triple dxil-pc-shadermodel6.3-vertex -fnative-half-type | FileCheck -match-full-lines %s --check-prefixes=CHECK,VERTEX,HALF

// HALF: #define __HLSL_ENABLE_16_BIT 1
// NOHALF-NOT: __HLSL_ENABLE_16_BIT

// CHECK: #define __HLSL_VERSION 2021

// CHECK: #define __SHADER_STAGE_AMPLIFICATION 14
// CHECK: #define __SHADER_STAGE_COMPUTE 5
// CHECK: #define __SHADER_STAGE_DOMAIN 4
Expand Down
8 changes: 7 additions & 1 deletion clang/test/SemaCXX/MicrosoftExtensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -571,11 +571,17 @@ class PR34109_class {
virtual ~PR34109_class() {}
};

#if !defined(__cpp_sized_deallocation)
void operator delete(void *) throw();
// expected-note@-1 {{previous declaration is here}}
__declspec(dllexport) void operator delete(void *) throw();
// expected-error@-1 {{redeclaration of 'operator delete' cannot add 'dllexport' attribute}}

#else
void operator delete(void *, unsigned int) throw();
// expected-note@-1 {{previous declaration is here}}
__declspec(dllexport) void operator delete(void *, unsigned int) throw();
// expected-error@-1 {{redeclaration of 'operator delete' cannot add 'dllexport' attribute}}
#endif
void PR34109(int* a) {
delete a;
}
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/builtin-operator-new-delete.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++1z -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++1z -fno-sized-deallocation -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++03 -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++03 -faligned-allocation -fsyntax-only -verify %s
// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s
Expand Down
2 changes: 1 addition & 1 deletion clang/test/SemaCXX/cxx1y-sized-deallocation.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clang_cc1 -std=c++1y -verify %s -fsized-deallocation -fexceptions -fcxx-exceptions
// RUN: %clang_cc1 -std=c++1y -verify %s -fexceptions -fcxx-exceptions

using size_t = decltype(sizeof(0));
void operator delete(void *, size_t) noexcept; // expected-note {{'operator delete' declared here}}
Expand Down
15 changes: 9 additions & 6 deletions clang/test/SemaCXX/unavailable_aligned_allocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ void testOveraligned() {
// expected-error-re@-22 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
// expected-note@-23 {{if you supply your own aligned allocation functions}}

// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is {{only|not}} available on}}
// expected-error-re@-24 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is {{only|not}} available on}}
// expected-note@-25 {{if you supply your own aligned allocation functions}}

// expected-error-re@-26 {{aligned allocation function of type 'void *(std::size_t, std::align_val_t, const std::nothrow_t &) noexcept' is {{only|not}} available on}}
Expand Down Expand Up @@ -143,19 +143,19 @@ OveralignedS2::~OveralignedS2() {}
// expected-no-diagnostics
#else
#if defined(IOS)
// expected-error@-6 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on iOS 11 or newer}}}
// expected-error@-6 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is only available on iOS 11 or newer}}}
// expected-note@-7 {{if you supply your own aligned allocation functions}}
#elif defined(TVOS)
// expected-error@-9 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on tvOS 11 or newer}}}
// expected-error@-9 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is only available on tvOS 11 or newer}}}
// expected-note@-10 {{if you supply your own aligned allocation functions}}
#elif defined(WATCHOS)
// expected-error@-12 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
// expected-error@-12 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is only available on watchOS 4 or newer}}}
// expected-note@-13 {{if you supply your own aligned allocation functions}}
#elif defined(MACOS)
// expected-error@-15 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
// expected-error@-15 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is only available on macOS 10.13 or newer}}}
// expected-note@-16 {{if you supply your own aligned allocation functions}}
#elif defined(ZOS)
// expected-error@-18 {{aligned deallocation function of type 'void (void *, enum std::align_val_t) noexcept' is not available on z/OS}}}
// expected-error@-18 {{aligned deallocation function of type 'void (void *, std::size_t, std::align_val_t) noexcept' is not available on z/OS}}}
// expected-note@-19 {{if you supply your own aligned allocation functions}}
#endif
#endif
Expand Down Expand Up @@ -209,6 +209,9 @@ void *operator new(std::size_t __sz, std::align_val_t) {
void operator delete(void *p, std::align_val_t) {
}

void operator delete(void *p, std::size_t __sz, std::align_val_t) {
}

void testOveraligned2() {
auto p = new ((std::align_val_t)8) OveralignedS;
delete p;
Expand Down
2 changes: 0 additions & 2 deletions clang/tools/clang-installapi/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -594,9 +594,7 @@ getInterfaceFile(const StringRef Filename) {
std::unique_ptr<InterfaceFile> IF;
switch (identify_magic(Buffer->getBuffer())) {
case file_magic::macho_dynamically_linked_shared_lib:
LLVM_FALLTHROUGH;
case file_magic::macho_dynamically_linked_shared_lib_stub:
LLVM_FALLTHROUGH;
case file_magic::macho_universal_binary:
return DylibReader::get(Buffer->getMemBufferRef());
break;
Expand Down
Loading