Skip to content

Commit 1434e11

Browse files
committed
[𝘀𝗽𝗿] changes introduced through rebase
Created using spr 1.3.4 [skip ci]
2 parents 49341e9 + 8c917f3 commit 1434e11

File tree

162 files changed

+5461
-3573
lines changed

Some content is hidden

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

162 files changed

+5461
-3573
lines changed

clang-tools-extra/docs/clang-tidy/checks/bugprone/implicit-widening-of-multiplication-result.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,20 +37,20 @@ Options
3737
.. option:: UseCXXStaticCastsInCppSources
3838

3939
When suggesting fix-its for C++ code, should C++-style ``static_cast<>()``'s
40-
be suggested, or C-style casts. Defaults to ``true``.
40+
be suggested, or C-style casts. Defaults to `true`.
4141

4242
.. option:: UseCXXHeadersInCppSources
4343

4444
When suggesting to include the appropriate header in C++ code,
4545
should ``<cstddef>`` header be suggested, or ``<stddef.h>``.
46-
Defaults to ``true``.
46+
Defaults to `true`.
4747

4848
.. option:: IgnoreConstantIntExpr
4949

5050
If the multiplication operands are compile-time constants (like literals or
5151
are ``constexpr``) and fit within the source expression type, do not emit a
5252
diagnostic or suggested fix. Only considers expressions where the source
53-
expression is a signed integer type. Defaults to ``false``.
53+
expression is a signed integer type. Defaults to `false`.
5454

5555
Examples:
5656

clang-tools-extra/docs/clang-tidy/checks/cert/err33-c.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ This check is an alias of check :doc:`bugprone-unused-return-value <../bugprone/
190190
with a fixed set of functions.
191191

192192
Suppressing issues by casting to ``void`` is enabled by default and can be
193-
disabled by setting `AllowCastToVoid` option to ``false``.
193+
disabled by setting `AllowCastToVoid` option to `false`.
194194

195195
The check corresponds to a part of CERT C Coding Standard rule `ERR33-C.
196196
Detect and handle standard library errors

clang-tools-extra/docs/clang-tidy/checks/modernize/loop-convert.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ lives.
144144

145145
When set to true convert loops when in C++20 or later mode using
146146
``std::ranges::reverse_view``.
147-
Default value is ``true``.
147+
Default value is `true`.
148148

149149
.. option:: MakeReverseRangeFunction
150150

clang/docs/ClangFormatStyleOptions.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4786,17 +4786,20 @@ the configuration (without a prefix: ``Auto``).
47864786

47874787
.. note::
47884788

4789-
You can also specify the language (``Cpp`` or ``ObjC``) for ``.h`` files
4790-
by adding a ``// clang-format Language:`` line before the first
4789+
You can specify the language (``C``, ``Cpp``, or ``ObjC``) for ``.h``
4790+
files by adding a ``// clang-format Language:`` line before the first
47914791
non-comment (and non-empty) line, e.g. ``// clang-format Language: Cpp``.
47924792

47934793
Possible values:
47944794

47954795
* ``LK_None`` (in configuration: ``None``)
47964796
Do not use.
47974797

4798+
* ``LK_C`` (in configuration: ``C``)
4799+
Should be used for C.
4800+
47984801
* ``LK_Cpp`` (in configuration: ``Cpp``)
4799-
Should be used for C, C++.
4802+
Should be used for C++.
48004803

48014804
* ``LK_CSharp`` (in configuration: ``CSharp``)
48024805
Should be used for C#.

