Skip to content

Commit 2b2c236

Browse files
committed
Merge branch 'main' of https://github.com/llvm/llvm-project into private_is_an_evil_default
2 parents a742e92 + 467a9bd commit 2b2c236

File tree

244 files changed

+7465
-3250
lines changed

Some content is hidden

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

244 files changed

+7465
-3250
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,8 @@ Android Support
605605
Windows Support
606606
^^^^^^^^^^^^^^^
607607

608+
- clang-cl now supports ``/std:c++23preview`` which enables C++23 features.
609+
608610
- Clang no longer allows references inside a union when emulating MSVC 1900+ even if `fms-extensions` is enabled.
609611
Starting with VS2015, MSVC 1900, this Microsoft extension is no longer allowed and always results in an error.
610612
Clang now follows the MSVC behavior in this scenario.

clang/docs/analyzer/checkers.rst

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3371,12 +3371,23 @@ Checks for overlap in two buffer arguments. Applies to: ``memcpy, mempcpy, wmem
33713371
33723372
alpha.unix.cstring.NotNullTerminated (C)
33733373
""""""""""""""""""""""""""""""""""""""""
3374-
Check for arguments which are not null-terminated strings; applies to: ``strlen, strnlen, strcpy, strncpy, strcat, strncat, wcslen, wcsnlen``.
3374+
Check for arguments which are not null-terminated strings;
3375+
applies to the ``strlen``, ``strcpy``, ``strcat``, ``strcmp`` family of functions.
3376+
3377+
Only very fundamental cases are detected where the passed memory block is
3378+
absolutely different from a null-terminated string. This checker does not
3379+
find if a memory buffer is passed where the terminating zero character
3380+
is missing.
33753381
33763382
.. code-block:: c
33773383
3378-
void test() {
3379-
int y = strlen((char *)&test); // warn
3384+
void test1() {
3385+
int l = strlen((char *)&test); // warn
3386+
}
3387+
3388+
void test2() {
3389+
label:
3390+
int l = strlen((char *)&&label); // warn
33803391
}
33813392
33823393
.. _alpha-unix-cstring-OutOfBounds:

clang/include/clang/Basic/Builtins.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4761,6 +4761,12 @@ def HLSLWaveIsFirstLane : LangBuiltin<"HLSL_LANG"> {
47614761
let Prototype = "bool()";
47624762
}
47634763

4764+
def HLSLWaveReadLaneAt : LangBuiltin<"HLSL_LANG"> {
4765+
let Spellings = ["__builtin_hlsl_wave_read_lane_at"];
4766+
let Attributes = [NoThrow, Const];
4767+
let Prototype = "void(...)";
4768+
}
4769+
47644770
def HLSLClamp : LangBuiltin<"HLSL_LANG"> {
47654771
let Spellings = ["__builtin_hlsl_elementwise_clamp"];
47664772
let Attributes = [NoThrow, Const];

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9230,6 +9230,8 @@ def err_typecheck_cond_incompatible_operands : Error<
92309230
def err_typecheck_expect_scalar_or_vector : Error<
92319231
"invalid operand of type %0 where %1 or "
92329232
"a vector of such type is required">;
9233+
def err_typecheck_expect_any_scalar_or_vector : Error<
9234+
"invalid operand of type %0 where a scalar or vector is required">;
92339235
def err_typecheck_expect_flt_or_vector : Error<
92349236
"invalid operand of type %0 where floating, complex or "
92359237
"a vector of such types is required">;

clang/include/clang/Driver/Options.td

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5384,9 +5384,14 @@ def mlasx : Flag<["-"], "mlasx">, Group<m_loongarch_Features_Group>,
53845384
HelpText<"Enable Loongson Advanced SIMD Extension (LASX).">;
53855385
def mno_lasx : Flag<["-"], "mno-lasx">, Group<m_loongarch_Features_Group>,
53865386
HelpText<"Disable Loongson Advanced SIMD Extension (LASX).">;
5387+
let Flags = [TargetSpecific] in {
53875388
def msimd_EQ : Joined<["-"], "msimd=">, Group<m_loongarch_Features_Group>,
5388-
Flags<[TargetSpecific]>,
53895389
HelpText<"Select the SIMD extension(s) to be enabled in LoongArch either 'none', 'lsx', 'lasx'.">;
5390+
def mannotate_tablejump : Flag<["-"], "mannotate-tablejump">, Group<m_loongarch_Features_Group>,
5391+
HelpText<"Enable annotate table jump instruction to correlate it with the jump table.">;
5392+
def mno_annotate_tablejump : Flag<["-"], "mno-annotate-tablejump">, Group<m_loongarch_Features_Group>,
5393+
HelpText<"Disable annotate table jump instruction to correlate it with the jump table.">;
5394+
} // let Flags = [TargetSpecific]
53905395
def mnop_mcount : Flag<["-"], "mnop-mcount">, HelpText<"Generate mcount/__fentry__ calls as nops. To activate they need to be patched in.">,
53915396
Visibility<[ClangOption, CC1Option]>, Group<m_Group>,
53925397
MarshallingInfoFlag<CodeGenOpts<"MNopMCount">>;
@@ -8526,7 +8531,7 @@ def _SLASH_execution_charset : CLCompileJoined<"execution-charset:">,
85268531
HelpText<"Set runtime encoding, supports only UTF-8">,
85278532
Alias<fexec_charset_EQ>;
85288533
def _SLASH_std : CLCompileJoined<"std:">,
8529-
HelpText<"Set language version (c++14,c++17,c++20,c++latest,c11,c17)">;
8534+
HelpText<"Set language version (c++14,c++17,c++20,c++23preview,c++latest,c11,c17)">;
85308535
def _SLASH_U : CLJoinedOrSeparate<"U">, HelpText<"Undefine macro">,
85318536
MetaVarName<"<macro>">, Alias<U>;
85328537
def _SLASH_validate_charset : CLFlag<"validate-charset">,

clang/include/clang/ExtractAPI/API.h

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "llvm/ADT/SmallVector.h"
2727
#include "llvm/Support/Allocator.h"
2828
#include "llvm/Support/Casting.h"
29+
#include "llvm/Support/Compiler.h"
2930
#include "llvm/TargetParser/Triple.h"
3031
#include <cstddef>
3132
#include <iterator>
@@ -615,7 +616,24 @@ struct TagRecord : APIRecord, RecordContext {
615616
return classofKind(Record->getKind());
616617
}
617618
static bool classofKind(RecordKind K) {
618-
return K == RK_Struct || K == RK_Union || K == RK_Enum;
619+
switch (K) {
620+
case RK_Enum:
621+
LLVM_FALLTHROUGH;
622+
case RK_Struct:
623+
LLVM_FALLTHROUGH;
624+
case RK_Union:
625+
LLVM_FALLTHROUGH;
626+
case RK_CXXClass:
627+
LLVM_FALLTHROUGH;
628+
case RK_ClassTemplate:
629+
LLVM_FALLTHROUGH;
630+
case RK_ClassTemplateSpecialization:
631+
LLVM_FALLTHROUGH;
632+
case RK_ClassTemplatePartialSpecialization:
633+
return true;
634+
default:
635+
return false;
636+
}
619637
}
620638

621639
bool IsEmbeddedInVarDeclarator;
@@ -684,7 +702,22 @@ struct RecordRecord : TagRecord {
684702
return classofKind(Record->getKind());
685703
}
686704
static bool classofKind(RecordKind K) {
687-
return K == RK_Struct || K == RK_Union;
705+
switch (K) {
706+
case RK_Struct:
707+
LLVM_FALLTHROUGH;
708+
case RK_Union:
709+
LLVM_FALLTHROUGH;
710+
case RK_CXXClass:
711+
LLVM_FALLTHROUGH;
712+
case RK_ClassTemplate:
713+
LLVM_FALLTHROUGH;
714+
case RK_ClassTemplateSpecialization:
715+
LLVM_FALLTHROUGH;
716+
case RK_ClassTemplatePartialSpecialization:
717+
return true;
718+
default:
719+
return false;
720+
}
688721
}
689722

690723
bool isAnonymousWithNoTypedef() { return Name.empty(); }

clang/lib/AST/ExprConstant.cpp

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7237,6 +7237,7 @@ class APValueToBufferConverter {
72377237

72387238
case APValue::ComplexInt:
72397239
case APValue::ComplexFloat:
7240+
return visitComplex(Val, Ty, Offset);
72407241
case APValue::FixedPoint:
72417242
// FIXME: We should support these.
72427243

@@ -7323,6 +7324,31 @@ class APValueToBufferConverter {
73237324
return true;
73247325
}
73257326

7327+
bool visitComplex(const APValue &Val, QualType Ty, CharUnits Offset) {
7328+
const ComplexType *ComplexTy = Ty->castAs<ComplexType>();
7329+
QualType EltTy = ComplexTy->getElementType();
7330+
CharUnits EltSizeChars = Info.Ctx.getTypeSizeInChars(EltTy);
7331+
bool IsInt = Val.isComplexInt();
7332+
7333+
if (IsInt) {
7334+
if (!visitInt(Val.getComplexIntReal(), EltTy,
7335+
Offset + (0 * EltSizeChars)))
7336+
return false;
7337+
if (!visitInt(Val.getComplexIntImag(), EltTy,
7338+
Offset + (1 * EltSizeChars)))
7339+
return false;
7340+
} else {
7341+
if (!visitFloat(Val.getComplexFloatReal(), EltTy,
7342+
Offset + (0 * EltSizeChars)))
7343+
return false;
7344+
if (!visitFloat(Val.getComplexFloatImag(), EltTy,
7345+
Offset + (1 * EltSizeChars)))
7346+
return false;
7347+
}
7348+
7349+
return true;
7350+
}
7351+
73267352
bool visitVector(const APValue &Val, QualType Ty, CharUnits Offset) {
73277353
const VectorType *VTy = Ty->castAs<VectorType>();
73287354
QualType EltTy = VTy->getElementType();
@@ -7595,6 +7621,23 @@ class BufferToAPValueConverter {
75957621
return ArrayValue;
75967622
}
75977623

7624+
std::optional<APValue> visit(const ComplexType *Ty, CharUnits Offset) {
7625+
QualType ElementType = Ty->getElementType();
7626+
CharUnits ElementWidth = Info.Ctx.getTypeSizeInChars(ElementType);
7627+
bool IsInt = ElementType->isIntegerType();
7628+
7629+
std::optional<APValue> Values[2];
7630+
for (unsigned I = 0; I != 2; ++I) {
7631+
Values[I] = visitType(Ty->getElementType(), Offset + I * ElementWidth);
7632+
if (!Values[I])
7633+
return std::nullopt;
7634+
}
7635+
7636+
if (IsInt)
7637+
return APValue(Values[0]->getInt(), Values[1]->getInt());
7638+
return APValue(Values[0]->getFloat(), Values[1]->getFloat());
7639+
}
7640+
75987641
std::optional<APValue> visit(const VectorType *VTy, CharUnits Offset) {
75997642
QualType EltTy = VTy->getElementType();
76007643
unsigned NElts = VTy->getNumElements();

clang/lib/Basic/Targets/OSTargets.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -214,9 +214,11 @@ static void addVisualCDefines(const LangOptions &Opts, MacroBuilder &Builder) {
214214
Builder.defineMacro("_HAS_CHAR16_T_LANGUAGE_SUPPORT", Twine(1));
215215

216216
if (Opts.isCompatibleWithMSVC(LangOptions::MSVC2015)) {
217-
if (Opts.CPlusPlus23)
217+
if (Opts.CPlusPlus26)
218218
// TODO update to the proper value.
219-
Builder.defineMacro("_MSVC_LANG", "202004L");
219+
Builder.defineMacro("_MSVC_LANG", "202400L");
220+
else if (Opts.CPlusPlus23)
221+
Builder.defineMacro("_MSVC_LANG", "202302L");
220222
else if (Opts.CPlusPlus20)
221223
Builder.defineMacro("_MSVC_LANG", "202002L");
222224
else if (Opts.CPlusPlus17)

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18906,6 +18906,24 @@ case Builtin::BI__builtin_hlsl_elementwise_isinf: {
1890618906
return EmitRuntimeCall(
1890718907
Intrinsic::getOrInsertDeclaration(&CGM.getModule(), ID));
1890818908
}
18909+
case Builtin::BI__builtin_hlsl_wave_read_lane_at: {
18910+
// Due to the use of variadic arguments we must explicitly retreive them and
18911+
// create our function type.
18912+
Value *OpExpr = EmitScalarExpr(E->getArg(0));
18913+
Value *OpIndex = EmitScalarExpr(E->getArg(1));
18914+
llvm::FunctionType *FT = llvm::FunctionType::get(
18915+
OpExpr->getType(), ArrayRef{OpExpr->getType(), OpIndex->getType()},
18916+
false);
18917+
18918+
// Get overloaded name
18919+
std::string Name =
18920+
Intrinsic::getName(CGM.getHLSLRuntime().getWaveReadLaneAtIntrinsic(),
18921+
ArrayRef{OpExpr->getType()}, &CGM.getModule());
18922+
return EmitRuntimeCall(CGM.CreateRuntimeFunction(FT, Name, {},
18923+
/*Local=*/false,
18924+
/*AssumeConvergent=*/true),
18925+
ArrayRef{OpExpr, OpIndex}, "hlsl.wave.readlane");
18926+
}
1890918927
case Builtin::BI__builtin_hlsl_elementwise_sign: {
1891018928
auto *Arg0 = E->getArg(0);
1891118929
Value *Op0 = EmitScalarExpr(Arg0);

clang/lib/CodeGen/CGHLSLRuntime.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ class CGHLSLRuntime {
9090
GENERATE_HLSL_INTRINSIC_FUNCTION(SDot, sdot)
9191
GENERATE_HLSL_INTRINSIC_FUNCTION(UDot, udot)
9292
GENERATE_HLSL_INTRINSIC_FUNCTION(WaveIsFirstLane, wave_is_first_lane)
93+
GENERATE_HLSL_INTRINSIC_FUNCTION(WaveReadLaneAt, wave_readlane)
9394

9495
//===----------------------------------------------------------------------===//
9596
// End of reserved area for HLSL intrinsic getters.

0 commit comments

Comments
 (0)