Skip to content

Commit 4566819

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:eaa32d20a2612370371047140734e91f8f22dea1 into amd-gfx:7be0dd27ca83
Local branch amd-gfx 7be0dd2 Merged main:52770d83bf00fc56e9496e32f083f0f940bf7315 into amd-gfx:a59cc49ff7ab Remote branch main eaa32d2 [mlir] fix affine-loop-fusion crash (llvm#76351)
2 parents 7be0dd2 + eaa32d2 commit 4566819

File tree

208 files changed

+11252
-2036
lines changed

Some content is hidden

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

208 files changed

+11252
-2036
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 127 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1052,18 +1052,117 @@ libclang
10521052
Static Analyzer
10531053
---------------
10541054

1055+
New features
1056+
^^^^^^^^^^^^
1057+
1058+
- Implemented the ``[[clang::suppress]]`` attribute for suppressing diagnostics
1059+
of static analysis tools, such as the Clang Static Analyzer.
1060+
`Documentation <https://clang.llvm.org/docs/AttributeReference.html#suppress>`__.
1061+
1062+
- Added support for the ``cleanup`` attribute.
1063+
`Documentation <https://clang.llvm.org/docs/AttributeReference.html#cleanup>`__.
1064+
1065+
- Support "Deducing this" (P0847R7). (Worked out of the box)
1066+
(`af4751738db8 <https://github.com/llvm/llvm-project/commit/af4751738db89a142a8880c782d12d4201b222a8>`__)
1067+
10551068
- Added a new checker ``core.BitwiseShift`` which reports situations where
10561069
bitwise shift operators produce undefined behavior (because some operand is
10571070
negative or too large).
1071+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#core-bitwiseshift-c-c>`__.
1072+
1073+
- Added a new experimental checker ``alpha.core.StdVariant`` to detect variant
1074+
accesses via wrong alternatives.
1075+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#alpha-core-stdvariant-c>`__.
1076+
(`#66481 <https://github.com/llvm/llvm-project/pull/66481>`_)
1077+
1078+
- Added a new experimental checker ``alpha.cplusplus.ArrayDelete`` to detect
1079+
destructions of arrays of polymorphic objects that are destructed as their
1080+
base class (`CERT EXP51-CPP <https://wiki.sei.cmu.edu/confluence/display/cplusplus/EXP51-CPP.+Do+not+delete+an+array+through+a+pointer+of+the+incorrect+type>`_).
1081+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#alpha-cplusplus-arraydelete-c>`__.
1082+
(`0e246bb67573 <https://github.com/llvm/llvm-project/commit/0e246bb67573799409d0085b89902a330998ddcc>`_)
1083+
1084+
- Added a new checker configuration option ``InvalidatingGetEnv=[true,false]`` to
1085+
``security.cert.env.InvalidPtr``. It's not set by default.
1086+
If set, ``getenv`` calls won't invalidate previously returned pointers.
1087+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#security-cert-env-invalidptr>`__.
1088+
(`#67663 <https://github.com/llvm/llvm-project/pull/67663>`_)
1089+
1090+
Crash and bug fixes
1091+
^^^^^^^^^^^^^^^^^^^
10581092

1059-
- Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
1060-
to ``unix.Errno``.
1093+
- Fixed a crash caused by ``builtin_bit_cast``.
1094+
(`#69922 <https://github.com/llvm/llvm-project/issues/69922>`_)
10611095

1062-
- Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
1063-
to ``unix.StdCLibraryFunctions``.
1096+
- Fixed a ``core.StackAddressEscape`` crash on temporary object fields.
1097+
(`#66221 <https://github.com/llvm/llvm-project/issues/66221>`_)
1098+
1099+
- A few crashes have been found and fixed using randomized testing related
1100+
to the use of ``_BitInt()`` in tidy checks and in clang analysis.
1101+
(`#67212 <https://github.com/llvm/llvm-project/pull/67212>`_,
1102+
`#66782 <https://github.com/llvm/llvm-project/pull/66782>`_,
1103+
`#65889 <https://github.com/llvm/llvm-project/pull/65889>`_,
1104+
`#65888 <https://github.com/llvm/llvm-project/pull/65888>`_,
1105+
`#65887 <https://github.com/llvm/llvm-project/pull/65887>`_)
1106+
1107+
- Fixed note links of the HTML output.
1108+
(`#64054 <https://github.com/llvm/llvm-project/issues/64054>`_)
1109+
1110+
- Allow widening rage-based for loops.
1111+
(`#70190 <https://github.com/llvm/llvm-project/pull/70190>`_)
1112+
1113+
- Fixed uninitialized base class with initializer list when ctor is not
1114+
declared in the base class.
1115+
(`#70464 <https://github.com/llvm/llvm-project/issues/70464>`_,
1116+
`#59493 <https://github.com/llvm/llvm-project/issues/59493>`_,
1117+
`#54533 <https://github.com/llvm/llvm-project/issues/54533>`_)
1118+
1119+
- Fixed an ``alpha.unix.cstring`` crash on variadic functions.
1120+
(`#74269 <https://github.com/llvm/llvm-project/issues/74269>`_)
10641121

10651122
- Fix false positive in mutation check when using pointer to member function.
1066-
(`#66204: <https://github.com/llvm/llvm-project/issues/66204>`_).
1123+
(`#66204 <https://github.com/llvm/llvm-project/issues/66204>`_)
1124+
1125+
Improvements
1126+
^^^^^^^^^^^^
1127+
1128+
- Improved the ``unix.StdCLibraryFunctions`` checker by modeling more
1129+
functions like ``send``, ``recv``, ``readlink`` and ``errno`` behavior.
1130+
(`52ac71f92d38 <https://github.com/llvm/llvm-project/commit/52ac71f92d38f75df5cb88e9c090ac5fd5a71548>`_,
1131+
`#71373 <https://github.com/llvm/llvm-project/pull/71373>`_,
1132+
`#71392 <https://github.com/llvm/llvm-project/pull/71392>`_)
1133+
1134+
- Fixed a false negative for when accessing a nonnull property (ObjC).
1135+
(`1dceba3a3684 <https://github.com/llvm/llvm-project/commit/1dceba3a3684d12394731e09a6cf3efcebf07a3a>`_)
1136+
1137+
- ``security.insecureAPI.DeprecatedOrUnsafeBufferHandling`` now considers
1138+
``fprintf`` calls unsafe.
1139+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#security-insecureapi-deprecatedorunsafebufferhandling-c>`__.
1140+
1141+
- Improved the diagnostics of the ``optin.core.EnumCastOutOfRange`` checker.
1142+
It will display the name and the declaration of the enumeration along with
1143+
the concrete value being cast to the enum.
1144+
(`#74503 <https://github.com/llvm/llvm-project/pull/74503>`_)
1145+
1146+
- Improved the ``alpha.security.ArrayBoundV2`` checker for detecting buffer
1147+
accesses prior the buffer; and also reworked the diagnostic messages.
1148+
(`3e014038b373 <https://github.com/llvm/llvm-project/commit/3e014038b373e5a4a96d89d46cea17e4d2456a04>`_,
1149+
`#70056 <https://github.com/llvm/llvm-project/pull/70056>`_,
1150+
`#72107 <https://github.com/llvm/llvm-project/pull/72107>`_)
1151+
1152+
- Improved the ``alpha.unix.cstring.OutOfBounds`` checking both ends of the
1153+
buffers in more cases.
1154+
(`c3a87ddad62a <https://github.com/llvm/llvm-project/commit/c3a87ddad62a6cc01acaccc76592bc6730c8ac3c>`_,
1155+
`0954dc3fb921 <https://github.com/llvm/llvm-project/commit/0954dc3fb9214b994623f5306473de075f8e3593>`_)
1156+
1157+
- Improved the ``alpha.unix.Stream`` checker by modeling more functions like,
1158+
``fflush``, ``fputs``, ``fgetc``, ``fputc``, ``fopen``, ``fopen``, ``fgets``.
1159+
(`#74296 <https://github.com/llvm/llvm-project/pull/74296>`_,
1160+
`#73335 <https://github.com/llvm/llvm-project/pull/73335>`_,
1161+
`#72627 <https://github.com/llvm/llvm-project/pull/72627>`_,
1162+
`#71518 <https://github.com/llvm/llvm-project/pull/71518>`_,
1163+
`#72016 <https://github.com/llvm/llvm-project/pull/72016>`_,
1164+
`#70540 <https://github.com/llvm/llvm-project/pull/70540>`_,
1165+
`#73638 <https://github.com/llvm/llvm-project/pull/73638>`_)
10671166

10681167
- The ``alpha.security.taint.TaintPropagation`` checker no longer propagates
10691168
taint on ``strlen`` and ``strnlen`` calls, unless these are marked
@@ -1072,16 +1171,32 @@ Static Analyzer
10721171
Read the PR for the details.
10731172
(`#66086 <https://github.com/llvm/llvm-project/pull/66086>`_)
10741173

1075-
- A few crashes have been found and fixed using randomized testing related
1076-
to the use of ``_BitInt()`` in tidy checks and in clang analysis. See
1077-
`#67212 <https://github.com/llvm/llvm-project/pull/67212>`_,
1078-
`#66782 <https://github.com/llvm/llvm-project/pull/66782>`_,
1079-
`#65889 <https://github.com/llvm/llvm-project/pull/65889>`_,
1080-
`#65888 <https://github.com/llvm/llvm-project/pull/65888>`_, and
1081-
`#65887 <https://github.com/llvm/llvm-project/pull/65887>`_
1174+
- Other taint-related improvements.
1175+
(`#66358 <https://github.com/llvm/llvm-project/pull/66358>`_,
1176+
`#66074 <https://github.com/llvm/llvm-project/pull/66074>`_,
1177+
`#66358 <https://github.com/llvm/llvm-project/pull/66358>`_)
1178+
1179+
- Checkers can query constraint bounds to improve diagnostic messages.
1180+
(`#74141 <https://github.com/llvm/llvm-project/pull/74141>`_)
1181+
1182+
Moved checkers
1183+
^^^^^^^^^^^^^^
1184+
1185+
- Move checker ``alpha.unix.Errno`` out of the ``alpha`` package
1186+
to ``unix.Errno``.
1187+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-errno-c>`__.
1188+
1189+
- Move checker ``alpha.unix.StdCLibraryFunctions`` out of the ``alpha`` package
1190+
to ``unix.StdCLibraryFunctions``.
1191+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#unix-stdclibraryfunctions-c>`__.
1192+
1193+
- Move checker ``alpha.security.cert.env.InvalidPtr`` out of the ``alpha``
1194+
package to ``security.cert.env.InvalidPtr``.
1195+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#security-cert-env-invalidptr>`__.
10821196

10831197
- Move checker ``alpha.cplusplus.EnumCastOutOfRange`` out of the ``alpha``
10841198
package to ``optin.core.EnumCastOutOfRange``.
1199+
`Documentation <https://clang.llvm.org/docs/analyzer/checkers.html#optin-core-enumcastoutofrange-c-c>`__.
10851200

10861201
.. _release-notes-sanitizers:
10871202

clang/docs/analyzer/checkers.rst

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1025,7 +1025,7 @@ security.insecureAPI.vfork (C)
10251025
10261026
security.insecureAPI.DeprecatedOrUnsafeBufferHandling (C)
10271027
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""
1028-
Warn on occurrences of unsafe or deprecated buffer handling functions, which now have a secure variant: ``sprintf, vsprintf, scanf, wscanf, fscanf, fwscanf, vscanf, vwscanf, vfscanf, vfwscanf, sscanf, swscanf, vsscanf, vswscanf, swprintf, snprintf, vswprintf, vsnprintf, memcpy, memmove, strncpy, strncat, memset``
1028+
Warn on occurrences of unsafe or deprecated buffer handling functions, which now have a secure variant: ``sprintf, fprintf, vsprintf, scanf, wscanf, fscanf, fwscanf, vscanf, vwscanf, vfscanf, vfwscanf, sscanf, swscanf, vsscanf, vswscanf, swprintf, snprintf, vswprintf, vsnprintf, memcpy, memmove, strncpy, strncat, memset``
10291029
10301030
.. code-block:: c
10311031
@@ -2095,6 +2095,21 @@ This checker is a part of ``core.StackAddressEscape``, but is temporarily disabl
20952095
// returned block
20962096
}
20972097
2098+
.. _alpha-core-StdVariant:
2099+
2100+
alpha.core.StdVariant (C++)
2101+
"""""""""""""""""""""""""""
2102+
Check if a value of active type is retrieved from an ``std::variant`` instance with ``std::get``.
2103+
In case of bad variant type access (the accessed type differs from the active type)
2104+
a warning is emitted. Currently, this checker does not take exception handling into account.
2105+
2106+
.. code-block:: cpp
2107+
2108+
void test() {
2109+
std::variant<int, char> v = 25;
2110+
char c = stg::get<char>(v); // warn: "int" is the active alternative
2111+
}
2112+
20982113
.. _alpha-core-TestAfterDivZero:
20992114
21002115
alpha.core.TestAfterDivZero (C)

clang/include/clang/AST/Type.h

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2383,10 +2383,6 @@ class alignas(TypeAlignment) Type : public ExtQualsTypeCommonBase {
23832383
/// Check if the type is the CUDA device builtin texture type.
23842384
bool isCUDADeviceBuiltinTextureType() const;
23852385

2386-
bool isRVVType(unsigned ElementCount) const;
2387-
2388-
bool isRVVType(unsigned Bitwidth, bool IsFloat, bool IsBFloat = false) const;
2389-
23902386
/// Return the implicit lifetime for this type, which must not be dependent.
23912387
Qualifiers::ObjCLifetime getObjCARCImplicitLifetime() const;
23922388

@@ -7283,28 +7279,6 @@ inline bool Type::isOpenCLSpecificType() const {
72837279
isQueueT() || isReserveIDT() || isPipeType() || isOCLExtOpaqueType();
72847280
}
72857281

7286-
inline bool Type::isRVVType(unsigned ElementCount) const {
7287-
bool Ret = false;
7288-
#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
7289-
IsFP, IsBF) \
7290-
if (NumEls == ElementCount) \
7291-
Ret |= isSpecificBuiltinType(BuiltinType::Id);
7292-
#include "clang/Basic/RISCVVTypes.def"
7293-
return Ret;
7294-
}
7295-
7296-
inline bool Type::isRVVType(unsigned Bitwidth, bool IsFloat,
7297-
bool IsBFloat) const {
7298-
bool Ret = false;
7299-
#define RVV_TYPE(Name, Id, SingletonId)
7300-
#define RVV_VECTOR_TYPE(Name, Id, SingletonId, NumEls, ElBits, NF, IsSigned, \
7301-
IsFP, IsBF) \
7302-
if (ElBits == Bitwidth && IsFloat == IsFP && IsBFloat == IsBF) \
7303-
Ret |= isSpecificBuiltinType(BuiltinType::Id);
7304-
#include "clang/Basic/RISCVVTypes.def"
7305-
return Ret;
7306-
}
7307-
73087282
inline bool Type::isTemplateTypeParmType() const {
73097283
return isa<TemplateTypeParmType>(CanonicalType);
73107284
}

clang/lib/Basic/Targets/RISCV.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,8 +416,7 @@ static void handleFullArchString(StringRef FullArchStr,
416416
Features.push_back("__RISCV_TargetAttrNeedOverride");
417417
auto RII = llvm::RISCVISAInfo::parseArchString(
418418
FullArchStr, /* EnableExperimentalExtension */ true);
419-
if (!RII) {
420-
consumeError(RII.takeError());
419+
if (llvm::errorToBool(RII.takeError())) {
421420
// Forward the invalid FullArchStr.
422421
Features.push_back("+" + FullArchStr.str());
423422
} else {

clang/lib/Driver/Driver.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@
8686
#include "llvm/Support/PrettyStackTrace.h"
8787
#include "llvm/Support/Process.h"
8888
#include "llvm/Support/Program.h"
89+
#include "llvm/Support/RISCVISAInfo.h"
8990
#include "llvm/Support/StringSaver.h"
9091
#include "llvm/Support/VirtualFileSystem.h"
9192
#include "llvm/Support/raw_ostream.h"
@@ -670,10 +671,15 @@ static llvm::Triple computeTargetTriple(const Driver &D,
670671
if (Args.hasArg(options::OPT_march_EQ) ||
671672
Args.hasArg(options::OPT_mcpu_EQ)) {
672673
StringRef ArchName = tools::riscv::getRISCVArch(Args, Target);
673-
if (ArchName.starts_with_insensitive("rv32"))
674-
Target.setArch(llvm::Triple::riscv32);
675-
else if (ArchName.starts_with_insensitive("rv64"))
676-
Target.setArch(llvm::Triple::riscv64);
674+
auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
675+
ArchName, /*EnableExperimentalExtensions=*/true);
676+
if (!llvm::errorToBool(ISAInfo.takeError())) {
677+
unsigned XLen = (*ISAInfo)->getXLen();
678+
if (XLen == 32)
679+
Target.setArch(llvm::Triple::riscv32);
680+
else if (XLen == 64)
681+
Target.setArch(llvm::Triple::riscv64);
682+
}
677683
}
678684
}
679685

clang/lib/Driver/ToolChains/Arch/RISCV.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,10 +215,8 @@ StringRef riscv::getRISCVABI(const ArgList &Args, const llvm::Triple &Triple) {
215215

216216
auto ParseResult = llvm::RISCVISAInfo::parseArchString(
217217
Arch, /* EnableExperimentalExtension */ true);
218-
if (!ParseResult)
219-
// Ignore parsing error, just go 3rd step.
220-
consumeError(ParseResult.takeError());
221-
else
218+
// Ignore parsing error, just go 3rd step.
219+
if (!llvm::errorToBool(ParseResult.takeError()))
222220
return (*ParseResult)->computeDefaultABI();
223221

224222
// 3. Choose a default based on the triple

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2072,12 +2072,9 @@ void Clang::AddRISCVTargetArgs(const ArgList &Args,
20722072
StringRef Arch = riscv::getRISCVArch(Args, Triple);
20732073
auto ISAInfo = llvm::RISCVISAInfo::parseArchString(
20742074
Arch, /*EnableExperimentalExtensions*/ true);
2075-
if (!ISAInfo) {
2076-
// Ignore parsing error.
2077-
consumeError(ISAInfo.takeError());
2078-
} else {
2075+
// Ignore parsing error.
2076+
if (!errorToBool(ISAInfo.takeError()))
20792077
MinVLen = (*ISAInfo)->getMinVLen();
2080-
}
20812078

20822079
// If the value is "zvl", use MinVLen from march. Otherwise, try to parse
20832080
// as integer as long as we have a MinVLen.

clang/lib/Driver/ToolChains/Gnu.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1741,11 +1741,9 @@ selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, StringRef Arch,
17411741
llvm::RISCVISAInfo::parseArchString(
17421742
Arch, /*EnableExperimentalExtension=*/true,
17431743
/*ExperimentalExtensionVersionCheck=*/false);
1744-
if (!ParseResult) {
1745-
// Ignore any error here, we assume it will be handled in another place.
1746-
consumeError(ParseResult.takeError());
1744+
// Ignore any error here, we assume it will be handled in another place.
1745+
if (llvm::errorToBool(ParseResult.takeError()))
17471746
return false;
1748-
}
17491747

17501748
auto &ISAInfo = *ParseResult;
17511749

@@ -1780,10 +1778,8 @@ selectRISCVMultilib(const MultilibSet &RISCVMultilibSet, StringRef Arch,
17801778
llvm::RISCVISAInfo::parseArchString(
17811779
Flag, /*EnableExperimentalExtension=*/true,
17821780
/*ExperimentalExtensionVersionCheck=*/false);
1783-
if (!MLConfigParseResult) {
1784-
// Ignore any error here, we assume it will handled in another place.
1785-
llvm::consumeError(MLConfigParseResult.takeError());
1786-
1781+
// Ignore any error here, we assume it will handled in another place.
1782+
if (llvm::errorToBool(MLConfigParseResult.takeError())) {
17871783
// We might get a parsing error if rv32e in the list, we could just skip
17881784
// that and process the rest of multi-lib configs.
17891785
Skip = true;

clang/lib/Frontend/LayoutOverrideSource.cpp

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) {
147147

148148
// Skip over this offset, the following comma, and any spaces.
149149
LineStr = LineStr.substr(1);
150-
while (!LineStr.empty() && isWhitespace(LineStr[0]))
151-
LineStr = LineStr.substr(1);
150+
LineStr = LineStr.drop_while(isWhitespace);
152151
}
153152
}
154153

@@ -163,8 +162,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) {
163162

164163
// Skip over this offset, the following comma, and any spaces.
165164
LineStr = LineStr.substr(1);
166-
while (!LineStr.empty() && isWhitespace(LineStr[0]))
167-
LineStr = LineStr.substr(1);
165+
LineStr = LineStr.drop_while(isWhitespace);
168166
}
169167
continue;
170168
}
@@ -180,8 +178,7 @@ LayoutOverrideSource::LayoutOverrideSource(StringRef Filename) {
180178

181179
// Skip over this offset, the following comma, and any spaces.
182180
LineStr = LineStr.substr(1);
183-
while (!LineStr.empty() && isWhitespace(LineStr[0]))
184-
LineStr = LineStr.substr(1);
181+
LineStr = LineStr.drop_while(isWhitespace);
185182
}
186183
}
187184
}

0 commit comments

Comments
 (0)