clang/docs/ReleaseNotes.rst

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -271,9 +271,10 @@ clang-format
271271
- Adds ``BreakBeforeTemplateCloser`` option.
272272
- Adds ``BinPackLongBracedList`` option to override bin packing options in
273273
long (20 item or more) braced list initializer lists.
274-
- Allow specifying the language (C++ or Objective-C) for a ``.h`` file by adding
275-
a special comment (e.g. ``// clang-format Language: ObjC``) near the top of
276-
the file.
274+
- Add the C language instead of treating it like C++.
275+
- Allow specifying the language (C, C++, or Objective-C) for a ``.h`` file by
276+
adding a special comment (e.g. ``// clang-format Language: ObjC``) near the
277+
top of the file.
277278

278279
libclang
279280
--------

clang/include/clang/Basic/BuiltinsSPIRV.td

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,9 +19,3 @@ def SPIRVLength : Builtin {
1919
let Attributes = [NoThrow, Const];
2020
let Prototype = "void(...)";
2121
}
22-
23-
def SPIRVReflect : Builtin {
24-
let Spellings = ["__builtin_spirv_reflect"];
25-
let Attributes = [NoThrow, Const];
26-
let Prototype = "void(...)";
27-
}

clang/include/clang/Format/Format.h

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3318,7 +3318,9 @@ struct FormatStyle {
33183318
enum LanguageKind : int8_t {
33193319
/// Do not use.
33203320
LK_None,
3321-
/// Should be used for C, C++.
3321+
/// Should be used for C.
3322+
LK_C,
3323+
/// Should be used for C++.
33223324
LK_Cpp,
33233325
/// Should be used for C#.
33243326
LK_CSharp,
@@ -3343,7 +3345,9 @@ struct FormatStyle {
33433345
/// https://sci-hub.st/10.1109/IEEESTD.2018.8299595
33443346
LK_Verilog
33453347
};
3346-
bool isCpp() const { return Language == LK_Cpp || Language == LK_ObjC; }
3348+
bool isCpp() const {
3349+
return Language == LK_Cpp || Language == LK_C || Language == LK_ObjC;
3350+
}
33473351
bool isCSharp() const { return Language == LK_CSharp; }
33483352
bool isJson() const { return Language == LK_Json; }
33493353
bool isJavaScript() const { return Language == LK_JavaScript; }
@@ -3355,8 +3359,8 @@ struct FormatStyle {
33553359

33563360
/// The language that this format style targets.
33573361
/// \note
3358-
/// You can also specify the language (``Cpp`` or ``ObjC``) for ``.h`` files
3359-
/// by adding a ``// clang-format Language:`` line before the first
3362+
/// You can specify the language (``C``, ``Cpp``, or ``ObjC``) for ``.h``
3363+
/// files by adding a ``// clang-format Language:`` line before the first
33603364
/// non-comment (and non-empty) line, e.g. ``// clang-format Language: Cpp``.
33613365
/// \endnote
33623366
/// \version 3.5
@@ -5715,6 +5719,8 @@ FormatStyle::LanguageKind guessLanguage(StringRef FileName, StringRef Code);
57155719
// Returns a string representation of ``Language``.
57165720
inline StringRef getLanguageName(FormatStyle::LanguageKind Language) {
57175721
switch (Language) {
5722+
case FormatStyle::LK_C:
5723+
return "C";
57185724
case FormatStyle::LK_Cpp:
57195725
return "C++";
57205726
case FormatStyle::LK_CSharp:

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1015,11 +1015,14 @@ static bool RunDestructors(InterpState &S, CodePtr OpPC, const Block *B) {
10151015
assert(Desc->isRecord() || Desc->isCompositeArray());
10161016

10171017
if (Desc->isCompositeArray()) {
1018+
unsigned N = Desc->getNumElems();
1019+
if (N == 0)
1020+
return true;
10181021
const Descriptor *ElemDesc = Desc->ElemDesc;
10191022
assert(ElemDesc->isRecord());
10201023

10211024
Pointer RP(const_cast<Block *>(B));
1022-
for (unsigned I = 0; I != Desc->getNumElems(); ++I) {
1025+
for (int I = static_cast<int>(N) - 1; I >= 0; --I) {
10231026
if (!runRecordDestructor(S, OpPC, RP.atIndex(I).narrow(), ElemDesc))
10241027
return false;
10251028
}
@@ -1379,6 +1382,18 @@ bool CallVirt(InterpState &S, CodePtr OpPC, const Function *Func,
13791382
size_t ArgSize = Func->getArgSize() + VarArgSize;
13801383
size_t ThisOffset = ArgSize - (Func->hasRVO() ? primSize(PT_Ptr) : 0);
13811384
Pointer &ThisPtr = S.Stk.peek<Pointer>(ThisOffset);
1385+
const FunctionDecl *Callee = Func->getDecl();
1386+
1387+
// C++2a [class.abstract]p6:
1388+
// the effect of making a virtual call to a pure virtual function [...] is
1389+
// undefined
1390+
if (Callee->isPureVirtual()) {
1391+
S.FFDiag(S.Current->getSource(OpPC), diag::note_constexpr_pure_virtual_call,
1392+
1)
1393+
<< Callee;
1394+
S.Note(Callee->getLocation(), diag::note_declared_at);
1395+
return false;
1396+
}
13821397

13831398
const CXXRecordDecl *DynamicDecl = nullptr;
13841399
{
@@ -1395,7 +1410,7 @@ bool CallVirt(InterpState &S, CodePtr OpPC, const Function *Func,
13951410
assert(DynamicDecl);
13961411

13971412
const auto *StaticDecl = cast<CXXRecordDecl>(Func->getParentDecl());
1398-
const auto *InitialFunction = cast<CXXMethodDecl>(Func->getDecl());
1413+
const auto *InitialFunction = cast<CXXMethodDecl>(Callee);
13991414
const CXXMethodDecl *Overrider = S.getContext().getOverridingFunction(
14001415
DynamicDecl, StaticDecl, InitialFunction);
14011416

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -20829,19 +20829,6 @@ Value *CodeGenFunction::EmitSPIRVBuiltinExpr(unsigned BuiltinID,
2082920829
/*ReturnType=*/X->getType()->getScalarType(), Intrinsic::spv_length,
2083020830
ArrayRef<Value *>{X}, nullptr, "spv.length");
2083120831
}
20832-
case SPIRV::BI__builtin_spirv_reflect: {
20833-
Value *I = EmitScalarExpr(E->getArg(0));
20834-
Value *N = EmitScalarExpr(E->getArg(1));
20835-
assert(E->getArg(0)->getType()->hasFloatingRepresentation() &&
20836-
E->getArg(1)->getType()->hasFloatingRepresentation() &&
20837-
"Reflect operands must have a float representation");
20838-
assert(E->getArg(0)->getType()->isVectorType() &&
20839-
E->getArg(1)->getType()->isVectorType() &&
20840-
"Reflect operands must be a vector");
20841-
return Builder.CreateIntrinsic(
20842-
/*ReturnType=*/I->getType(), Intrinsic::spv_reflect,
20843-
ArrayRef<Value *>{I, N}, nullptr, "spv.reflect");
20844-
}
2084520832
}
2084620833
return nullptr;
2084720834
}

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -862,13 +862,15 @@ void tools::addLTOOptions(const ToolChain &ToolChain, const ArgList &Args,
862862
const llvm::Triple &Triple = ToolChain.getTriple();
863863
const bool IsOSAIX = Triple.isOSAIX();
864864
const bool IsAMDGCN = Triple.isAMDGCN();
865-
const char *Linker = Args.MakeArgString(ToolChain.GetLinkerPath());
865+
StringRef Linker = Args.getLastArgValue(options::OPT_fuse_ld_EQ);
866+
const char *LinkerPath = Args.MakeArgString(ToolChain.GetLinkerPath());
866867
const Driver &D = ToolChain.getDriver();
867868
const bool IsFatLTO = Args.hasFlag(options::OPT_ffat_lto_objects,
868869
options::OPT_fno_fat_lto_objects, false);
869870
const bool IsUnifiedLTO = Args.hasArg(options::OPT_funified_lto);
870-
if (llvm::sys::path::filename(Linker) != "ld.lld" &&
871-
llvm::sys::path::stem(Linker) != "ld.lld" && !Triple.isOSOpenBSD()) {
871+
if (Linker != "lld" && Linker != "lld-link" &&
872+
llvm::sys::path::filename(LinkerPath) != "ld.lld" &&
873+
llvm::sys::path::stem(LinkerPath) != "ld.lld" && !Triple.isOSOpenBSD()) {
872874
// Tell the linker to load the plugin. This has to come before
873875
// AddLinkerInputs as gold requires -plugin and AIX ld requires -bplugin to
874876
// come before any -plugin-opt/-bplugin_opt that -Wl might forward.

clang/lib/Driver/ToolChains/Linux.cpp

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -343,14 +343,7 @@ Linux::Linux(const Driver &D, const llvm::Triple &Triple, const ArgList &Args)
343343
}
344344

345345
addPathIfExists(D, concat(SysRoot, "/usr/lib", MultiarchTriple), Paths);
346-
// 64-bit OpenEmbedded sysroots may not have a /usr/lib dir. So they cannot
347-
// find /usr/lib64 as it is referenced as /usr/lib/../lib64. So we handle
348-
// this here.
349-
if (Triple.getVendor() == llvm::Triple::OpenEmbedded &&
350-
Triple.isArch64Bit())
351-
addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
352-
else
353-
addPathIfExists(D, concat(SysRoot, "/usr/lib/..", OSLibDir), Paths);
346+
addPathIfExists(D, concat(SysRoot, "/usr", OSLibDir), Paths);
354347
if (IsRISCV) {
355348
StringRef ABIName = tools::riscv::getRISCVABI(Args, Triple);
356349
addPathIfExists(D, concat(SysRoot, "/", OSLibDir, ABIName), Paths);

clang/lib/Format/Format.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ template <> struct MappingTraits<FormatStyle::KeepEmptyLinesStyle> {
401401

402402
template <> struct ScalarEnumerationTraits<FormatStyle::LanguageKind> {
403403
static void enumeration(IO &IO, FormatStyle::LanguageKind &Value) {
404+
IO.enumCase(Value, "C", FormatStyle::LK_C);
404405
IO.enumCase(Value, "Cpp", FormatStyle::LK_Cpp);
405406
IO.enumCase(Value, "Java", FormatStyle::LK_Java);
406407
IO.enumCase(Value, "JavaScript", FormatStyle::LK_JavaScript);
@@ -3957,7 +3958,12 @@ LangOptions getFormattingLangOpts(const FormatStyle &Style) {
39573958
LangOpts.Digraphs = LexingStd >= FormatStyle::LS_Cpp11;
39583959

39593960
LangOpts.LineComment = 1;
3960-
LangOpts.CXXOperatorNames = Style.isCpp();
3961+
3962+
const auto Language = Style.Language;
3963+
LangOpts.C17 = Language == FormatStyle::LK_C;
3964+
LangOpts.CXXOperatorNames =
3965+
Language == FormatStyle::LK_Cpp || Language == FormatStyle::LK_ObjC;
3966+
39613967
LangOpts.Bool = 1;
39623968
LangOpts.ObjC = 1;
39633969
LangOpts.MicrosoftExt = 1; // To get kw___try, kw___finally.
@@ -3982,6 +3988,8 @@ const char *StyleOptionHelpDescription =
39823988
" --style=\"{BasedOnStyle: llvm, IndentWidth: 8}\"";
39833989

39843990
static FormatStyle::LanguageKind getLanguageByFileName(StringRef FileName) {
3991+
if (FileName.ends_with(".c"))
3992+
return FormatStyle::LK_C;
39853993
if (FileName.ends_with(".java"))
39863994
return FormatStyle::LK_Java;
39873995
if (FileName.ends_with_insensitive(".js") ||
@@ -4039,6 +4047,8 @@ static FormatStyle::LanguageKind getLanguageByComment(const Environment &Env) {
40394047
continue;
40404048

40414049
Text = Text.trim();
4050+
if (Text == "C")
4051+
return FormatStyle::LK_C;
40424052
if (Text == "Cpp")
40434053
return FormatStyle::LK_Cpp;
40444054
if (Text == "ObjC")

clang/lib/Format/FormatToken.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ static SmallVector<StringRef> CppNonKeywordTypes = {
4444
bool FormatToken::isTypeName(const LangOptions &LangOpts) const {
4545
if (is(TT_TypeName) || Tok.isSimpleTypeSpecifier(LangOpts))
4646
return true;
47-
const bool IsCpp = LangOpts.CXXOperatorNames;
48-
return IsCpp && is(tok::identifier) &&
47+
return (LangOpts.CXXOperatorNames || LangOpts.C17) && is(tok::identifier) &&
4948
std::binary_search(CppNonKeywordTypes.begin(),
5049
CppNonKeywordTypes.end(), TokenText);
5150
}

clang/lib/Format/TokenAnnotator.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ class AnnotatingParser {
129129
: Style(Style), Line(Line), CurrentToken(Line.First), AutoFound(false),
130130
IsCpp(Style.isCpp()), LangOpts(getFormattingLangOpts(Style)),
131131
Keywords(Keywords), Scopes(Scopes), TemplateDeclarationDepth(0) {
132-
assert(IsCpp == LangOpts.CXXOperatorNames);
132+
assert(IsCpp == (LangOpts.CXXOperatorNames || LangOpts.C17));
133133
Contexts.push_back(Context(tok::unknown, 1, /*IsExpression=*/false));
134134
resetTokenMetadata();
135135
}
@@ -3821,7 +3821,7 @@ static bool isFunctionDeclarationName(const LangOptions &LangOpts,
38213821
};
38223822

38233823
const auto *Next = Current.Next;
3824-
const bool IsCpp = LangOpts.CXXOperatorNames;
3824+
const bool IsCpp = LangOpts.CXXOperatorNames || LangOpts.C17;
38253825

38263826
// Find parentheses of parameter list.
38273827
if (Current.is(tok::kw_operator)) {

clang/lib/Format/TokenAnnotator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ class TokenAnnotator {
225225
TokenAnnotator(const FormatStyle &Style, const AdditionalKeywords &Keywords)
226226
: Style(Style), IsCpp(Style.isCpp()),
227227
LangOpts(getFormattingLangOpts(Style)), Keywords(Keywords) {
228-
assert(IsCpp == LangOpts.CXXOperatorNames);
228+
assert(IsCpp == (LangOpts.CXXOperatorNames || LangOpts.C17));
229229
}
230230

231231
/// Adapts the indent levels of comment lines to the indent of the

clang/lib/Format/UnwrappedLineParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ UnwrappedLineParser::UnwrappedLineParser(
168168
: IG_Inited),
169169
IncludeGuardToken(nullptr), FirstStartColumn(FirstStartColumn),
170170
Macros(Style.Macros, SourceMgr, Style, Allocator, IdentTable) {
171-
assert(IsCpp == LangOpts.CXXOperatorNames);
171+
assert(IsCpp == (LangOpts.CXXOperatorNames || LangOpts.C17));
172172
}
173173

174174
void UnwrappedLineParser::reset() {

clang/lib/Headers/hlsl/hlsl_detail.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -79,22 +79,6 @@ constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
7979
distance_vec_impl(vector<T, N> X, vector<T, N> Y) {
8080
return length_vec_impl(X - Y);
8181
}
82-
83-
template <typename T>
84-
constexpr enable_if_t<is_same<float, T>::value || is_same<half, T>::value, T>
85-
reflect_impl(T I, T N) {
86-
return I - 2 * N * I * N;
87-
}
88-
89-
template <typename T, int L>
90-
constexpr vector<T, L> reflect_vec_impl(vector<T, L> I, vector<T, L> N) {
91-
#if (__has_builtin(__builtin_spirv_reflect))
92-
return __builtin_spirv_reflect(I, N);
93-
#else
94-
return I - 2 * N * __builtin_hlsl_dot(I, N);
95-
#endif
96-
}
97-
9882
} // namespace __detail
9983
} // namespace hlsl
10084
#endif //_HLSL_HLSL_DETAILS_H_

clang/lib/Headers/hlsl/hlsl_intrinsics.h

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2030,49 +2030,6 @@ double3 rcp(double3);
20302030
_HLSL_BUILTIN_ALIAS(__builtin_hlsl_elementwise_rcp)
20312031
double4 rcp(double4);
20322032

2033-
//===----------------------------------------------------------------------===//
2034-
// reflect builtin
2035-
//===----------------------------------------------------------------------===//
2036-
2037-
/// \fn T reflect(T I, T N)
2038-
/// \brief Returns a reflection using an incident ray, \a I, and a surface
2039-
/// normal, \a N.
2040-
/// \param I The incident ray.
2041-
/// \param N The surface normal.
2042-
///
2043-
/// The return value is a floating-point vector that represents the reflection
2044-
/// of the incident ray, \a I, off a surface with the normal \a N.
2045-
///
2046-
/// This function calculates the reflection vector using the following formula:
2047-
/// V = I - 2 * N * dot(I N) .
2048-
///
2049-
/// N must already be normalized in order to achieve the desired result.
2050-
///
2051-
/// The operands must all be a scalar or vector whose component type is
2052-
/// floating-point.
2053-
///
2054-
/// Result type and the type of all operands must be the same type.
2055-
2056-
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2057-
const inline half reflect(half I, half N) {
2058-
return __detail::reflect_impl(I, N);
2059-
}
2060-
2061-
const inline float reflect(float I, float N) {
2062-
return __detail::reflect_impl(I, N);
2063-
}
2064-
2065-
template <int L>
2066-
_HLSL_16BIT_AVAILABILITY(shadermodel, 6.2)
2067-
const inline vector<half, L> reflect(vector<half, L> I, vector<half, L> N) {
2068-
return __detail::reflect_vec_impl(I, N);
2069-
}
2070-
2071-
template <int L>
2072-
const inline vector<float, L> reflect(vector<float, L> I, vector<float, L> N) {
2073-
return __detail::reflect_vec_impl(I, N);
2074-
}
2075-
20762033
//===----------------------------------------------------------------------===//
20772034
// rsqrt builtins
20782035
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)