Skip to content

Commit 42b6a1d

Browse files
author
Jenkins
committed
merge main into amd-staging
Change-Id: I54b5b4774cd9d38952074c99bc45c9ccc02923f1
2 parents 176813e + 2b31a67 commit 42b6a1d

File tree

296 files changed

+6210
-3786
lines changed

Some content is hidden

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

296 files changed

+6210
-3786
lines changed

clang-tools-extra/clang-apply-replacements/include/clang-apply-replacements/Tooling/ApplyReplacements.h

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,19 +51,27 @@ using FileToChangesMap =
5151
/// Directories starting with '.' are ignored during traversal.
5252
///
5353
/// \param[in] Directory Directory to begin search for serialized
54-
/// TranslationUnitReplacements.
54+
/// TranslationUnitReplacements or TranslationUnitDiagnostics.
5555
/// \param[out] TUs Collection of all found and deserialized
5656
/// TranslationUnitReplacements or TranslationUnitDiagnostics.
57-
/// \param[out] TUFiles Collection of all TranslationUnitReplacement files
58-
/// found in \c Directory.
57+
/// \param[out] TUFiles Collection of all TranslationUnitReplacement or
58+
/// TranslationUnitDiagnostics files found in \c Directory.
5959
/// \param[in] Diagnostics DiagnosticsEngine used for error output.
6060
///
6161
/// \returns An error_code indicating success or failure in navigating the
6262
/// directory structure.
63+
template <typename TranslationUnits>
64+
std::error_code collectReplacementsFromDirectory(
65+
const llvm::StringRef Directory, TranslationUnits &TUs,
66+
TUReplacementFiles &TUFiles,
67+
clang::DiagnosticsEngine &Diagnostics) = delete;
68+
69+
template <>
6370
std::error_code collectReplacementsFromDirectory(
6471
const llvm::StringRef Directory, TUReplacements &TUs,
6572
TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics);
6673

74+
template <>
6775
std::error_code collectReplacementsFromDirectory(
6876
const llvm::StringRef Directory, TUDiagnostics &TUs,
6977
TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics);

clang-tools-extra/clang-apply-replacements/lib/Tooling/ApplyReplacements.cpp

Lines changed: 17 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,10 @@ static void eatDiagnostics(const SMDiagnostic &, void *) {}
3838
namespace clang {
3939
namespace replace {
4040

41-
std::error_code collectReplacementsFromDirectory(
42-
const llvm::StringRef Directory, TUReplacements &TUs,
41+
namespace detail {
42+
template <typename TranslationUnits>
43+
static std::error_code collectReplacementsFromDirectory(
44+
const llvm::StringRef Directory, TranslationUnits &TUs,
4345
TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
4446
using namespace llvm::sys::fs;
4547
using namespace llvm::sys::path;
@@ -68,7 +70,7 @@ std::error_code collectReplacementsFromDirectory(
6870
}
6971

7072
yaml::Input YIn(Out.get()->getBuffer(), nullptr, &eatDiagnostics);
71-
tooling::TranslationUnitReplacements TU;
73+
typename TranslationUnits::value_type TU;
7274
YIn >> TU;
7375
if (YIn.error()) {
7476
// File doesn't appear to be a header change description. Ignore it.
@@ -81,49 +83,22 @@ std::error_code collectReplacementsFromDirectory(
8183

8284
return ErrorCode;
8385
}
86+
} // namespace detail
8487

88+
template <>
8589
std::error_code collectReplacementsFromDirectory(
86-
const llvm::StringRef Directory, TUDiagnostics &TUs,
90+
const llvm::StringRef Directory, TUReplacements &TUs,
8791
TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
88-
using namespace llvm::sys::fs;
89-
using namespace llvm::sys::path;
90-
91-
std::error_code ErrorCode;
92-
93-
for (recursive_directory_iterator I(Directory, ErrorCode), E;
94-
I != E && !ErrorCode; I.increment(ErrorCode)) {
95-
if (filename(I->path())[0] == '.') {
96-
// Indicate not to descend into directories beginning with '.'
97-
I.no_push();
98-
continue;
99-
}
100-
101-
if (extension(I->path()) != ".yaml")
102-
continue;
103-
104-
TUFiles.push_back(I->path());
105-
106-
ErrorOr<std::unique_ptr<MemoryBuffer>> Out =
107-
MemoryBuffer::getFile(I->path());
108-
if (std::error_code BufferError = Out.getError()) {
109-
errs() << "Error reading " << I->path() << ": " << BufferError.message()
110-
<< "\n";
111-
continue;
112-
}
113-
114-
yaml::Input YIn(Out.get()->getBuffer(), nullptr, &eatDiagnostics);
115-
tooling::TranslationUnitDiagnostics TU;
116-
YIn >> TU;
117-
if (YIn.error()) {
118-
// File doesn't appear to be a header change description. Ignore it.
119-
continue;
120-
}
121-
122-
// Only keep files that properly parse.
123-
TUs.push_back(TU);
124-
}
92+
return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
93+
Diagnostics);
94+
}
12595

126-
return ErrorCode;
96+
template <>
97+
std::error_code collectReplacementsFromDirectory(
98+
const llvm::StringRef Directory, TUDiagnostics &TUs,
99+
TUReplacementFiles &TUFiles, clang::DiagnosticsEngine &Diagnostics) {
100+
return detail::collectReplacementsFromDirectory(Directory, TUs, TUFiles,
101+
Diagnostics);
127102
}
128103

129104
/// Extract replacements from collected TranslationUnitReplacements and

clang/include/clang/Basic/AttributeCommonInfo.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ inline bool doesKeywordAttributeTakeArgs(tok::TokenKind Kind) {
260260
switch (Kind) {
261261
default:
262262
return false;
263-
#define KEYWORD_ATTRIBUTE(NAME, HASARG) \
263+
#define KEYWORD_ATTRIBUTE(NAME, HASARG, ...) \
264264
case tok::kw_##NAME: \
265265
return HASARG;
266266
#include "clang/Basic/RegularKeywordAttrInfo.inc"

clang/include/clang/Basic/TokenKinds.def

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -760,8 +760,9 @@ KEYWORD(__builtin_available , KEYALL)
760760
KEYWORD(__builtin_sycl_unique_stable_name, KEYSYCL)
761761

762762
// Keywords defined by Attr.td.
763+
// The "EMPTY ## X" is used to prevent early macro-expansion of the keyword.
763764
#ifndef KEYWORD_ATTRIBUTE
764-
#define KEYWORD_ATTRIBUTE(X, ...) KEYWORD(X, KEYALL)
765+
#define KEYWORD_ATTRIBUTE(X, HASARG, EMPTY) KEYWORD(EMPTY ## X, KEYALL)
765766
#endif
766767
#include "clang/Basic/RegularKeywordAttrInfo.inc"
767768

0 commit comments

Comments
 (0)