Skip to content

Commit 24d8edb

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into sret_fixes
2 parents c8f03e7 + 93cda6d commit 24d8edb

File tree

336 files changed

+7765
-4704
lines changed

Some content is hidden

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

336 files changed

+7765
-4704
lines changed

clang-tools-extra/clangd/Protocol.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -504,6 +504,16 @@ bool fromJSON(const llvm::json::Value &Params, ClientCapabilities &R,
504504
P.field("offsetEncoding")))
505505
return false;
506506
}
507+
508+
if (auto *Experimental = O->getObject("experimental")) {
509+
if (auto *TextDocument = Experimental->getObject("textDocument")) {
510+
if (auto *Completion = TextDocument->getObject("completion")) {
511+
if (auto EditsNearCursor = Completion->getBoolean("editsNearCursor"))
512+
R.CompletionFixes |= *EditsNearCursor;
513+
}
514+
}
515+
}
516+
507517
return true;
508518
}
509519

clang/Maintainers.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,12 @@ Sema
6969
| aeternalmail\@gmail.com (email), Sirraide (GitHub), Ætérnal (Discord), Sirraide (Discourse)
7070
7171

72+
Recovery AST
73+
~~~~~~~~~~~~
74+
| Haojian Wu
75+
| hokein.wu\@gmail.com (email), hokein (Phabricator), hokein (GitHub), hokein (Discourse)
76+
77+
7278
Experimental new constant interpreter
7379
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7480
| Timm Bäder

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -872,10 +872,9 @@ Sanitizers
872872
This new flag should allow those projects to enable integer sanitizers with
873873
less noise.
874874

875-
- Arithmetic overflow sanitizers ``-fsanitize=signed-integer-overflow`` and
876-
``-fsanitize=unsigned-integer-overflow`` as well as the implicit integer
877-
truncation sanitizers ``-fsanitize=implicit-signed-integer-truncation`` and
878-
``-fsanitize=implicit-unsigned-integer-truncation`` now properly support the
875+
- ``-fsanitize=signed-integer-overflow``, ``-fsanitize=unsigned-integer-overflow``,
876+
``-fsanitize=implicit-signed-integer-truncation``, ``-fsanitize=implicit-unsigned-integer-truncation``,
877+
``-fsanitize=enum`` now properly support the
879878
"type" prefix within `Sanitizer Special Case Lists (SSCL)
880879
<https://clang.llvm.org/docs/SanitizerSpecialCaseList.html>`_. See that link
881880
for examples.

clang/docs/SanitizerSpecialCaseList.rst

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,9 @@ Goal and usage
1616
==============
1717

1818
Users of sanitizer tools, such as :doc:`AddressSanitizer`,
19-
:doc:`ThreadSanitizer`, :doc:`MemorySanitizer` or :doc:`UndefinedBehaviorSanitizer`
20-
may want to disable or alter some checks for certain source-level entities to:
19+
:doc:`HardwareAssistedAddressSanitizerDesign`, :doc:`ThreadSanitizer`,
20+
:doc:`MemorySanitizer` or :doc:`UndefinedBehaviorSanitizer` may want to disable
21+
or alter some checks for certain source-level entities to:
2122

