Skip to content

Commit 8cc500e

Browse files
committed
merge main f5ef9bd into amd-staging
Change-Id: I22dca040abe725eb538f5f38c4791dd0f1f0249d
2 parents 3f1723a + f5ef9bd commit 8cc500e

File tree

252 files changed

+7644
-4661
lines changed

Some content is hidden

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

252 files changed

+7644
-4661
lines changed

clang/docs/LanguageExtensions.rst

Lines changed: 80 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,40 +1459,45 @@ More information could be found `here <https://clang.llvm.org/docs/Modules.html>
14591459
Language Extensions Back-ported to Previous Standards
14601460
=====================================================
14611461

1462-
====================================== ================================ ============= =============
1463-
Feature Feature Test Macro Introduced In Backported To
1464-
====================================== ================================ ============= =============
1465-
variadic templates __cpp_variadic_templates C++11 C++03
1466-
Alias templates __cpp_alias_templates C++11 C++03
1467-
Non-static data member initializers __cpp_nsdmi C++11 C++03
1468-
Range-based ``for`` loop __cpp_range_based_for C++11 C++03
1469-
RValue references __cpp_rvalue_references C++11 C++03
1470-
Attributes __cpp_attributes C++11 C++03
1471-
variable templates __cpp_variable_templates C++14 C++03
1472-
Binary literals __cpp_binary_literals C++14 C++03
1473-
Relaxed constexpr __cpp_constexpr C++14 C++11
1474-
``if constexpr`` __cpp_if_constexpr C++17 C++11
1475-
fold expressions __cpp_fold_expressions C++17 C++03
1476-
Lambda capture of \*this by value __cpp_capture_star_this C++17 C++11
1477-
Attributes on enums __cpp_enumerator_attributes C++17 C++03
1478-
Guaranteed copy elision __cpp_guaranteed_copy_elision C++17 C++03
1479-
Hexadecimal floating literals __cpp_hex_float C++17 C++03
1480-
``inline`` variables __cpp_inline_variables C++17 C++03
1481-
Attributes on namespaces __cpp_namespace_attributes C++17 C++11
1482-
Structured bindings __cpp_structured_bindings C++17 C++03
1483-
template template arguments __cpp_template_template_args C++17 C++03
1484-
``static operator[]`` __cpp_multidimensional_subscript C++20 C++03
1485-
Designated initializers __cpp_designated_initializers C++20 C++03
1486-
Conditional ``explicit`` __cpp_conditional_explicit C++20 C++03
1487-
``using enum`` __cpp_using_enum C++20 C++03
1488-
``if consteval`` __cpp_if_consteval C++23 C++20
1489-
``static operator()`` __cpp_static_call_operator C++23 C++03
1490-
Attributes on Lambda-Expressions C++23 C++11
1491-
-------------------------------------- -------------------------------- ------------- -------------
1492-
Designated initializers (N494) C99 C89
1493-
Array & element qualification (N2607) C23 C89
1494-
Attributes (N2335) C23 C89
1495-
====================================== ================================ ============= =============
1462+
============================================ ================================ ============= =============
1463+
Feature Feature Test Macro Introduced In Backported To
1464+
============================================ ================================ ============= =============
1465+
variadic templates __cpp_variadic_templates C++11 C++03
1466+
Alias templates __cpp_alias_templates C++11 C++03
1467+
Non-static data member initializers __cpp_nsdmi C++11 C++03
1468+
Range-based ``for`` loop __cpp_range_based_for C++11 C++03
1469+
RValue references __cpp_rvalue_references C++11 C++03
1470+
Attributes __cpp_attributes C++11 C++03
1471+
Lambdas __cpp_lambdas C++11 C++03
1472+
Generalized lambda captures __cpp_init_captures C++14 C++03
1473+
Generic lambda expressions __cpp_generic_lambdas C++14 C++03
1474+
variable templates __cpp_variable_templates C++14 C++03
1475+
Binary literals __cpp_binary_literals C++14 C++03
1476+
Relaxed constexpr __cpp_constexpr C++14 C++11
1477+
Pack expansion in generalized lambda-capture __cpp_init_captures C++17 C++03
1478+
``if constexpr`` __cpp_if_constexpr C++17 C++11
1479+
fold expressions __cpp_fold_expressions C++17 C++03
1480+
Lambda capture of \*this by value __cpp_capture_star_this C++17 C++03
1481+
Attributes on enums __cpp_enumerator_attributes C++17 C++03
1482+
Guaranteed copy elision __cpp_guaranteed_copy_elision C++17 C++03
1483+
Hexadecimal floating literals __cpp_hex_float C++17 C++03
1484+
``inline`` variables __cpp_inline_variables C++17 C++03
1485+
Attributes on namespaces __cpp_namespace_attributes C++17 C++11
1486+
Structured bindings __cpp_structured_bindings C++17 C++03
1487+
template template arguments __cpp_template_template_args C++17 C++03
1488+
Familiar template syntax for generic lambdas __cpp_generic_lambdas C++20 C++03
1489+
``static operator[]`` __cpp_multidimensional_subscript C++20 C++03
1490+
Designated initializers __cpp_designated_initializers C++20 C++03
1491+
Conditional ``explicit`` __cpp_conditional_explicit C++20 C++03
1492+
``using enum`` __cpp_using_enum C++20 C++03
1493+
``if consteval`` __cpp_if_consteval C++23 C++20
1494+
``static operator()`` __cpp_static_call_operator C++23 C++03
1495+
Attributes on Lambda-Expressions C++23 C++11
1496+
-------------------------------------------- -------------------------------- ------------- -------------
1497+
Designated initializers (N494) C99 C89
1498+
Array & element qualification (N2607) C23 C89
1499+
Attributes (N2335) C23 C89
1500+
============================================ ================================ ============= =============
14961501

14971502
Type Trait Primitives
14981503
=====================
@@ -3548,6 +3553,47 @@ argument can be of any unsigned integer type.
35483553
``__builtin_popcount{,l,ll}`` builtins, with support for other integer types,
35493554
such as ``unsigned __int128`` and C23 ``unsigned _BitInt(N)``.
35503555
3556+
``__builtin_clzg`` and ``__builtin_ctzg``
3557+
-----------------------------------------
3558+
3559+
``__builtin_clzg`` (respectively ``__builtin_ctzg``) returns the number of
3560+
leading (respectively trailing) 0 bits in the first argument. The first argument
3561+
can be of any unsigned integer type.
3562+
3563+
If the first argument is 0 and an optional second argument of ``int`` type is
3564+
provided, then the second argument is returned. If the first argument is 0, but
3565+
only one argument is provided, then the behavior is undefined.
3566+
3567+
**Syntax**:
3568+
3569+
.. code-block:: c++
3570+
3571+
int __builtin_clzg(type x[, int fallback])
3572+
int __builtin_ctzg(type x[, int fallback])
3573+
3574+
**Examples**:
3575+
3576+
.. code-block:: c++
3577+
3578+
unsigned int x = 1;
3579+
int x_lz = __builtin_clzg(x);
3580+
int x_tz = __builtin_ctzg(x);
3581+
3582+
unsigned long y = 2;
3583+
int y_lz = __builtin_clzg(y);
3584+
int y_tz = __builtin_ctzg(y);
3585+
3586+
unsigned _BitInt(128) z = 4;
3587+
int z_lz = __builtin_clzg(z);
3588+
int z_tz = __builtin_ctzg(z);
3589+
3590+
**Description**:
3591+
3592+
``__builtin_clzg`` (respectively ``__builtin_ctzg``) is meant to be a
3593+
type-generic alternative to the ``__builtin_clz{,l,ll}`` (respectively
3594+
``__builtin_ctz{,l,ll}``) builtins, with support for other integer types, such
3595+
as ``unsigned __int128`` and C23 ``unsigned _BitInt(N)``.
3596+
35513597
Multiprecision Arithmetic Builtins
35523598
----------------------------------
35533599

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,8 @@ Non-comprehensive list of changes in this release
185185
the previous builtins, this new builtin is constexpr and may be used in
186186
constant expressions.
187187

188+
- Lambda expressions are now accepted in C++03 mode as an extension.
189+
188190
New Compiler Flags
189191
------------------
190192

clang/include/clang/Basic/Builtins.td

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -676,15 +676,23 @@ def Clz : Builtin, BitShort_Int_Long_LongLongTemplate {
676676
let Prototype = "int(unsigned T)";
677677
}
678678

679-
// FIXME: Add int clzimax(uintmax_t)
679+
def Clzg : Builtin {
680+
let Spellings = ["__builtin_clzg"];
681+
let Attributes = [NoThrow, Const, CustomTypeChecking];
682+
let Prototype = "int(...)";
683+
}
680684

681685
def Ctz : Builtin, BitShort_Int_Long_LongLongTemplate {
682686
let Spellings = ["__builtin_ctz"];
683687
let Attributes = [NoThrow, Const, Constexpr];
684688
let Prototype = "int(unsigned T)";
685689
}
686690

687-
// FIXME: Add int ctzimax(uintmax_t)
691+
def Ctzg : Builtin {
692+
let Spellings = ["__builtin_ctzg"];
693+
let Attributes = [NoThrow, Const, CustomTypeChecking];
694+
let Prototype = "int(...)";
695+
}
688696

689697
def FFS : Builtin, BitInt_Long_LongLongTemplate {
690698
let Spellings = ["__builtin_ffs"];

clang/include/clang/Basic/DiagnosticParseKinds.td

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1029,6 +1029,7 @@ def err_expected_lambda_body : Error<"expected body of lambda expression">;
10291029
def warn_cxx98_compat_lambda : Warning<
10301030
"lambda expressions are incompatible with C++98">,
10311031
InGroup<CXX98Compat>, DefaultIgnore;
1032+
def ext_lambda : ExtWarn<"lambdas are a C++11 extension">, InGroup<CXX11>;
10321033
def err_lambda_decl_specifier_repeated : Error<
10331034
"%select{'mutable'|'static'|'constexpr'|'consteval'}0 cannot "
10341035
"appear multiple times in a lambda declarator">;

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12018,13 +12018,14 @@ def err_builtin_launder_invalid_arg : Error<
1201812018
"'__builtin_launder' is not allowed">;
1201912019

1202012020
def err_builtin_invalid_arg_type: Error <
12021-
"%ordinal0 argument must be a "
12022-
"%select{vector, integer or floating point type|matrix|"
12023-
"pointer to a valid matrix element type|"
12024-
"signed integer or floating point type|vector type|"
12025-
"floating point type|"
12026-
"vector of integers|"
12027-
"type of unsigned integer}1 (was %2)">;
12021+
"%ordinal0 argument must be "
12022+
"%select{a vector, integer or floating point type|a matrix|"
12023+
"a pointer to a valid matrix element type|"
12024+
"a signed integer or floating point type|a vector type|"
12025+
"a floating point type|"
12026+
"a vector of integers|"
12027+
"an unsigned integer|"
12028+
"an 'int'}1 (was %2)">;
1202812029

1202912030
def err_builtin_matrix_disabled: Error<
1203012031
"matrix types extension is disabled. Pass -fenable-matrix to enable it">;

clang/include/clang/Basic/Features.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ EXTENSION(cxx_defaulted_functions, LangOpts.CPlusPlus)
261261
EXTENSION(cxx_deleted_functions, LangOpts.CPlusPlus)
262262
EXTENSION(cxx_explicit_conversions, LangOpts.CPlusPlus)
263263
EXTENSION(cxx_inline_namespaces, LangOpts.CPlusPlus)
264+
EXTENSION(cxx_lambdas, LangOpts.CPlusPlus)
264265
EXTENSION(cxx_local_type_template_args, LangOpts.CPlusPlus)
265266
EXTENSION(cxx_nonstatic_member_init, LangOpts.CPlusPlus)
266267
EXTENSION(cxx_override_control, LangOpts.CPlusPlus)

clang/include/clang/StaticAnalyzer/Core/PathSensitive/ProgramState.h

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,8 @@ class ProgramState : public llvm::FoldingSetNode {
494494
InvalidatedSymbols *IS,
495495
RegionAndSymbolInvalidationTraits *HTraits,
496496
const CallEvent *Call) const;
497+
498+
SVal wrapSymbolicRegion(SVal Base) const;
497499
};
498500

499501
//===----------------------------------------------------------------------===//
@@ -782,20 +784,6 @@ inline SVal ProgramState::getLValue(const ObjCIvarDecl *D, SVal Base) const {
782784
return getStateManager().StoreMgr->getLValueIvar(D, Base);
783785
}
784786

785-
inline SVal ProgramState::getLValue(const FieldDecl *D, SVal Base) const {
786-
return getStateManager().StoreMgr->getLValueField(D, Base);
787-
}
788-
789-
inline SVal ProgramState::getLValue(const IndirectFieldDecl *D,
790-
SVal Base) const {
791-
StoreManager &SM = *getStateManager().StoreMgr;
792-
for (const auto *I : D->chain()) {
793-
Base = SM.getLValueField(cast<FieldDecl>(I), Base);
794-
}
795-
796-
return Base;
797-
}
798-
799787
inline SVal ProgramState::getLValue(QualType ElementType, SVal Idx, SVal Base) const{
800788
if (std::optional<NonLoc> N = Idx.getAs<NonLoc>())
801789
return getStateManager().StoreMgr->getLValueElement(ElementType, *N, Base);

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3128,36 +3128,66 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
31283128
case Builtin::BI__builtin_ctzs:
31293129
case Builtin::BI__builtin_ctz:
31303130
case Builtin::BI__builtin_ctzl:
3131-
case Builtin::BI__builtin_ctzll: {
3132-
Value *ArgValue = EmitCheckedArgForBuiltin(E->getArg(0), BCK_CTZPassedZero);
3131+
case Builtin::BI__builtin_ctzll:
3132+
case Builtin::BI__builtin_ctzg: {
3133+
bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_ctzg &&
3134+
E->getNumArgs() > 1;
3135+
3136+
Value *ArgValue =
3137+
HasFallback ? EmitScalarExpr(E->getArg(0))
3138+
: EmitCheckedArgForBuiltin(E->getArg(0), BCK_CTZPassedZero);
31333139

31343140
llvm::Type *ArgType = ArgValue->getType();
31353141
Function *F = CGM.getIntrinsic(Intrinsic::cttz, ArgType);
31363142

31373143
llvm::Type *ResultType = ConvertType(E->getType());
3138-
Value *ZeroUndef = Builder.getInt1(getTarget().isCLZForZeroUndef());
3144+
Value *ZeroUndef =
3145+
Builder.getInt1(HasFallback || getTarget().isCLZForZeroUndef());
31393146
Value *Result = Builder.CreateCall(F, {ArgValue, ZeroUndef});
31403147
if (Result->getType() != ResultType)
31413148
Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
31423149
"cast");
3143-
return RValue::get(Result);
3150+
if (!HasFallback)
3151+
return RValue::get(Result);
3152+
3153+
Value *Zero = Constant::getNullValue(ArgType);
3154+
Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero");
3155+
Value *FallbackValue = EmitScalarExpr(E->getArg(1));
3156+
Value *ResultOrFallback =
3157+
Builder.CreateSelect(IsZero, FallbackValue, Result, "ctzg");
3158+
return RValue::get(ResultOrFallback);
31443159
}
31453160
case Builtin::BI__builtin_clzs:
31463161
case Builtin::BI__builtin_clz:
31473162
case Builtin::BI__builtin_clzl:
3148-
case Builtin::BI__builtin_clzll: {
3149-
Value *ArgValue = EmitCheckedArgForBuiltin(E->getArg(0), BCK_CLZPassedZero);
3163+
case Builtin::BI__builtin_clzll:
3164+
case Builtin::BI__builtin_clzg: {
3165+
bool HasFallback = BuiltinIDIfNoAsmLabel == Builtin::BI__builtin_clzg &&
3166+
E->getNumArgs() > 1;
3167+
3168+
Value *ArgValue =
3169+
HasFallback ? EmitScalarExpr(E->getArg(0))
3170+
: EmitCheckedArgForBuiltin(E->getArg(0), BCK_CLZPassedZero);
31503171

31513172
llvm::Type *ArgType = ArgValue->getType();
31523173
Function *F = CGM.getIntrinsic(Intrinsic::ctlz, ArgType);
31533174

31543175
llvm::Type *ResultType = ConvertType(E->getType());
3155-
Value *ZeroUndef = Builder.getInt1(getTarget().isCLZForZeroUndef());
3176+
Value *ZeroUndef =
3177+
Builder.getInt1(HasFallback || getTarget().isCLZForZeroUndef());
31563178
Value *Result = Builder.CreateCall(F, {ArgValue, ZeroUndef});
31573179
if (Result->getType() != ResultType)
31583180
Result = Builder.CreateIntCast(Result, ResultType, /*isSigned*/true,
31593181
"cast");
3160-
return RValue::get(Result);
3182+
if (!HasFallback)
3183+
return RValue::get(Result);
3184+
3185+
Value *Zero = Constant::getNullValue(ArgType);
3186+
Value *IsZero = Builder.CreateICmpEQ(ArgValue, Zero, "iszero");
3187+
Value *FallbackValue = EmitScalarExpr(E->getArg(1));
3188+
Value *ResultOrFallback =
3189+
Builder.CreateSelect(IsZero, FallbackValue, Result, "clzg");
3190+
return RValue::get(ResultOrFallback);
31613191
}
31623192
case Builtin::BI__builtin_ffs:
31633193
case Builtin::BI__builtin_ffsl:

clang/lib/Driver/Driver.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -6626,28 +6626,35 @@ std::string Driver::GetStdModuleManifestPath(const Compilation &C,
66266626

66276627
switch (TC.GetCXXStdlibType(C.getArgs())) {
66286628
case ToolChain::CST_Libcxx: {
6629-
std::string lib = GetFilePath("libc++.so", TC);
6630-
6631-
// Note when there are multiple flavours of libc++ the module json needs to
6632-
// look at the command-line arguments for the proper json.
6633-
// These flavours do not exist at the moment, but there are plans to
6634-
// provide a variant that is built with sanitizer instrumentation enabled.
6635-
6636-
// For example
6637-
// StringRef modules = [&] {
6638-
// const SanitizerArgs &Sanitize = TC.getSanitizerArgs(C.getArgs());
6639-
// if (Sanitize.needsAsanRt())
6640-
// return "modules-asan.json";
6641-
// return "modules.json";
6642-
// }();
6643-
6644-
SmallString<128> path(lib.begin(), lib.end());
6645-
llvm::sys::path::remove_filename(path);
6646-
llvm::sys::path::append(path, "modules.json");
6647-
if (TC.getVFS().exists(path))
6648-
return static_cast<std::string>(path);
6629+
auto evaluate = [&](const char *library) -> std::optional<std::string> {
6630+
std::string lib = GetFilePath(library, TC);
6631+
6632+
// Note when there are multiple flavours of libc++ the module json needs
6633+
// to look at the command-line arguments for the proper json. These
6634+
// flavours do not exist at the moment, but there are plans to provide a
6635+
// variant that is built with sanitizer instrumentation enabled.
6636+
6637+
// For example
6638+
// StringRef modules = [&] {
6639+
// const SanitizerArgs &Sanitize = TC.getSanitizerArgs(C.getArgs());
6640+
// if (Sanitize.needsAsanRt())
6641+
// return "libc++.modules-asan.json";
6642+
// return "libc++.modules.json";
6643+
// }();
6644+
6645+
SmallString<128> path(lib.begin(), lib.end());
6646+
llvm::sys::path::remove_filename(path);
6647+
llvm::sys::path::append(path, "libc++.modules.json");
6648+
if (TC.getVFS().exists(path))
6649+
return static_cast<std::string>(path);
6650+
6651+
return {};
6652+
};
66496653

6650-
return error;
6654+
if (std::optional<std::string> result = evaluate("libc++.so"); result)
6655+
return *result;
6656+
6657+
return evaluate("libc++.a").value_or(error);
66516658
}
66526659

66536660
case ToolChain::CST_Libstdcxx:

0 commit comments

Comments
 (0)