Skip to content

Commit 7ed352e

Browse files
committed
[AutoBump] Merge with 7c24041 (Feb 18)
2 parents a50472d + 7c24041 commit 7ed352e

File tree

42 files changed

+601
-89
lines changed

Some content is hidden

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

42 files changed

+601
-89
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2629,7 +2629,7 @@ with the current table size.
26292629
.. code-block:: c++
26302630
26312631
typedef void (*__funcref funcref_t)();
2632-
static __funcref table[0];
2632+
static funcref_t table[0];
26332633
26342634
size_t getSize() {
26352635
return __builtin_wasm_table_size(table);
@@ -2651,10 +2651,10 @@ or -1. It will return -1 if not enough space could be allocated.
26512651
.. code-block:: c++
26522652
26532653
typedef void (*__funcref funcref_t)();
2654-
static __funcref table[0];
2654+
static funcref_t table[0];
26552655
26562656
// grow returns the new table size or -1 on error.
2657-
int grow(__funcref fn, int delta) {
2657+
int grow(funcref_t fn, int delta) {
26582658
int prevSize = __builtin_wasm_table_grow(table, fn, delta);
26592659
if (prevSize == -1)
26602660
return -1;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10606,6 +10606,9 @@ def warn_noreturn_function_has_return_expr : Warning<
1060610606
def warn_falloff_noreturn_function : Warning<
1060710607
"function declared 'noreturn' should not return">,
1060810608
InGroup<InvalidNoreturn>;
10609+
def warn_noreturn_coroutine : Warning<
10610+
"coroutine %0 cannot be declared 'noreturn' as it always returns a coroutine handle">,
10611+
InGroup<InvalidNoreturn>;
1060910612
def err_noreturn_block_has_return_expr : Error<
1061010613
"block declared 'noreturn' should not return">;
1061110614
def err_carries_dependency_missing_on_first_decl : Error<

clang/lib/Sema/AnalysisBasedWarnings.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -697,10 +697,12 @@ static void CheckFallThroughForBody(Sema &S, const Decl *D, const Stmt *Body,
697697
return;
698698
SourceLocation LBrace = Body->getBeginLoc(), RBrace = Body->getEndLoc();
699699
auto EmitDiag = [&](SourceLocation Loc, unsigned DiagID) {
700-
if (IsCoroutine)
701-
S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
702-
else
700+
if (IsCoroutine) {
701+
if (DiagID != 0)
702+
S.Diag(Loc, DiagID) << FSI->CoroutinePromise->getType();
703+
} else {
703704
S.Diag(Loc, DiagID);
705+
}
704706
};
705707

706708
// cpu_dispatch functions permit empty function bodies for ICC compatibility.

clang/lib/Sema/SemaCoroutine.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,10 @@ void Sema::CheckCompletedCoroutineBody(FunctionDecl *FD, Stmt *&Body) {
11761176
for (AddrLabelExpr *ALE : Fn->AddrLabels)
11771177
Diag(ALE->getBeginLoc(), diag::err_coro_invalid_addr_of_label);
11781178

1179+
// Coroutines always return a handle, so they can't be [[noreturn]].
1180+
if (FD->isNoReturn())
1181+
Diag(FD->getLocation(), diag::warn_noreturn_coroutine) << FD;
1182+
11791183
CoroutineStmtBuilder Builder(*this, *FD, *Fn, Body);
11801184
if (Builder.isInvalid() || !Builder.buildStatements())
11811185
return FD->setInvalidDecl();

clang/lib/Sema/SemaStmt.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3910,7 +3910,7 @@ StmtResult Sema::BuildReturnStmt(SourceLocation ReturnLoc, Expr *RetValExp,
39103910
FnRetType = FD->getReturnType();
39113911
if (FD->hasAttrs())
39123912
Attrs = &FD->getAttrs();
3913-
if (FD->isNoReturn())
3913+
if (FD->isNoReturn() && !getCurFunction()->isCoroutine())
39143914
Diag(ReturnLoc, diag::warn_noreturn_function_has_return_expr) << FD;
39153915
if (FD->isMain() && RetValExp)
39163916
if (isa<CXXBoolLiteralExpr>(RetValExp))
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// RUN: %clang_cc1 %s -std=c++20 -fsyntax-only -Winvalid-noreturn -verify
2+
3+
#include "Inputs/std-coroutine.h"
4+
5+
struct Promise;
6+
7+
struct Awaitable {
8+
bool await_ready();
9+
void await_suspend(std::coroutine_handle<>);
10+
void await_resume();
11+
};
12+
13+
struct Coro : std::coroutine_handle<> {
14+
using promise_type = Promise;
15+
};
16+
17+
struct Promise {
18+
Coro get_return_object();
19+
std::suspend_always initial_suspend() noexcept;
20+
std::suspend_always final_suspend() noexcept;
21+
void return_void();
22+
void unhandled_exception();
23+
};
24+
25+
[[noreturn]] Coro test() { // expected-warning {{coroutine 'test' cannot be declared 'noreturn' as it always returns a coroutine handle}}
26+
co_await Awaitable{};
27+
}
28+
29+
// NO warning here. This could be a regular function returning a `Coro` object.
30+
[[noreturn]] Coro test2();

flang-rt/include/flang-rt/runtime/io-stmt.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,7 @@ class OpenStatementState : public ExternalIoStatementBase {
627627
Fortran::common::optional<Action> action_;
628628
Convert convert_{Convert::Unknown};
629629
OwningPtr<char> path_;
630-
std::size_t pathLength_;
630+
std::size_t pathLength_{};
631631
Fortran::common::optional<bool> isUnformatted_;
632632
Fortran::common::optional<Access> access_;
633633
};

lldb/include/lldb/Symbol/ObjectFile.h

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,9 +81,14 @@ class ObjectFile : public std::enable_shared_from_this<ObjectFile>,
8181
enum BinaryType {
8282
eBinaryTypeInvalid = 0,
8383
eBinaryTypeUnknown,
84-
eBinaryTypeKernel, /// kernel binary
85-
eBinaryTypeUser, /// user process binary
86-
eBinaryTypeStandalone /// standalone binary / firmware
84+
/// kernel binary
85+
eBinaryTypeKernel,
86+
/// user process binary, dyld addr
87+
eBinaryTypeUser,
88+
/// user process binary, dyld_all_image_infos addr
89+
eBinaryTypeUserAllImageInfos,
90+
/// standalone binary / firmware
91+
eBinaryTypeStandalone
8792
};
8893

8994
struct LoadableData {

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5599,9 +5599,13 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
55995599
// struct main_bin_spec
56005600
// {
56015601
// uint32_t version; // currently 2
5602-
// uint32_t type; // 0 == unspecified, 1 == kernel,
5602+
// uint32_t type; // 0 == unspecified,
5603+
// // 1 == kernel
56035604
// // 2 == user process,
5605+
// dyld mach-o binary addr
56045606
// // 3 == standalone binary
5607+
// // 4 == user process,
5608+
// // dyld_all_image_infos addr
56055609
// uint64_t address; // UINT64_MAX if address not specified
56065610
// uint64_t slide; // slide, UINT64_MAX if unspecified
56075611
// // 0 if no slide needs to be applied to
@@ -5652,6 +5656,7 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
56525656
// convert the "main bin spec" type into our
56535657
// ObjectFile::BinaryType enum
56545658
const char *typestr = "unrecognized type";
5659+
type = eBinaryTypeInvalid;
56555660
switch (binspec_type) {
56565661
case 0:
56575662
type = eBinaryTypeUnknown;
@@ -5669,6 +5674,10 @@ bool ObjectFileMachO::GetCorefileMainBinaryInfo(addr_t &value,
56695674
type = eBinaryTypeStandalone;
56705675
typestr = "standalone";
56715676
break;
5677+
case 4:
5678+
type = eBinaryTypeUserAllImageInfos;
5679+
typestr = "userland dyld_all_image_infos";
5680+
break;
56725681
}
56735682
LLDB_LOGF(log,
56745683
"LC_NOTE 'main bin spec' found, version %d type %d "

lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp

Lines changed: 37 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ ProcessMachCore::ProcessMachCore(lldb::TargetSP target_sp,
114114
: PostMortemProcess(target_sp, listener_sp, core_file), m_core_aranges(),
115115
m_core_range_infos(), m_core_module_sp(),
116116
m_dyld_addr(LLDB_INVALID_ADDRESS),
117+
m_dyld_all_image_infos_addr(LLDB_INVALID_ADDRESS),
117118
m_mach_kernel_addr(LLDB_INVALID_ADDRESS) {}
118119

119120
// Destructor
@@ -320,6 +321,9 @@ bool ProcessMachCore::LoadBinariesViaMetadata() {
320321
} else if (type == ObjectFile::eBinaryTypeUser) {
321322
m_dyld_addr = objfile_binary_value;
322323
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
324+
} else if (type == ObjectFile::eBinaryTypeUserAllImageInfos) {
325+
m_dyld_all_image_infos_addr = objfile_binary_value;
326+
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
323327
} else {
324328
const bool force_symbol_search = true;
325329
const bool notify = true;
@@ -466,6 +470,7 @@ void ProcessMachCore::LoadBinariesViaExhaustiveSearch() {
466470
addr_t saved_user_dyld_addr = m_dyld_addr;
467471
m_mach_kernel_addr = LLDB_INVALID_ADDRESS;
468472
m_dyld_addr = LLDB_INVALID_ADDRESS;
473+
m_dyld_all_image_infos_addr = LLDB_INVALID_ADDRESS;
469474

470475
addr_t better_kernel_address =
471476
DynamicLoaderDarwinKernel::SearchForDarwinKernel(this);
@@ -507,6 +512,12 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
507512
"image at 0x%" PRIx64,
508513
__FUNCTION__, m_dyld_addr);
509514
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
515+
} else if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS) {
516+
LLDB_LOGF(log,
517+
"ProcessMachCore::%s: Using user process dyld "
518+
"dyld_all_image_infos at 0x%" PRIx64,
519+
__FUNCTION__, m_dyld_all_image_infos_addr);
520+
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
510521
}
511522
} else {
512523
if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
@@ -515,6 +526,11 @@ void ProcessMachCore::LoadBinariesAndSetDYLD() {
515526
"image at 0x%" PRIx64,
516527
__FUNCTION__, m_dyld_addr);
517528
m_dyld_plugin_name = DynamicLoaderMacOSXDYLD::GetPluginNameStatic();
529+
} else if (m_dyld_all_image_infos_addr != LLDB_INVALID_ADDRESS) {
530+
LLDB_LOGF(log,
531+
"ProcessMachCore::%s: Using user process dyld "
532+
"dyld_all_image_infos at 0x%" PRIx64,
533+
__FUNCTION__, m_dyld_all_image_infos_addr);
518534
} else if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
519535
LLDB_LOGF(log,
520536
"ProcessMachCore::%s: Using kernel "
@@ -763,19 +779,32 @@ void ProcessMachCore::Initialize() {
763779
}
764780

765781
addr_t ProcessMachCore::GetImageInfoAddress() {
766-
// If we found both a user-process dyld and a kernel binary, we need to
767-
// decide which to prefer.
782+
// The DynamicLoader plugin will call back in to this Process
783+
// method to find the virtual address of one of these:
784+
// 1. The xnu mach kernel binary Mach-O header
785+
// 2. The dyld binary Mach-O header
786+
// 3. dyld's dyld_all_image_infos object
787+
//
788+
// DynamicLoaderMacOSX will accept either the dyld Mach-O header
789+
// address or the dyld_all_image_infos interchangably, no need
790+
// to distinguish between them. It disambiguates by the Mach-O
791+
// file magic number at the start.
768792
if (GetCorefilePreference() == eKernelCorefile) {
769-
if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS) {
793+
if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
770794
return m_mach_kernel_addr;
771-
}
772-
return m_dyld_addr;
795+
if (m_dyld_addr != LLDB_INVALID_ADDRESS)
796+
return m_dyld_addr;
773797
} else {
774-
if (m_dyld_addr != LLDB_INVALID_ADDRESS) {
798+
if (m_dyld_addr != LLDB_INVALID_ADDRESS)
775799
return m_dyld_addr;
776-
}
777-
return m_mach_kernel_addr;
800+
if (m_mach_kernel_addr != LLDB_INVALID_ADDRESS)
801+
return m_mach_kernel_addr;
778802
}
803+
804+
// m_dyld_addr and m_mach_kernel_addr both
805+
// invalid, return m_dyld_all_image_infos_addr
806+
// in case it has a useful value.
807+
return m_dyld_all_image_infos_addr;
779808
}
780809

781810
lldb_private::ObjectFile *ProcessMachCore::GetCoreObjectFile() {

0 commit comments

Comments
 (0)