Skip to content

Commit 2df0281

Browse files
authored
Merge branch 'main' into refactor-lldb-dap
2 parents d09721b + 1b44c3a commit 2df0281

File tree

181 files changed

+4611
-549
lines changed

Some content is hidden

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

181 files changed

+4611
-549
lines changed

.icslock

Whitespace-only changes.

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -271,6 +271,8 @@ Resolutions to C++ Defect Reports
271271
C Language Changes
272272
------------------
273273

274+
- Extend clang's ``<limits.h>`` to define ``LONG_LONG_*`` macros for Android's bionic.
275+
274276
C2y Feature Support
275277
^^^^^^^^^^^^^^^^^^^
276278

@@ -553,6 +555,8 @@ Bug Fixes in This Version
553555
the unsupported type instead of the ``register`` keyword (#GH109776).
554556
- Fixed a crash when emit ctor for global variant with flexible array init (#GH113187).
555557
- Fixed a crash when GNU statement expression contains invalid statement (#GH113468).
558+
- Fixed a failed assertion when using ``__attribute__((noderef))`` on an
559+
``_Atomic``-qualified type (#GH116124).
556560

557561
Bug Fixes to Compiler Builtins
558562
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

clang/lib/Driver/ToolChains/PS4CPU.cpp

Lines changed: 55 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ void tools::PS4cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
183183
CmdArgs.push_back(
184184
Args.MakeArgString(Twine("-lto-debug-options=") + LTOArgs));
185185

186+
// Sanitizer runtimes must be supplied before all other objects and libs.
186187
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
187188
TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
188189

@@ -360,27 +361,70 @@ void tools::PS5cpu::Linker::ConstructJob(Compilation &C, const JobAction &JA,
360361
if (StringRef Jobs = getLTOParallelism(Args, D); !Jobs.empty())
361362
AddLTOFlag(Twine("jobs=") + Jobs);
362363

363-
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
364-
TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
365-
366364
TC.AddFilePathLibArgs(Args, CmdArgs);
367365
Args.addAllArgs(CmdArgs, {options::OPT_L, options::OPT_T_Group,
368366
options::OPT_s, options::OPT_t});
369367

370368
if (Args.hasArg(options::OPT_Z_Xlinker__no_demangle))
371369
CmdArgs.push_back("--no-demangle");
372370

373-
AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
371+
// Sanitizer runtimes must be supplied before all other objects and libs.
372+
if (!Args.hasArg(options::OPT_nostdlib, options::OPT_nodefaultlibs))
373+
TC.addSanitizerArgs(Args, CmdArgs, "-l", "");
374374

375-
if (Args.hasArg(options::OPT_pthread)) {
376-
CmdArgs.push_back("-lpthread");
375+
const bool AddStartFiles =
376+
!Relocatable &&
377+
!Args.hasArg(options::OPT_nostartfiles, options::OPT_nostdlib);
378+
379+
auto AddCRTObject = [&](const char *Name) {
380+
CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(Name)));
381+
};
382+
383+
if (AddStartFiles) {
384+
if (!Shared)
385+
AddCRTObject("crt1.o");
386+
AddCRTObject("crti.o");
387+
AddCRTObject(Shared ? "crtbeginS.o"
388+
: Static ? "crtbeginT.o"
389+
: "crtbegin.o");
377390
}
378391

379-
if (UseJMC) {
380-
CmdArgs.push_back("--push-state");
381-
CmdArgs.push_back("--whole-archive");
382-
CmdArgs.push_back("-lSceJmc_nosubmission");
383-
CmdArgs.push_back("--pop-state");
392+
AddLinkerInputs(TC, Inputs, Args, CmdArgs, JA);
393+
394+
if (!Relocatable &&
395+
!Args.hasArg(options::OPT_nodefaultlibs, options::OPT_nostdlib)) {
396+
397+
if (UseJMC) {
398+
CmdArgs.push_back("--push-state");
399+
CmdArgs.push_back("--whole-archive");
400+
CmdArgs.push_back("-lSceJmc_nosubmission");
401+
CmdArgs.push_back("--pop-state");
402+
}
403+
404+
if (Args.hasArg(options::OPT_pthread))
405+
CmdArgs.push_back("-lpthread");
406+
407+
if (Static) {
408+
if (!Args.hasArg(options::OPT_nostdlibxx))
409+
CmdArgs.push_back("-lstdc++");
410+
if (!Args.hasArg(options::OPT_nolibc)) {
411+
CmdArgs.push_back("-lm");
412+
CmdArgs.push_back("-lc");
413+
}
414+
415+
CmdArgs.push_back("-lcompiler_rt");
416+
CmdArgs.push_back("-lkernel");
417+
} else {
418+
// The C and C++ libraries are combined.
419+
if (!Args.hasArg(options::OPT_nolibc, options::OPT_nostdlibxx))
420+
CmdArgs.push_back("-lc_stub_weak");
421+
422+
CmdArgs.push_back("-lkernel_stub_weak");
423+
}
424+
}
425+
if (AddStartFiles) {
426+
AddCRTObject(Shared ? "crtendS.o" : "crtend.o");
427+
AddCRTObject("crtn.o");
384428
}
385429

386430
if (Args.hasArg(options::OPT_fuse_ld_EQ)) {

clang/lib/Headers/limits.h

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,14 @@
111111
#define ULLONG_MAX (__LONG_LONG_MAX__*2ULL+1ULL)
112112
#endif
113113

114-
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. It's too bad
115-
that we don't have something like #pragma poison that could be used to
116-
deprecate a macro - the code should just use LLONG_MAX and friends.
114+
/* LONG_LONG_MIN/LONG_LONG_MAX/ULONG_LONG_MAX are a GNU extension. Android's
115+
bionic also defines them. It's too bad that we don't have something like
116+
#pragma poison that could be used to deprecate a macro - the code should just
117+
use LLONG_MAX and friends.
117118
*/
118-
#if defined(__GNU_LIBRARY__) ? defined(__USE_GNU) : !defined(__STRICT_ANSI__)
119+
#if (defined(__GNU_LIBRARY__) ? defined(__USE_GNU) \
120+
: !defined(__STRICT_ANSI__)) || \
121+
defined(__BIONIC__)
119122

120123
#undef LONG_LONG_MIN
121124
#undef LONG_LONG_MAX

clang/lib/Sema/SemaOpenACC.cpp

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,12 @@ class SemaOpenACCClauseVisitor {
572572

573573
OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultClause(
574574
SemaOpenACC::OpenACCParsedClause &Clause) {
575-
// Restrictions only properly implemented on 'compute' constructs, and
576-
// 'compute' constructs are the only construct that can do anything with
577-
// this yet, so skip/treat as unimplemented in this case.
578-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
575+
// Restrictions only properly implemented on 'compute'/'combined' constructs,
576+
// and 'compute'/'combined' constructs are the only construct that can do
577+
// anything with this yet, so skip/treat as unimplemented in this case.
578+
// Only 'data' is left.
579+
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
580+
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
579581
return isNotImplemented();
580582

581583
// Don't add an invalid clause to the AST.
@@ -596,6 +598,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitDefaultClause(
596598

597599
OpenACCClause *SemaOpenACCClauseVisitor::VisitTileClause(
598600
SemaOpenACC::OpenACCParsedClause &Clause) {
601+
// TODO OpenACC: Remove this when we get combined construct impl for this.
599602
if (Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
600603
return isNotImplemented();
601604

@@ -697,6 +700,8 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitNumGangsClause(
697700
// Restrictions only properly implemented on 'compute' constructs, and
698701
// 'compute' constructs are the only construct that can do anything with
699702
// this yet, so skip/treat as unimplemented in this case.
703+
// TODO OpenACC: Remove this check when we have combined constructs for this
704+
// clause.
700705
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
701706
return isNotImplemented();
702707

@@ -752,6 +757,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitNumWorkersClause(
752757
// Restrictions only properly implemented on 'compute' constructs, and
753758
// 'compute' constructs are the only construct that can do anything with
754759
// this yet, so skip/treat as unimplemented in this case.
760+
// TODO: OpenACC: Remove when we get combined constructs.
755761
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
756762
return isNotImplemented();
757763

@@ -773,6 +779,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
773779
// Restrictions only properly implemented on 'compute' constructs, and
774780
// 'compute' constructs are the only construct that can do anything with
775781
// this yet, so skip/treat as unimplemented in this case.
782+
// TODO: OpenACC: Remove when we get combined constructs.
776783
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
777784
return isNotImplemented();
778785

@@ -791,10 +798,11 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitVectorLengthClause(
791798

792799
OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
793800
SemaOpenACC::OpenACCParsedClause &Clause) {
794-
// Restrictions only properly implemented on 'compute' constructs, and
795-
// 'compute' constructs are the only construct that can do anything with
796-
// this yet, so skip/treat as unimplemented in this case.
797-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
801+
// Restrictions only properly implemented on 'compute'/'combined' constructs,
802+
// and 'compute'/'combined' constructs are the only construct that can do
803+
// anything with this yet, so skip/treat as unimplemented in this case.
804+
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
805+
!isOpenACCCombinedDirectiveKind(Clause.getDirectiveKind()))
798806
return isNotImplemented();
799807

800808
// There is no prose in the standard that says duplicates aren't allowed,
@@ -813,14 +821,6 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitAsyncClause(
813821

814822
OpenACCClause *SemaOpenACCClauseVisitor::VisitPrivateClause(
815823
SemaOpenACC::OpenACCParsedClause &Clause) {
816-
// Restrictions only properly implemented on 'compute' and 'loop'
817-
// constructs, and 'compute'/'loop' constructs are the only construct that
818-
// can do anything with this yet, so skip/treat as unimplemented in this
819-
// case.
820-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
821-
Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
822-
return isNotImplemented();
823-
824824
// ActOnVar ensured that everything is a valid variable reference, so there
825825
// really isn't anything to do here. GCC does some duplicate-finding, though
826826
// it isn't apparent in the standard where this is justified.
@@ -832,12 +832,6 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitPrivateClause(
832832

833833
OpenACCClause *SemaOpenACCClauseVisitor::VisitFirstPrivateClause(
834834
SemaOpenACC::OpenACCParsedClause &Clause) {
835-
// Restrictions only properly implemented on 'compute' constructs, and
836-
// 'compute' constructs are the only construct that can do anything with
837-
// this yet, so skip/treat as unimplemented in this case.
838-
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()))
839-
return isNotImplemented();
840-
841835
// ActOnVar ensured that everything is a valid variable reference, so there
842836
// really isn't anything to do here. GCC does some duplicate-finding, though
843837
// it isn't apparent in the standard where this is justified.
@@ -1410,6 +1404,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitReductionClause(
14101404
// Restrictions only properly implemented on 'compute' constructs, and
14111405
// 'compute' constructs are the only construct that can do anything with
14121406
// this yet, so skip/treat as unimplemented in this case.
1407+
// TODO: OpenACC: Remove check once we get combined constructs for this clause.
14131408
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
14141409
Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
14151410
return isNotImplemented();
@@ -1500,6 +1495,7 @@ OpenACCClause *SemaOpenACCClauseVisitor::VisitReductionClause(
15001495

15011496
OpenACCClause *SemaOpenACCClauseVisitor::VisitCollapseClause(
15021497
SemaOpenACC::OpenACCParsedClause &Clause) {
1498+
// TODO: Remove this check once we implement this for combined constructs.
15031499
if (!isOpenACCComputeDirectiveKind(Clause.getDirectiveKind()) &&
15041500
Clause.getDirectiveKind() != OpenACCDirectiveKind::Loop)
15051501
return isNotImplemented();

clang/lib/Sema/SemaType.cpp

Lines changed: 27 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -5837,6 +5837,30 @@ static void fillMatrixTypeLoc(MatrixTypeLoc MTL,
58375837
llvm_unreachable("no matrix_type attribute found at the expected location!");
58385838
}
58395839

5840+
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) {
5841+
SourceLocation Loc;
5842+
switch (Chunk.Kind) {
5843+
case DeclaratorChunk::Function:
5844+
case DeclaratorChunk::Array:
5845+
case DeclaratorChunk::Paren:
5846+
case DeclaratorChunk::Pipe:
5847+
llvm_unreachable("cannot be _Atomic qualified");
5848+
5849+
case DeclaratorChunk::Pointer:
5850+
Loc = Chunk.Ptr.AtomicQualLoc;
5851+
break;
5852+
5853+
case DeclaratorChunk::BlockPointer:
5854+
case DeclaratorChunk::Reference:
5855+
case DeclaratorChunk::MemberPointer:
5856+
// FIXME: Provide a source location for the _Atomic keyword.
5857+
break;
5858+
}
5859+
5860+
ATL.setKWLoc(Loc);
5861+
ATL.setParensRange(SourceRange());
5862+
}
5863+
58405864
namespace {
58415865
class TypeSpecLocFiller : public TypeLocVisitor<TypeSpecLocFiller> {
58425866
Sema &SemaRef;
@@ -6223,6 +6247,9 @@ namespace {
62236247
void VisitExtVectorTypeLoc(ExtVectorTypeLoc TL) {
62246248
TL.setNameLoc(Chunk.Loc);
62256249
}
6250+
void VisitAtomicTypeLoc(AtomicTypeLoc TL) {
6251+
fillAtomicQualLoc(TL, Chunk);
6252+
}
62266253
void
62276254
VisitDependentSizedExtVectorTypeLoc(DependentSizedExtVectorTypeLoc TL) {
62286255
TL.setNameLoc(Chunk.Loc);
@@ -6237,30 +6264,6 @@ namespace {
62376264
};
62386265
} // end anonymous namespace
62396266

6240-
static void fillAtomicQualLoc(AtomicTypeLoc ATL, const DeclaratorChunk &Chunk) {
6241-
SourceLocation Loc;
6242-
switch (Chunk.Kind) {
6243-
case DeclaratorChunk::Function:
6244-
case DeclaratorChunk::Array:
6245-
case DeclaratorChunk::Paren:
6246-
case DeclaratorChunk::Pipe:
6247-
llvm_unreachable("cannot be _Atomic qualified");
6248-
6249-
case DeclaratorChunk::Pointer:
6250-
Loc = Chunk.Ptr.AtomicQualLoc;
6251-
break;
6252-
6253-
case DeclaratorChunk::BlockPointer:
6254-
case DeclaratorChunk::Reference:
6255-
case DeclaratorChunk::MemberPointer:
6256-
// FIXME: Provide a source location for the _Atomic keyword.
6257-
break;
6258-
}
6259-
6260-
ATL.setKWLoc(Loc);
6261-
ATL.setParensRange(SourceRange());
6262-
}
6263-
62646267
static void
62656268
fillDependentAddressSpaceTypeLoc(DependentAddressSpaceTypeLoc DASTL,
62666269
const ParsedAttributesView &Attrs) {

clang/lib/StaticAnalyzer/Core/RegionStore.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -608,6 +608,9 @@ class RegionStoreManager : public StoreManager {
608608
return getBinding(getRegionBindings(S), L, T);
609609
}
610610

611+
std::optional<SVal>
612+
getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const;
613+
611614
std::optional<SVal> getDefaultBinding(Store S, const MemRegion *R) override {
612615
RegionBindingsRef B = getRegionBindings(S);
613616
// Default bindings are always applied over a base region so look up the
@@ -2605,9 +2608,43 @@ RegionBindingsRef RegionStoreManager::bindVector(RegionBindingsConstRef B,
26052608
return NewB;
26062609
}
26072610

2611+
std::optional<SVal>
2612+
RegionStoreManager::getUniqueDefaultBinding(nonloc::LazyCompoundVal LCV) const {
2613+
const MemRegion *BaseR = LCV.getRegion();
2614+
2615+
// We only handle base regions.
2616+
if (BaseR != BaseR->getBaseRegion())
2617+
return std::nullopt;
2618+
2619+
const auto *Cluster = getRegionBindings(LCV.getStore()).lookup(BaseR);
2620+
if (!Cluster || !llvm::hasSingleElement(*Cluster))
2621+
return std::nullopt;
2622+
2623+
const auto [Key, Value] = *Cluster->begin();
2624+
return Key.isDirect() ? std::optional<SVal>{} : Value;
2625+
}
2626+
26082627
std::optional<RegionBindingsRef> RegionStoreManager::tryBindSmallStruct(
26092628
RegionBindingsConstRef B, const TypedValueRegion *R, const RecordDecl *RD,
26102629
nonloc::LazyCompoundVal LCV) {
2630+
// If we try to copy a Conjured value representing the value of the whole
2631+
// struct, don't try to element-wise copy each field.
2632+
// That would unnecessarily bind Derived symbols slicing off the subregion for
2633+
// the field from the whole Conjured symbol.
2634+
//
2635+
// struct Window { int width; int height; };
2636+
// Window getWindow(); <-- opaque fn.
2637+
// Window w = getWindow(); <-- conjures a new Window.
2638+
// Window w2 = w; <-- trivial copy "w", calling "tryBindSmallStruct"
2639+
//
2640+
// We should not end up with a new Store for "w2" like this:
2641+
// Direct [ 0..31]: Derived{Conj{}, w.width}
2642+
// Direct [32..63]: Derived{Conj{}, w.height}
2643+
// Instead, we should just bind that Conjured value instead.
2644+
if (std::optional<SVal> Val = getUniqueDefaultBinding(LCV)) {
2645+
return B.addBinding(BindingKey::Make(R, BindingKey::Default), Val.value());
2646+
}
2647+
26112648
FieldVector Fields;
26122649

26132650
if (const CXXRecordDecl *Class = dyn_cast<CXXRecordDecl>(RD))

0 commit comments

Comments
 (0)