2223
* speedup hot function, which is known to be correct;
2324
* ignore a function that does some low-level magic (e.g. walks through the
@@ -51,11 +52,10 @@ Example
5152
Usage with UndefinedBehaviorSanitizer
5253
=====================================
5354

54-
The arithmetic overflow sanitizers ``unsigned-integer-overflow`` and
55-
``signed-integer-overflow`` as well as the implicit integer truncation
56-
sanitizers ``implicit-signed-integer-truncation`` and
57-
``implicit-unsigned-integer-truncation`` support the ability to adjust
58-
instrumentation based on type.
55+
``unsigned-integer-overflow``, ``signed-integer-overflow``,
56+
``implicit-signed-integer-truncation``,
57+
``implicit-unsigned-integer-truncation``, and ``enum`` sanitizers support the
58+
ability to adjust instrumentation based on type.
5959

6060
By default, supported sanitizers will have their instrumentation disabled for
6161
types specified within an ignorelist.

clang/docs/analyzer/checkers.rst

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3459,8 +3459,8 @@ Raw pointers and references to an object which supports CheckedPtr or CheckedRef
34593459
.. code-block:: cpp
34603460
34613461
struct CheckableObj {
3462-
void incrementPtrCount() {}
3463-
void decrementPtrCount() {}
3462+
void incrementCheckedPtrCount() {}
3463+
void decrementCheckedPtrCount() {}
34643464
};
34653465
34663466
struct Foo {

clang/include/clang/AST/Decl.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -737,7 +737,7 @@ class DeclaratorDecl : public ValueDecl {
737737
// qualifier, to be used for the (uncommon) case of out-of-line declarations
738738
// and constrained function decls.
739739
struct ExtInfo : public QualifierInfo {
740-
TypeSourceInfo *TInfo;
740+
TypeSourceInfo *TInfo = nullptr;
741741
Expr *TrailingRequiresClause = nullptr;
742742
};
743743

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2735,7 +2735,7 @@ bool Compiler<Emitter>::VisitMaterializeTemporaryExpr(
27352735
InitLinkScope<Emitter> ILS(this, InitLink::Temp(*LocalIndex));
27362736
if (!this->emitGetPtrLocal(*LocalIndex, E))
27372737
return false;
2738-
return this->visitInitializer(SubExpr);
2738+
return this->visitInitializer(SubExpr) && this->emitFinishInit(E);
27392739
}
27402740
}
27412741
return false;
@@ -6446,8 +6446,6 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
64466446
QualType ToType = E->getType();
64476447
std::optional<PrimType> ToT = classify(ToType);
64486448

6449-
assert(!DiscardResult && "Implement DiscardResult mode for bitcasts.");
6450-
64516449
if (ToType->isNullPtrType()) {
64526450
if (!this->discard(SubExpr))
64536451
return false;
@@ -6463,12 +6461,24 @@ bool Compiler<Emitter>::emitBuiltinBitCast(const CastExpr *E) {
64636461
}
64646462
assert(!ToType->isReferenceType());
64656463

6464+
// Prepare storage for the result in case we discard.
6465+
if (DiscardResult && !Initializing && !ToT) {
6466+
std::optional<unsigned> LocalIndex = allocateLocal(E);
6467+
if (!LocalIndex)
6468+
return false;
6469+
if (!this->emitGetPtrLocal(*LocalIndex, E))
6470+
return false;
6471+
}
6472+
64666473
// Get a pointer to the value-to-cast on the stack.
64676474
if (!this->visit(SubExpr))
64686475
return false;
64696476

6470-
if (!ToT || ToT == PT_Ptr)
6471-
return this->emitBitCastPtr(E);
6477+
if (!ToT || ToT == PT_Ptr) {
6478+
if (!this->emitBitCastPtr(E))
6479+
return false;
6480+
return DiscardResult ? this->emitPopPtr(E) : true;
6481+
}
64726482
assert(ToT);
64736483

64746484
const llvm::fltSemantics *TargetSemantics = nullptr;

clang/lib/AST/ByteCode/InterpBuiltinBitCast.cpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,19 +397,35 @@ bool clang::interp::DoBitCastPtr(InterpState &S, CodePtr OpPC,
397397
/*ReturnOnUninit=*/false);
398398

399399
// Now read the values out of the buffer again and into ToPtr.
400+
const ASTContext &ASTCtx = S.getASTContext();
400401
size_t BitOffset = 0;
401402
bool Success = enumeratePointerFields(
402403
ToPtr, S.getContext(),
403404
[&](const Pointer &P, PrimType T, size_t _) -> bool {
404-
BITCAST_TYPE_SWITCH_FIXED_SIZE(T, {
405-
T &Val = P.deref<T>();
405+
if (T == PT_Float) {
406+
CharUnits ObjectReprChars = ASTCtx.getTypeSizeInChars(P.getType());
407+
const auto &Semantics = ASTCtx.getFloatTypeSemantics(P.getType());
408+
unsigned NumBits = llvm::APFloatBase::getSizeInBits(Semantics);
409+
assert(NumBits % 8 == 0);
410+
assert(NumBits <= ASTCtx.toBits(ObjectReprChars));
411+
std::byte *M = Buffer.getBytes(BitOffset);
412+
413+
if (llvm::sys::IsBigEndianHost)
414+
swapBytes(M, NumBits / 8);
406415

416+
P.deref<Floating>() = Floating::bitcastFromMemory(M, Semantics);
417+
P.initialize();
418+
BitOffset += ASTCtx.toBits(ObjectReprChars);
419+
return true;
420+
}
421+
422+
BITCAST_TYPE_SWITCH_FIXED_SIZE(T, {
407423
std::byte *M = Buffer.getBytes(BitOffset);
408424

409425
if (llvm::sys::IsBigEndianHost)
410426
swapBytes(M, T::bitWidth() / 8);
411427

412-
Val = T::bitcastFromMemory(M, T::bitWidth());
428+
P.deref<T>() = T::bitcastFromMemory(M, T::bitWidth());
413429
P.initialize();
414430
BitOffset += T::bitWidth();
415431
});

clang/lib/CodeGen/CGExpr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1941,6 +1941,10 @@ bool CodeGenFunction::EmitScalarRangeCheck(llvm::Value *Value, QualType Ty,
19411941
cast<llvm::IntegerType>(Value->getType())->getBitWidth() == 1)
19421942
return false;
19431943

1944+
if (NeedsEnumCheck &&
1945+
getContext().isTypeIgnoredBySanitizer(SanitizerKind::Enum, Ty))
1946+
return false;
1947+
19441948
llvm::APInt Min, End;
19451949
if (!getRangeForType(*this, Ty, Min, End, /*StrictEnums=*/true, IsBool))
19461950
return true;

clang/lib/Driver/Driver.cpp

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -149,13 +149,9 @@ static std::optional<llvm::Triple>
149149
getHIPOffloadTargetTriple(const Driver &D, const ArgList &Args) {
150150
if (!Args.hasArg(options::OPT_offload_EQ)) {
151151
auto OffloadArchs = Args.getAllArgValues(options::OPT_offload_arch_EQ);
152-
if (llvm::is_contained(OffloadArchs, "amdgcnspirv")) {
153-
if (OffloadArchs.size() == 1)
154-
return llvm::Triple("spirv64-amd-amdhsa");
155-
// Mixing specific & SPIR-V compilation is not supported for now.
156-
D.Diag(diag::err_drv_only_one_offload_target_supported);
157-
return std::nullopt;
158-
}
152+
if (llvm::is_contained(OffloadArchs, "amdgcnspirv") &&
153+
OffloadArchs.size() == 1)
154+
return llvm::Triple("spirv64-amd-amdhsa");
159155
return llvm::Triple("amdgcn-amd-amdhsa"); // Default HIP triple.
160156
}
161157
auto TT = getOffloadTargetTriple(D, Args);
@@ -3477,9 +3473,11 @@ class OffloadingActionBuilder final {
34773473
llvm::StringMap<bool> Features;
34783474
// getHIPOffloadTargetTriple() is known to return valid value as it has
34793475
// been called successfully in the CreateOffloadingDeviceToolChains().
3480-
auto ArchStr = parseTargetID(
3481-
*getHIPOffloadTargetTriple(C.getDriver(), C.getInputArgs()), IdStr,
3482-
&Features);
3476+
auto T =
3477+
(IdStr == "amdgcnspirv")
3478+
? llvm::Triple("spirv64-amd-amdhsa")
3479+
: *getHIPOffloadTargetTriple(C.getDriver(), C.getInputArgs());
3480+
auto ArchStr = parseTargetID(T, IdStr, &Features);
34833481
if (!ArchStr) {
34843482
C.getDriver().Diag(clang::diag::err_drv_bad_target_id) << IdStr;
34853483
C.setContainsError();
@@ -5755,7 +5753,7 @@ InputInfoList Driver::BuildJobsForActionNoCache(
57555753
// We only have to generate a prefix for the host if this is not a top-level
57565754
// action.
57575755
std::string OffloadingPrefix = Action::GetOffloadingFileNamePrefix(
5758-
A->getOffloadingDeviceKind(), TC->getTriple().normalize(),
5756+
A->getOffloadingDeviceKind(), EffectiveTriple.normalize(),
57595757
/*CreatePrefixForHost=*/isa<OffloadPackagerJobAction>(A) ||
57605758
!(A->getOffloadingHostActiveKinds() == Action::OFK_None ||
57615759
AtTopLevel));

0 commit comments

Comments
 (0)