Skip to content

Commit 5f03902

Browse files
committed
merge main into amd-staging
Change-Id: Ie964b84e1213a06180063dd069510060db276f72
2 parents 501414c + 3b904ae commit 5f03902

File tree

35 files changed

+585
-81
lines changed

35 files changed

+585
-81
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -802,6 +802,7 @@ Bug Fixes to C++ Support
802802
- Fixed an assertion failure caused by mangled names with invalid identifiers. (#GH112205)
803803
- Fixed an incorrect lambda scope of generic lambdas that caused Clang to crash when computing potential lambda
804804
captures at the end of a full expression. (#GH115931)
805+
- Clang no longer rejects deleting a pointer of incomplete enumeration type. (#GH99278)
805806

806807
Bug Fixes to AST Handling
807808
^^^^^^^^^^^^^^^^^^^^^^^^^

clang/include/clang/AST/AttrIterator.h

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
#define LLVM_CLANG_AST_ATTRITERATOR_H
1515

1616
#include "clang/Basic/LLVM.h"
17+
#include "llvm/ADT/ADL.h"
1718
#include "llvm/ADT/SmallVector.h"
1819
#include "llvm/Support/Casting.h"
1920
#include <cassert>
2021
#include <cstddef>
2122
#include <iterator>
23+
#include <type_traits>
2224

2325
namespace clang {
2426

@@ -113,13 +115,13 @@ inline bool hasSpecificAttr(const Container& container) {
113115
specific_attr_end<SpecificAttr>(container);
114116
}
115117
template <typename SpecificAttr, typename Container>
116-
inline SpecificAttr *getSpecificAttr(const Container& container) {
117-
specific_attr_iterator<SpecificAttr, Container> i =
118-
specific_attr_begin<SpecificAttr>(container);
119-
if (i != specific_attr_end<SpecificAttr>(container))
120-
return *i;
121-
else
122-
return nullptr;
118+
inline auto *getSpecificAttr(const Container &container) {
119+
using ValueTy = llvm::detail::ValueOfRange<Container>;
120+
using ValuePointeeTy = std::remove_pointer_t<ValueTy>;
121+
using IterTy = std::conditional_t<std::is_const_v<ValuePointeeTy>,
122+
const SpecificAttr, SpecificAttr>;
123+
auto It = specific_attr_begin<IterTy>(container);
124+
return It != specific_attr_end<IterTy>(container) ? *It : nullptr;
123125
}
124126

125127
} // namespace clang

clang/lib/CodeGen/CGLoopInfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -811,7 +811,7 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx,
811811
// Identify loop attribute 'code_align' from Attrs.
812812
// For attribute code_align:
813813
// n - 'llvm.loop.align i32 n' metadata will be emitted.
814-
if (const auto *CodeAlign = getSpecificAttr<const CodeAlignAttr>(Attrs)) {
814+
if (const auto *CodeAlign = getSpecificAttr<CodeAlignAttr>(Attrs)) {
815815
const auto *CE = cast<ConstantExpr>(CodeAlign->getAlignment());
816816
llvm::APSInt ArgVal = CE->getResultAsAPSInt();
817817
setCodeAlign(ArgVal.getSExtValue());

clang/lib/Sema/SemaExprCXX.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3747,7 +3747,8 @@ Sema::ActOnCXXDelete(SourceLocation StartLoc, bool UseGlobal,
37473747
} else if (!Pointee->isDependentType()) {
37483748
// FIXME: This can result in errors if the definition was imported from a
37493749
// module but is hidden.
3750-
if (!RequireCompleteType(StartLoc, Pointee,
3750+
if (!Pointee->isStructureOrClassType() ||
3751+
!RequireCompleteType(StartLoc, Pointee,
37513752
LangOpts.CPlusPlus26
37523753
? diag::err_delete_incomplete
37533754
: diag::warn_delete_incomplete,

clang/test/SemaCXX/new-delete.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -540,6 +540,13 @@ namespace PR10504 {
540540
void f(A *x) { delete x; } // expected-warning {{delete called on 'PR10504::A' that is abstract but has non-virtual destructor}}
541541
}
542542

543+
#if __cplusplus >= 201103L
544+
enum GH99278_1 {
545+
zero = decltype(delete static_cast<GH99278_1*>(nullptr), 0){}
546+
// expected-warning@-1 {{expression with side effects has no effect in an unevaluated context}}
547+
};
548+
#endif
549+
543550
struct PlacementArg {};
544551
inline void *operator new[](size_t, const PlacementArg &) throw () {
545552
return 0;

clang/www/hacking.html

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,9 @@ <h2 id="debugging">Debugging</h2>
8989
qualifiers, and the <tt>getTypePtr()</tt> method to get the
9090
wrapped <tt>Type*</tt> which you can then dump.</li>
9191
<li>For <a href="https://lldb.llvm.org"> <tt>LLDB</tt></a> users there are
92-
data formatters for clang data structures in
93-
<a href="https://github.com/llvm/llvm-project/blob/main/clang/utils/ClangDataFormat.py">
94-
<tt>clang/utils/ClangDataFormat.py</tt></a>.</li>
92+
data formatters for LLVM data structures in
93+
<a href="https://github.com/llvm/llvm-project/blob/main/llvm/utils/lldbDataFormatters.py">
94+
<tt>llvm/utils/lldbDataFormatters.py</tt></a>.</li>
9595
</ul>
9696

9797
<!--=====================================================================-->

flang/lib/Semantics/resolve-directives.cpp

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1895,22 +1895,29 @@ void OmpAttributeVisitor::PrivatizeAssociatedLoopIndexAndCheckLoopLevel(
18951895
}
18961896

18971897
const auto &outer{std::get<std::optional<parser::DoConstruct>>(x.t)};
1898-
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
1899-
// go through all the nested do-loops and resolve index variables
1900-
const parser::Name *iv{GetLoopIndex(*loop)};
1901-
if (iv) {
1902-
if (auto *symbol{ResolveOmp(*iv, ivDSA, currScope())}) {
1903-
symbol->set(Symbol::Flag::OmpPreDetermined);
1904-
iv->symbol = symbol; // adjust the symbol within region
1905-
AddToContextObjectWithDSA(*symbol, ivDSA);
1906-
}
1898+
if (outer.has_value()) {
1899+
for (const parser::DoConstruct *loop{&*outer}; loop && level > 0; --level) {
1900+
// go through all the nested do-loops and resolve index variables
1901+
const parser::Name *iv{GetLoopIndex(*loop)};
1902+
if (iv) {
1903+
if (auto *symbol{ResolveOmp(*iv, ivDSA, currScope())}) {
1904+
symbol->set(Symbol::Flag::OmpPreDetermined);
1905+
iv->symbol = symbol; // adjust the symbol within region
1906+
AddToContextObjectWithDSA(*symbol, ivDSA);
1907+
}
19071908

1908-
const auto &block{std::get<parser::Block>(loop->t)};
1909-
const auto it{block.begin()};
1910-
loop = it != block.end() ? GetDoConstructIf(*it) : nullptr;
1909+
const auto &block{std::get<parser::Block>(loop->t)};
1910+
const auto it{block.begin()};
1911+
loop = it != block.end() ? GetDoConstructIf(*it) : nullptr;
1912+
}
19111913
}
1914+
CheckAssocLoopLevel(level, GetAssociatedClause());
1915+
} else {
1916+
context_.Say(GetContext().directiveSource,
1917+
"A DO loop must follow the %s directive"_err_en_US,
1918+
parser::ToUpperCaseLetters(
1919+
llvm::omp::getOpenMPDirectiveName(GetContext().directive).str()));
19121920
}
1913-
CheckAssocLoopLevel(level, GetAssociatedClause());
19141921
}
19151922
void OmpAttributeVisitor::CheckAssocLoopLevel(
19161923
std::int64_t level, const parser::OmpClause *clause) {
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
! RUN: %python %S/../test_errors.py %s %flang -fopenmp
2+
! Check for existence of loop following a DO directive
3+
4+
subroutine do1
5+
!ERROR: A DO loop must follow the DO directive
6+
!$omp do
7+
end subroutine
8+
9+
subroutine do2
10+
!ERROR: A DO loop must follow the PARALLEL DO directive
11+
!$omp parallel do
12+
end subroutine
13+
14+
subroutine do3
15+
!ERROR: A DO loop must follow the SIMD directive
16+
!$omp simd
17+
end subroutine
18+
19+
subroutine do4
20+
!ERROR: A DO loop must follow the DO SIMD directive
21+
!$omp do simd
22+
end subroutine
23+
24+
subroutine do5
25+
!ERROR: A DO loop must follow the LOOP directive
26+
!$omp loop
27+
end subroutine

libunwind/src/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,22 @@ if (HAIKU)
113113

114114
add_compile_flags("-D_DEFAULT_SOURCE")
115115
add_compile_flags("-DPT_GNU_EH_FRAME=PT_EH_FRAME")
116+
117+
find_path(LIBUNWIND_HAIKU_PRIVATE_HEADERS
118+
"commpage_defs.h"
119+
PATHS ${CMAKE_SYSTEM_INCLUDE_PATH}
120+
PATH_SUFFIXES "/private/system"
121+
NO_DEFAULT_PATH
122+
REQUIRED)
123+
124+
include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}")
125+
if (LIBUNWIND_TARGET_TRIPLE)
126+
if (${LIBUNWIND_TARGET_TRIPLE} MATCHES "^x86_64")
127+
include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/x86_64")
128+
endif()
129+
else()
130+
include_directories(SYSTEM "${LIBUNWIND_HAIKU_PRIVATE_HEADERS}/arch/${CMAKE_SYSTEM_PROCESSOR}")
131+
endif()
116132
endif ()
117133

118134
string(REPLACE ";" " " LIBUNWIND_COMPILE_FLAGS "${LIBUNWIND_COMPILE_FLAGS}")

libunwind/src/UnwindCursor.hpp

Lines changed: 68 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1010,6 +1010,9 @@ class UnwindCursor : public AbstractUnwindCursor{
10101010
template <typename Registers> int stepThroughSigReturn(Registers &) {
10111011
return UNW_STEP_END;
10121012
}
1013+
#elif defined(_LIBUNWIND_TARGET_HAIKU)
1014+
bool setInfoForSigReturn();
1015+
int stepThroughSigReturn();
10131016
#endif
10141017

10151018
#if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
@@ -1313,7 +1316,8 @@ class UnwindCursor : public AbstractUnwindCursor{
13131316
unw_proc_info_t _info;
13141317
bool _unwindInfoMissing;
13151318
bool _isSignalFrame;
1316-
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
1319+
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
1320+
defined(_LIBUNWIND_TARGET_HAIKU)
13171321
bool _isSigReturn = false;
13181322
#endif
13191323
};
@@ -2549,7 +2553,8 @@ int UnwindCursor<A, R>::stepWithTBTable(pint_t pc, tbtable *TBTable,
25492553

25502554
template <typename A, typename R>
25512555
void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
2552-
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
2556+
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
2557+
defined(_LIBUNWIND_TARGET_HAIKU)
25532558
_isSigReturn = false;
25542559
#endif
25552560

@@ -2673,7 +2678,8 @@ void UnwindCursor<A, R>::setInfoBasedOnIPRegister(bool isReturnAddress) {
26732678
}
26742679
#endif // #if defined(_LIBUNWIND_SUPPORT_DWARF_UNWIND)
26752680

2676-
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
2681+
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
2682+
defined(_LIBUNWIND_TARGET_HAIKU)
26772683
if (setInfoForSigReturn())
26782684
return;
26792685
#endif
@@ -2749,6 +2755,63 @@ int UnwindCursor<A, R>::stepThroughSigReturn(Registers_arm64 &) {
27492755
_isSignalFrame = true;
27502756
return UNW_STEP_SUCCESS;
27512757
}
2758+
2759+
#elif defined(_LIBUNWIND_TARGET_HAIKU) && defined(_LIBUNWIND_TARGET_X86_64)
2760+
#include <commpage_defs.h>
2761+
#include <signal.h>
2762+
2763+
extern "C" {
2764+
extern void *__gCommPageAddress;
2765+
}
2766+
2767+
template <typename A, typename R>
2768+
bool UnwindCursor<A, R>::setInfoForSigReturn() {
2769+
#if defined(_LIBUNWIND_TARGET_X86_64)
2770+
addr_t signal_handler =
2771+
(((addr_t *)__gCommPageAddress)[COMMPAGE_ENTRY_X86_SIGNAL_HANDLER] +
2772+
(addr_t)__gCommPageAddress);
2773+
addr_t signal_handler_ret = signal_handler + 45;
2774+
#endif
2775+
pint_t pc = static_cast<pint_t>(this->getReg(UNW_REG_IP));
2776+
if (pc == signal_handler_ret) {
2777+
_info = {};
2778+
_info.start_ip = signal_handler;
2779+
_info.end_ip = signal_handler_ret;
2780+
_isSigReturn = true;
2781+
return true;
2782+
}
2783+
return false;
2784+
}
2785+
2786+
template <typename A, typename R>
2787+
int UnwindCursor<A, R>::stepThroughSigReturn() {
2788+
_isSignalFrame = true;
2789+
pint_t sp = _registers.getSP();
2790+
#if defined(_LIBUNWIND_TARGET_X86_64)
2791+
vregs *regs = (vregs *)(sp + 0x70);
2792+
2793+
_registers.setRegister(UNW_REG_IP, regs->rip);
2794+
_registers.setRegister(UNW_REG_SP, regs->rsp);
2795+
_registers.setRegister(UNW_X86_64_RAX, regs->rax);
2796+
_registers.setRegister(UNW_X86_64_RDX, regs->rdx);
2797+
_registers.setRegister(UNW_X86_64_RCX, regs->rcx);
2798+
_registers.setRegister(UNW_X86_64_RBX, regs->rbx);
2799+
_registers.setRegister(UNW_X86_64_RSI, regs->rsi);
2800+
_registers.setRegister(UNW_X86_64_RDI, regs->rdi);
2801+
_registers.setRegister(UNW_X86_64_RBP, regs->rbp);
2802+
_registers.setRegister(UNW_X86_64_R8, regs->r8);
2803+
_registers.setRegister(UNW_X86_64_R9, regs->r9);
2804+
_registers.setRegister(UNW_X86_64_R10, regs->r10);
2805+
_registers.setRegister(UNW_X86_64_R11, regs->r11);
2806+
_registers.setRegister(UNW_X86_64_R12, regs->r12);
2807+
_registers.setRegister(UNW_X86_64_R13, regs->r13);
2808+
_registers.setRegister(UNW_X86_64_R14, regs->r14);
2809+
_registers.setRegister(UNW_X86_64_R15, regs->r15);
2810+
// TODO: XMM
2811+
#endif
2812+
2813+
return UNW_STEP_SUCCESS;
2814+
}
27522815
#endif // defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) &&
27532816
// defined(_LIBUNWIND_TARGET_AARCH64)
27542817

@@ -2917,7 +2980,8 @@ template <typename A, typename R> int UnwindCursor<A, R>::step(bool stage2) {
29172980

29182981
// Use unwinding info to modify register set as if function returned.
29192982
int result;
2920-
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN)
2983+
#if defined(_LIBUNWIND_CHECK_LINUX_SIGRETURN) || \
2984+
defined(_LIBUNWIND_TARGET_HAIKU)
29212985
if (_isSigReturn) {
29222986
result = this->stepThroughSigReturn();
29232987
} else

0 commit comments

Comments
 (0)