Skip to content

Commit 0c4323a

Browse files
authored
Merge branch 'llvm:main' into main
2 parents 1b60d62 + 657fb44 commit 0c4323a

File tree

355 files changed

+11002
-3811
lines changed

Some content is hidden

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

355 files changed

+11002
-3811
lines changed

.github/workflows/spirv-tests.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,4 @@ jobs:
2626
build_target: check-llvm-codegen-spirv
2727
projects:
2828
extra_cmake_args: '-DLLVM_TARGETS_TO_BUILD="" -DLLVM_EXPERIMENTAL_TARGETS_TO_BUILD="SPIRV" -DLLVM_INCLUDE_SPIRV_TOOLS_TESTS=ON'
29-
os_list: '["ubuntu-latest"]'
29+
os_list: '["ubuntu-22.04"]'

clang-tools-extra/clang-tidy/ClangTidyCheck.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,10 @@ void ClangTidyCheck::OptionsView::store<bool>(
163163
store(Options, LocalName, Value ? StringRef("true") : StringRef("false"));
164164
}
165165

166-
std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
167-
StringRef LocalName, ArrayRef<NameAndValue> Mapping, bool CheckGlobal,
168-
bool IgnoreCase) const {
166+
std::optional<int64_t>
167+
ClangTidyCheck::OptionsView::getEnumInt(StringRef LocalName,
168+
ArrayRef<NameAndValue> Mapping,
169+
bool CheckGlobal) const {
169170
if (!CheckGlobal && Context->getOptionsCollector())
170171
Context->getOptionsCollector()->insert((NamePrefix + LocalName).str());
171172
auto Iter = CheckGlobal ? findPriorityOption(CheckOptions, NamePrefix,
@@ -178,12 +179,10 @@ std::optional<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
178179
StringRef Closest;
179180
unsigned EditDistance = 3;
180181
for (const auto &NameAndEnum : Mapping) {
181-
if (IgnoreCase) {
182-
if (Value.equals_insensitive(NameAndEnum.second))
183-
return NameAndEnum.first;
184-
} else if (Value == NameAndEnum.second) {
182+
if (Value == NameAndEnum.second) {
185183
return NameAndEnum.first;
186-
} else if (Value.equals_insensitive(NameAndEnum.second)) {
184+
}
185+
if (Value.equals_insensitive(NameAndEnum.second)) {
187186
Closest = NameAndEnum.second;
188187
EditDistance = 0;
189188
continue;

clang-tools-extra/clang-tidy/ClangTidyCheck.h

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -333,9 +333,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
333333
/// supply the mapping required to convert between ``T`` and a string.
334334
template <typename T>
335335
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
336-
get(StringRef LocalName, bool IgnoreCase = false) const {
336+
get(StringRef LocalName) const {
337337
if (std::optional<int64_t> ValueOr =
338-
getEnumInt(LocalName, typeEraseMapping<T>(), false, IgnoreCase))
338+
getEnumInt(LocalName, typeEraseMapping<T>(), false))
339339
return static_cast<T>(*ValueOr);
340340
return std::nullopt;
341341
}
@@ -353,9 +353,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
353353
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
354354
/// supply the mapping required to convert between ``T`` and a string.
355355
template <typename T>
356-
std::enable_if_t<std::is_enum_v<T>, T> get(StringRef LocalName, T Default,
357-
bool IgnoreCase = false) const {
358-
return get<T>(LocalName, IgnoreCase).value_or(Default);
356+
std::enable_if_t<std::is_enum_v<T>, T> get(StringRef LocalName,
357+
T Default) const {
358+
return get<T>(LocalName).value_or(Default);
359359
}
360360

361361
/// Read a named option from the ``Context`` and parse it as an
@@ -373,9 +373,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
373373
/// supply the mapping required to convert between ``T`` and a string.
374374
template <typename T>
375375
std::enable_if_t<std::is_enum_v<T>, std::optional<T>>
376-
getLocalOrGlobal(StringRef LocalName, bool IgnoreCase = false) const {
376+
getLocalOrGlobal(StringRef LocalName) const {
377377
if (std::optional<int64_t> ValueOr =
378-
getEnumInt(LocalName, typeEraseMapping<T>(), true, IgnoreCase))
378+
getEnumInt(LocalName, typeEraseMapping<T>(), true))
379379
return static_cast<T>(*ValueOr);
380380
return std::nullopt;
381381
}
@@ -394,10 +394,9 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
394394
/// \ref clang::tidy::OptionEnumMapping must be specialized for ``T`` to
395395
/// supply the mapping required to convert between ``T`` and a string.
396396
template <typename T>
397-
std::enable_if_t<std::is_enum_v<T>, T>
398-
getLocalOrGlobal(StringRef LocalName, T Default,
399-
bool IgnoreCase = false) const {
400-
return getLocalOrGlobal<T>(LocalName, IgnoreCase).value_or(Default);
397+
std::enable_if_t<std::is_enum_v<T>, T> getLocalOrGlobal(StringRef LocalName,
398+
T Default) const {
399+
return getLocalOrGlobal<T>(LocalName).value_or(Default);
401400
}
402401

403402
/// Stores an option with the check-local name \p LocalName with
@@ -454,7 +453,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
454453

455454
std::optional<int64_t> getEnumInt(StringRef LocalName,
456455
ArrayRef<NameAndValue> Mapping,
457-
bool CheckGlobal, bool IgnoreCase) const;
456+
bool CheckGlobal) const;
458457

459458
template <typename T>
460459
std::enable_if_t<std::is_enum_v<T>, std::vector<NameAndValue>>

clang-tools-extra/clang-tidy/ClangTidyOptions.cpp

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include "llvm/ADT/SmallString.h"
1313
#include "llvm/Support/Debug.h"
1414
#include "llvm/Support/Errc.h"
15+
#include "llvm/Support/ErrorOr.h"
1516
#include "llvm/Support/FileSystem.h"
1617
#include "llvm/Support/MemoryBufferRef.h"
1718
#include "llvm/Support/Path.h"
@@ -298,12 +299,11 @@ ConfigOptionsProvider::getRawOptions(llvm::StringRef FileName) {
298299
if (ConfigOptions.InheritParentConfig.value_or(false)) {
299300
LLVM_DEBUG(llvm::dbgs()
300301
<< "Getting options for file " << FileName << "...\n");
301-
assert(FS && "FS must be set.");
302302

303-
llvm::SmallString<128> AbsoluteFilePath(FileName);
304-
305-
if (!FS->makeAbsolute(AbsoluteFilePath)) {
306-
addRawFileOptions(AbsoluteFilePath, RawOptions);
303+
llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
304+
getNormalizedAbsolutePath(FileName);
305+
if (AbsoluteFilePath) {
306+
addRawFileOptions(AbsoluteFilePath->str(), RawOptions);
307307
}
308308
}
309309
RawOptions.emplace_back(ConfigOptions,
@@ -334,6 +334,17 @@ FileOptionsBaseProvider::FileOptionsBaseProvider(
334334
OverrideOptions(std::move(OverrideOptions)),
335335
ConfigHandlers(std::move(ConfigHandlers)) {}
336336

337+
llvm::ErrorOr<llvm::SmallString<128>>
338+
FileOptionsBaseProvider::getNormalizedAbsolutePath(llvm::StringRef Path) {
339+
assert(FS && "FS must be set.");
340+
llvm::SmallString<128> NormalizedAbsolutePath = {Path};
341+
std::error_code Err = FS->makeAbsolute(NormalizedAbsolutePath);
342+
if (Err)
343+
return Err;
344+
llvm::sys::path::remove_dots(NormalizedAbsolutePath, /*remove_dot_dot=*/true);
345+
return NormalizedAbsolutePath;
346+
}
347+
337348
void FileOptionsBaseProvider::addRawFileOptions(
338349
llvm::StringRef AbsolutePath, std::vector<OptionsSource> &CurOptions) {
339350
auto CurSize = CurOptions.size();
@@ -397,16 +408,15 @@ std::vector<OptionsSource>
397408
FileOptionsProvider::getRawOptions(StringRef FileName) {
398409
LLVM_DEBUG(llvm::dbgs() << "Getting options for file " << FileName
399410
<< "...\n");
400-
assert(FS && "FS must be set.");
401-
402-
llvm::SmallString<128> AbsoluteFilePath(FileName);
403411

404-
if (FS->makeAbsolute(AbsoluteFilePath))
412+
llvm::ErrorOr<llvm::SmallString<128>> AbsoluteFilePath =
413+
getNormalizedAbsolutePath(FileName);
414+
if (!AbsoluteFilePath)
405415
return {};
406416

407417
std::vector<OptionsSource> RawOptions =
408-
DefaultOptionsProvider::getRawOptions(AbsoluteFilePath.str());
409-
addRawFileOptions(AbsoluteFilePath, RawOptions);
418+
DefaultOptionsProvider::getRawOptions(AbsoluteFilePath->str());
419+
addRawFileOptions(AbsoluteFilePath->str(), RawOptions);
410420
OptionsSource CommandLineOptions(OverrideOptions,
411421
OptionsSourceTypeCheckCommandLineOption);
412422

clang-tools-extra/clang-tidy/ClangTidyOptions.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#define LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYOPTIONS_H
1111

1212
#include "llvm/ADT/IntrusiveRefCntPtr.h"
13+
#include "llvm/ADT/SmallString.h"
1314
#include "llvm/ADT/StringMap.h"
1415
#include "llvm/ADT/StringRef.h"
1516
#include "llvm/Support/ErrorOr.h"
@@ -237,6 +238,9 @@ class FileOptionsBaseProvider : public DefaultOptionsProvider {
237238
void addRawFileOptions(llvm::StringRef AbsolutePath,
238239
std::vector<OptionsSource> &CurOptions);
239240

241+
llvm::ErrorOr<llvm::SmallString<128>>
242+
getNormalizedAbsolutePath(llvm::StringRef AbsolutePath);
243+
240244
/// Try to read configuration files from \p Directory using registered
241245
/// \c ConfigHandlers.
242246
std::optional<OptionsSource> tryReadConfigFile(llvm::StringRef Directory);

clang-tools-extra/clang-tidy/bugprone/NarrowingConversionsCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ AST_MATCHER(FieldDecl, hasIntBitwidth) {
3838
assert(Node.isBitField());
3939
const ASTContext &Ctx = Node.getASTContext();
4040
unsigned IntBitWidth = Ctx.getIntWidth(Ctx.IntTy);
41-
unsigned CurrentBitWidth = Node.getBitWidthValue(Ctx);
41+
unsigned CurrentBitWidth = Node.getBitWidthValue();
4242
return IntBitWidth == CurrentBitWidth;
4343
}
4444

clang-tools-extra/clang-tidy/bugprone/TooSmallLoopVariableCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ static MagnitudeBits calcMagnitudeBits(const ASTContext &Context,
124124
unsigned SignedBits = IntExprType->isUnsignedIntegerType() ? 0U : 1U;
125125

126126
if (const auto *BitField = IntExpr->getSourceBitField()) {
127-
unsigned BitFieldWidth = BitField->getBitWidthValue(Context);
127+
unsigned BitFieldWidth = BitField->getBitWidthValue();
128128
return {BitFieldWidth - SignedBits, BitFieldWidth};
129129
}
130130

clang-tools-extra/clang-tidy/hicpp/MultiwayPathsCoveredCheck.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ void MultiwayPathsCoveredCheck::handleSwitchWithoutDefault(
160160
}
161161
if (const auto *BitfieldDecl =
162162
Result.Nodes.getNodeAs<FieldDecl>("bitfield")) {
163-
return twoPow(BitfieldDecl->getBitWidthValue(*Result.Context));
163+
return twoPow(BitfieldDecl->getBitWidthValue());
164164
}
165165

166166
return static_cast<std::size_t>(0);

clang-tools-extra/clang-tidy/readability/ContainerSizeEmptyCheck.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@ namespace clang::tidy::readability {
1919
///
2020
/// The emptiness of a container should be checked using the `empty()` method
2121
/// instead of the `size()`/`length()` method. It shows clearer intent to use
22-
/// `empty()`. Furthermore some containers may implement the `empty()` method
23-
/// but not implement the `size()` or `length()` method. Using `empty()`
24-
/// whenever possible makes it easier to switch to another container in the
25-
/// future.
22+
/// `empty()`. Furthermore some containers (for example, a `std::forward_list`)
23+
/// may implement the `empty()` method but not implement the `size()` or
24+
/// `length()` method. Using `empty()` whenever possible makes it easier to
25+
/// switch to another container in the future.
2626
class ContainerSizeEmptyCheck : public ClangTidyCheck {
2727
public:
2828
ContainerSizeEmptyCheck(StringRef Name, ClangTidyContext *Context);

clang-tools-extra/clang-tidy/readability/RedundantCastingCheck.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,10 @@ void RedundantCastingCheck::registerMatchers(MatchFinder *Finder) {
108108

109109
auto BitfieldMemberExpr = memberExpr(member(fieldDecl(isBitField())));
110110

111+
const ast_matchers::internal::VariadicDynCastAllOfMatcher<
112+
Stmt, CXXParenListInitExpr>
113+
cxxParenListInitExpr; // NOLINT(readability-identifier-naming)
114+
111115
Finder->addMatcher(
112116
explicitCastExpr(
113117
unless(hasCastKind(CK_ConstructorConversion)),
@@ -117,6 +121,7 @@ void RedundantCastingCheck::registerMatchers(MatchFinder *Finder) {
117121
hasDestinationType(qualType().bind("dstType")),
118122
hasSourceExpression(anyOf(
119123
expr(unless(initListExpr()), unless(BitfieldMemberExpr),
124+
unless(cxxParenListInitExpr()),
120125
hasType(qualType().bind("srcType")))
121126
.bind("source"),
122127
initListExpr(unless(hasInit(1, expr())),

0 commit comments

Comments
 (0)