Skip to content

Commit 12848da

Browse files
committed
merge main into amd-staging
Change-Id: Iaf7385ca81460a898644a0b5210d18c5a4594c6c
2 parents a646234 + 2914ba1 commit 12848da

File tree

50 files changed

+2132
-1001
lines changed

Some content is hidden

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

50 files changed

+2132
-1001
lines changed

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/docs/ReleaseNotes.rst

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ Improvements to clang-tidy
117117
- Improved :program:`run-clang-tidy.py` script. Fixed minor shutdown noise
118118
happening on certain platforms when interrupting the script.
119119

120+
- Improved :program:`clang-tidy` by fixing incorrect configuration file path
121+
resolving when file paths contain ``..``.
122+
120123
- Removed :program:`clang-tidy`'s global options for most of checks. All options
121124
are changed to local options except `IncludeStyle`, `StrictMode` and
122125
`IgnoreMacros`. Global scoped `StrictMode` and `IgnoreMacros` are deprecated
@@ -192,7 +195,7 @@ Changes in existing checks
192195
the offending code with ``reinterpret_cast``, to more clearly express intent.
193196

194197
- Improved :doc:`bugprone-dangling-handle
195-
<clang-tidy/checks/bugprone/dangling-handle>` check to treat `std::span` as a
198+
<clang-tidy/checks/bugprone/dangling-handle>` check to treat ``std::span`` as a
196199
handle class.
197200

198201
- Improved :doc:`bugprone-exception-escape
@@ -230,7 +233,7 @@ Changes in existing checks
230233

231234
- Improved :doc:`bugprone-unchecked-optional-access
232235
<clang-tidy/checks/bugprone/unchecked-optional-access>` to support
233-
`bsl::optional` and `bdlb::NullableValue` from
236+
``bsl::optional`` and ``bdlb::NullableValue`` from
234237
<https://github.com/bloomberg/bde>_.
235238

236239
- Improved :doc:`bugprone-unhandled-self-assignment
@@ -367,7 +370,7 @@ Changes in existing checks
367370

368371
- Improved :doc:`readability-redundant-smartptr-get
369372
<clang-tidy/checks/readability/redundant-smartptr-get>` check to
370-
remove `->`, when redundant `get()` is removed.
373+
remove ``->``, when redundant ``get()`` is removed.
371374

372375
- Improved :doc:`readability-use-std-min-max
373376
<clang-tidy/checks/readability/use-std-min-max>` check to use correct template

clang-tools-extra/test/clang-tidy/infrastructure/Inputs/normalized-path/code.cpp

Whitespace-only changes.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
InvalidYamlFormat
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
// RUN: clang-tidy %S/Inputs/normalized-path/error-config/../code.cpp --verify-config 2>&1 | FileCheck %s
2+
3+
// CHECK-NOT: Error parsing

clang-tools-extra/unittests/clang-tidy/ClangTidyOptionsTest.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -417,13 +417,6 @@ TEST(ValidConfiguration, ValidEnumOptions) {
417417
CHECK_VAL(TestCheck.getIntLocal<Colours>("Valid"), Colours::Red);
418418
CHECK_VAL(TestCheck.getIntGlobal<Colours>("GlobalValid"), Colours::Violet);
419419

420-
CHECK_VAL(
421-
TestCheck.getIntLocal<Colours>("ValidWrongCase", /*IgnoreCase*/ true),
422-
Colours::Red);
423-
CHECK_VAL(TestCheck.getIntGlobal<Colours>("GlobalValidWrongCase",
424-
/*IgnoreCase*/ true),
425-
Colours::Violet);
426-
427420
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("ValidWrongCase").has_value());
428421
EXPECT_FALSE(TestCheck.getIntLocal<Colours>("NearMiss").has_value());
429422
EXPECT_FALSE(TestCheck.getIntGlobal<Colours>("GlobalInvalid").has_value());

compiler-rt/lib/interception/tests/interception_win_test.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -801,8 +801,8 @@ const struct InstructionSizeData {
801801
size_t size; // hold instruction size or 0 for failure,
802802
// e.g. on control instructions
803803
u8 instr[16];
804-
size_t rel_offset; // filled just for instructions with two operands
805-
// and displacement length of four bytes.
804+
size_t rel_offset; // adjustment for RIP-relative addresses when copying
805+
// instructions during hooking via hotpatch or trampoline.
806806
const char *comment;
807807
} data[] = {
808808
// clang-format off
@@ -858,6 +858,7 @@ const struct InstructionSizeData {
858858
{ 5, {0x68, 0x71, 0x72, 0x73, 0x74}, 0, "68 XX XX XX XX : push imm32"},
859859
{ 5, {0xb8, 0x71, 0x72, 0x73, 0x74}, 0, "b8 XX XX XX XX : mov eax, XX XX XX XX"},
860860
{ 5, {0xB9, 0x71, 0x72, 0x73, 0x74}, 0, "b9 XX XX XX XX : mov ecx, XX XX XX XX"},
861+
{ 7, {0x8D, 0xA4, 0x24, 0x73, 0x74, 0x75, 0x76}, 0, "8D A4 24 XX XX XX XX : lea esp, [esp + XX XX XX XX]"},
861862
#if SANITIZER_WINDOWS_x64
862863
// sorted list
863864
{ 2, {0x40, 0x50}, 0, "40 50 : push rax"},

0 commit comments

Comments
 (0)