Skip to content

Commit

Permalink
merge main into amd-staging
Browse files Browse the repository at this point in the history
Change-Id: If916efb1b9a59aa8e1224baaf995b36a21087364
  • Loading branch information
ronlieb committed Jun 22, 2024
2 parents feb5081 + 8e9c6bf commit 5f8f7a7
Show file tree
Hide file tree
Showing 44 changed files with 844 additions and 541 deletions.
1 change: 1 addition & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -920,6 +920,7 @@ Bug Fixes to C++ Support
- Clang now diagnoses explicit specializations with storage class specifiers in all contexts.
- Fix an assertion failure caused by parsing a lambda used as a default argument for the value of a
forward-declared class. (#GH93512).
- Fixed a bug in access checking inside return-type-requirement of compound requirements. (#GH93788).

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Format/TokenAnnotator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2837,6 +2837,11 @@ class AnnotatingParser {
if (!AfterRParen->Next)
return false;

if (AfterRParen->is(tok::l_brace) &&
AfterRParen->getBlockKind() == BK_BracedInit) {
return true;
}

// If the next token after the parenthesis is a unary operator, assume
// that this is cast, unless there are unexpected tokens inside the
// parenthesis.
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Sema/SemaTemplateInstantiate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2735,7 +2735,7 @@ TemplateInstantiator::TransformExprRequirement(concepts::ExprRequirement *Req) {
if (TPLInst.isInvalid())
return nullptr;
TemplateParameterList *TPL = TransformTemplateParameterList(OrigTPL);
if (!TPL)
if (!TPL || Trap.hasErrorOccurred())
TransRetReq.emplace(createSubstDiag(SemaRef, Info,
[&] (llvm::raw_ostream& OS) {
RetReq.getTypeConstraint()->getImmediatelyDeclaredConstraint()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,39 @@ namespace std_example {
template<C5 T> struct C5_check {}; // expected-note{{because 'short' does not satisfy 'C5'}}
using c5 = C5_check<short>; // expected-error{{constraints not satisfied for class template 'C5_check' [with T = short]}}
}

namespace access_checks {
namespace in_return_type_requirement {

// https://github.com/llvm/llvm-project/issues/93788
template <typename From, typename To>
concept is_assignable = requires(From from, To to) {
from = to;
};

template <typename T>
class trait {
public:
using public_type = int;
private:
using private_type = int;
};

template <typename T>
concept has_field = requires(T t) {
{ t.field } -> is_assignable<typename trait<T>::private_type>; // expected-note {{'private_type' is a private member}}
};
template <typename T>
concept has_field2 = requires(T t) {
{ t.field } -> is_assignable<typename trait<T>::public_type>;
};

struct A {
int field;
};
static_assert(has_field<A>); // expected-error {{static assertion failed}} \
// expected-note {{because 'A' does not satisfy 'has_field'}}
static_assert(has_field2<A>);

} // namespace access_checks
} // namespace in_return_type_requirement
4 changes: 4 additions & 0 deletions clang/unittests/Format/TokenAnnotatorTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -662,6 +662,10 @@ TEST_F(TokenAnnotatorTest, UnderstandsCasts) {
EXPECT_TOKEN(Tokens[3], tok::r_paren, TT_Unknown);
EXPECT_TOKEN(Tokens[4], tok::amp, TT_BinaryOperator);

Tokens = annotate("return (struct foo){};");
ASSERT_EQ(Tokens.size(), 9u) << Tokens;
EXPECT_TOKEN(Tokens[4], tok::r_paren, TT_CastRParen);

Tokens = annotate("#define FOO(bar) foo((uint64_t)&bar)");
ASSERT_EQ(Tokens.size(), 15u) << Tokens;
EXPECT_TOKEN(Tokens[10], tok::r_paren, TT_CastRParen);
Expand Down
1 change: 1 addition & 0 deletions libc/config/baremetal/arm/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdlib.calloc
libc.src.stdlib.div
libc.src.stdlib.free
libc.src.stdlib.freelist_malloc
libc.src.stdlib.labs
libc.src.stdlib.ldiv
libc.src.stdlib.llabs
Expand Down
1 change: 1 addition & 0 deletions libc/config/baremetal/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,7 @@ set(TARGET_LIBC_ENTRYPOINTS
libc.src.stdlib.calloc
libc.src.stdlib.div
libc.src.stdlib.free
libc.src.stdlib.freelist_malloc
libc.src.stdlib.labs
libc.src.stdlib.ldiv
libc.src.stdlib.llabs
Expand Down
207 changes: 104 additions & 103 deletions libc/src/stdlib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -317,96 +317,121 @@ add_entrypoint_object(
libc.include.stdlib
)

if(LLVM_LIBC_INCLUDE_SCUDO)
set(SCUDO_DEPS "")
if(NOT LIBC_TARGET_OS_IS_GPU)
if(LLVM_LIBC_INCLUDE_SCUDO)
set(SCUDO_DEPS "")

include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)

# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
endif()

if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
endif()

list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})

list(APPEND SCUDO_DEPS
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
)

include(${LIBC_SOURCE_DIR}/../compiler-rt/cmake/Modules/AllSupportedArchDefs.cmake)

# scudo distinguishes riscv32 and riscv64, so we need to translate the architecture
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO ${LIBC_TARGET_ARCHITECTURE})
if(LIBC_TARGET_ARCHITECTURE_IS_RISCV64)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv64)
elseif(LIBC_TARGET_ARCHITECTURE_IS_RISCV32)
set(LIBC_TARGET_ARCHITECTURE_FOR_SCUDO riscv32)
endif()
add_entrypoint_external(
malloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
calloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
realloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
aligned_alloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
free
DEPENDS
${SCUDO_DEPS}
)
else()
# Only use freelist malloc for baremetal targets.
add_entrypoint_object(
freelist_malloc
SRCS
freelist_malloc.cpp
HDRS
malloc.h
DEPENDS
libc.src.__support.freelist_heap
COMPILE_OPTIONS
-DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
)
get_target_property(freelist_malloc_is_skipped libc.src.stdlib.freelist_malloc "SKIPPED")
if(LIBC_TARGET_OS_IS_BAREMETAL AND NOT freelist_malloc_is_skipped)
add_entrypoint_object(
malloc
ALIAS
DEPENDS
.freelist_malloc
)
else()
add_entrypoint_external(
malloc
)
endif()

if(NOT (LIBC_TARGET_ARCHITECTURE_FOR_SCUDO IN_LIST ALL_SCUDO_STANDALONE_SUPPORTED_ARCH))
message(FATAL_ERROR "Architecture ${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO} is not supported by SCUDO.
Either disable LLVM_LIBC_INCLUDE_SCUDO or change your target architecture.")
add_entrypoint_external(
free
)
add_entrypoint_external(
calloc
)
add_entrypoint_external(
realloc
)
add_entrypoint_external(
aligned_alloc
)
endif()
endif()

list(APPEND SCUDO_DEPS RTScudoStandalone.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTScudoStandaloneCWrappers.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO})
if(NOT LLVM_LIBC_FULL_BUILD)
return()
endif()

list(APPEND SCUDO_DEPS
RTGwpAsan.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanBacktraceLibc.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
RTGwpAsanSegvHandler.${LIBC_TARGET_ARCHITECTURE_FOR_SCUDO}
)
if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()

add_entrypoint_external(
if(LIBC_TARGET_OS_IS_GPU)
add_entrypoint_object(
malloc
ALIAS
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
calloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
realloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
aligned_alloc
DEPENDS
${SCUDO_DEPS}
)
add_entrypoint_external(
free
DEPENDS
${SCUDO_DEPS}
)
elseif(LIBC_TARGET_OS_IS_GPU)
add_entrypoint_external(
calloc
)
add_entrypoint_external(
realloc
)
add_entrypoint_external(
aligned_alloc
.${LIBC_TARGET_OS}.malloc
)
else()
# Only use freelist malloc for baremetal targets.
add_entrypoint_object(
freelist_malloc
SRCS
freelist_malloc.cpp
HDRS
malloc.h
DEPENDS
libc.src.__support.freelist_heap
COMPILE_OPTIONS
-DLIBC_FREELIST_MALLOC_SIZE=${LIBC_CONF_FREELIST_MALLOC_BUFFER_SIZE}
)
if(LIBC_TARGET_OS_IS_BAREMETAL)
add_entrypoint_object(
malloc
ALIAS
DEPENDS
.freelist_malloc
)
else()
add_entrypoint_external(
malloc
)
endif()

add_entrypoint_external(
free
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.free
)
add_entrypoint_external(
calloc
Expand All @@ -419,14 +444,6 @@ else()
)
endif()

if(NOT LLVM_LIBC_FULL_BUILD)
return()
endif()

if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_OS})
endif()

add_entrypoint_object(
_Exit
SRCS
Expand Down Expand Up @@ -498,19 +515,3 @@ add_entrypoint_object(
DEPENDS
.${LIBC_TARGET_OS}.abort
)

if(LIBC_TARGET_OS_IS_GPU)
add_entrypoint_object(
malloc
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.malloc
)

add_entrypoint_object(
free
ALIAS
DEPENDS
.${LIBC_TARGET_OS}.free
)
endif()
25 changes: 23 additions & 2 deletions lldb/include/lldb/Expression/ExpressionParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -119,14 +119,35 @@ class ExpressionParser {
/// \return
/// An error code indicating the success or failure of the operation.
/// Test with Success().
virtual Status
Status
PrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end,
std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
ExecutionContext &exe_ctx, bool &can_interpret,
lldb_private::ExecutionPolicy execution_policy) = 0;
lldb_private::ExecutionPolicy execution_policy);

bool GetGenerateDebugInfo() const { return m_generate_debug_info; }

protected:
virtual Status
DoPrepareForExecution(lldb::addr_t &func_addr, lldb::addr_t &func_end,
std::shared_ptr<IRExecutionUnit> &execution_unit_sp,
ExecutionContext &exe_ctx, bool &can_interpret,
lldb_private::ExecutionPolicy execution_policy) = 0;

private:
/// Run all static initializers for an execution unit.
///
/// \param[in] execution_unit_sp
/// The execution unit.
///
/// \param[in] exe_ctx
/// The execution context to use when running them. Thread can't be null.
///
/// \return
/// The error code indicating the
Status RunStaticInitializers(lldb::IRExecutionUnitSP &execution_unit_sp,
ExecutionContext &exe_ctx);

protected:
Expression &m_expr; ///< The expression to be parsed
bool m_generate_debug_info;
Expand Down
1 change: 1 addition & 0 deletions lldb/source/Expression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ add_lldb_library(lldbExpression NO_PLUGIN_DEPENDENCIES
DWARFExpression.cpp
DWARFExpressionList.cpp
Expression.cpp
ExpressionParser.cpp
ExpressionTypeSystemHelper.cpp
ExpressionVariable.cpp
FunctionCaller.cpp
Expand Down
Loading

0 comments on commit 5f8f7a7

Please sign in to comment.