Skip to content

Commit 7c3a9f1

Browse files
committed
LLVM and SPIRV-LLVM-Translator pulldown (WW50)
LLVM: llvm/llvm-project@c41b3b0fa0f4 SPIRV-LLVM-Translator: KhronosGroup/SPIRV-LLVM-Translator@b75aff7
2 parents 3fdc06c + cab1525 commit 7c3a9f1

File tree

2,808 files changed

+232015
-109720
lines changed

Some content is hidden

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

2,808 files changed

+232015
-109720
lines changed

.github/ISSUE_TEMPLATE.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: DO NOT FILE AN ISSUE
3+
about: DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION
4+
title: "DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
# DO NOT FILE AN ISSUE
11+
12+
We are in the process of migrating from bugzilla to github issues please do not file a new issue as this could disrupt the migration process.
13+
14+
# DO NOT FILE AN ISSUE

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,5 @@ contact_links:
22
- name: Ask community a question
33
url: https://github.com/intel/llvm/discussions/categories/q-a
44
about: Please use Q&A Discussions category instead of Issues to ask questions
5+
6+
blank_issues_enabled: false
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
---
2+
name: DO NOT FILE AN ISSUE
3+
about: DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION
4+
title: "DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION"
5+
labels: ''
6+
assignees: ''
7+
8+
---
9+
10+
# DO NOT FILE AN ISSUE
11+
12+
We are in the process of migrating from bugzilla to github issues please do not file a new issue as this could disrupt the migration process.
13+
14+
# DO NOT FILE AN ISSUE

.github/PULL_REQUEST_TEMPLATE.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# **DO NOT FILE A PULL REQUEST**
2+
3+
We are in the process of a github migration. Please do not create a pull request as this could interfere with the process.

clang-tools-extra/clang-doc/ClangDoc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
//
77
//===----------------------------------------------------------------------===//
88
//
9-
// This file exposes a method to craete the FrontendActionFactory for the
9+
// This file exposes a method to create the FrontendActionFactory for the
1010
// clang-doc tool. The factory runs the clang-doc mapper on a given set of
1111
// source code files, storing the results key-value pairs in its
1212
// ExecutionContext.

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

Lines changed: 24 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -79,16 +79,22 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
7979
return CharSourceRange::getCharRange(SourceRange.getBegin(), End);
8080
};
8181

82+
// We are only interested in valid ranges.
83+
auto ValidRanges =
84+
llvm::make_filter_range(Ranges, [](const CharSourceRange &R) {
85+
return R.getAsRange().isValid();
86+
});
87+
8288
if (Level == DiagnosticsEngine::Note) {
8389
Error.Notes.push_back(TidyMessage);
84-
for (const CharSourceRange &SourceRange : Ranges)
90+
for (const CharSourceRange &SourceRange : ValidRanges)
8591
Error.Notes.back().Ranges.emplace_back(Loc.getManager(),
8692
ToCharRange(SourceRange));
8793
return;
8894
}
8995
assert(Error.Message.Message.empty() && "Overwriting a diagnostic message");
9096
Error.Message = TidyMessage;
91-
for (const CharSourceRange &SourceRange : Ranges)
97+
for (const CharSourceRange &SourceRange : ValidRanges)
9298
Error.Message.Ranges.emplace_back(Loc.getManager(),
9399
ToCharRange(SourceRange));
94100
}
@@ -149,29 +155,6 @@ ClangTidyError::ClangTidyError(StringRef CheckName,
149155
: tooling::Diagnostic(CheckName, DiagLevel, BuildDirectory),
150156
IsWarningAsError(IsWarningAsError) {}
151157

152-
class ClangTidyContext::CachedGlobList {
153-
public:
154-
CachedGlobList(StringRef Globs) : Globs(Globs) {}
155-
156-
bool contains(StringRef S) {
157-
switch (auto &Result = Cache[S]) {
158-
case Yes:
159-
return true;
160-
case No:
161-
return false;
162-
case None:
163-
Result = Globs.contains(S) ? Yes : No;
164-
return Result == Yes;
165-
}
166-
llvm_unreachable("invalid enum");
167-
}
168-
169-
private:
170-
GlobList Globs;
171-
enum Tristate { None, Yes, No };
172-
llvm::StringMap<Tristate> Cache;
173-
};
174-
175158
ClangTidyContext::ClangTidyContext(
176159
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
177160
bool AllowEnablingAnalyzerAlphaCheckers)
@@ -291,10 +274,12 @@ std::string ClangTidyContext::getCheckName(unsigned DiagnosticID) const {
291274

292275
ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
293276
ClangTidyContext &Ctx, DiagnosticsEngine *ExternalDiagEngine,
294-
bool RemoveIncompatibleErrors, bool GetFixesFromNotes)
277+
bool RemoveIncompatibleErrors, bool GetFixesFromNotes,
278+
bool EnableNolintBlocks)
295279
: Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
296280
RemoveIncompatibleErrors(RemoveIncompatibleErrors),
297-
GetFixesFromNotes(GetFixesFromNotes), LastErrorRelatesToUserCode(false),
281+
GetFixesFromNotes(GetFixesFromNotes),
282+
EnableNolintBlocks(EnableNolintBlocks), LastErrorRelatesToUserCode(false),
298283
LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {}
299284

300285
void ClangTidyDiagnosticConsumer::finalizeLastError() {
@@ -463,7 +448,8 @@ static bool
463448
lineIsMarkedWithNOLINT(const ClangTidyContext &Context,
464449
SmallVectorImpl<ClangTidyError> &SuppressionErrors,
465450
bool AllowIO, const SourceManager &SM,
466-
SourceLocation Loc, StringRef CheckName) {
451+
SourceLocation Loc, StringRef CheckName,
452+
bool EnableNolintBlocks) {
467453
// Get source code for this location.
468454
FileID File;
469455
unsigned Offset;
@@ -493,19 +479,21 @@ lineIsMarkedWithNOLINT(const ClangTidyContext &Context,
493479
return true;
494480

495481
// Check if this line is within a NOLINT(BEGIN...END) block.
496-
return lineIsWithinNolintBegin(Context, SuppressionErrors, SM, Loc, CheckName,
482+
return EnableNolintBlocks &&
483+
lineIsWithinNolintBegin(Context, SuppressionErrors, SM, Loc, CheckName,
497484
TextBeforeDiag, TextAfterDiag);
498485
}
499486

500487
static bool lineIsMarkedWithNOLINTinMacro(
501488
const Diagnostic &Info, const ClangTidyContext &Context,
502-
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO) {
489+
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO,
490+
bool EnableNolintBlocks) {
503491
const SourceManager &SM = Info.getSourceManager();
504492
SourceLocation Loc = Info.getLocation();
505493
std::string CheckName = Context.getCheckName(Info.getID());
506494
while (true) {
507495
if (lineIsMarkedWithNOLINT(Context, SuppressionErrors, AllowIO, SM, Loc,
508-
CheckName))
496+
CheckName, EnableNolintBlocks))
509497
return true;
510498
if (!Loc.isMacroID())
511499
return false;
@@ -520,12 +508,13 @@ namespace tidy {
520508
bool shouldSuppressDiagnostic(
521509
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
522510
ClangTidyContext &Context,
523-
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO) {
511+
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO,
512+
bool EnableNolintBlocks) {
524513
return Info.getLocation().isValid() &&
525514
DiagLevel != DiagnosticsEngine::Error &&
526515
DiagLevel != DiagnosticsEngine::Fatal &&
527516
lineIsMarkedWithNOLINTinMacro(Info, Context, SuppressionErrors,
528-
AllowIO);
517+
AllowIO, EnableNolintBlocks);
529518
}
530519

531520
const llvm::StringMap<tooling::Replacements> *
@@ -555,7 +544,8 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
555544
return;
556545

557546
SmallVector<ClangTidyError, 1> SuppressionErrors;
558-
if (shouldSuppressDiagnostic(DiagLevel, Info, Context, SuppressionErrors)) {
547+
if (shouldSuppressDiagnostic(DiagLevel, Info, Context, SuppressionErrors,
548+
EnableNolintBlocks)) {
559549
++Context.Stats.ErrorsIgnoredNOLINT;
560550
// Ignored a warning, should ignore related notes as well
561551
LastErrorWasIgnored = true;

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

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ class CompilationDatabase;
2929
} // namespace tooling
3030

3131
namespace tidy {
32+
class CachedGlobList;
3233

3334
/// A detected error complete with information to display diagnostic and
3435
/// automatic fix.
@@ -191,7 +192,7 @@ class ClangTidyContext {
191192

192193
std::string CurrentFile;
193194
ClangTidyOptions CurrentOptions;
194-
class CachedGlobList;
195+
195196
std::unique_ptr<CachedGlobList> CheckFilter;
196197
std::unique_ptr<CachedGlobList> WarningAsErrorFilter;
197198

@@ -219,14 +220,17 @@ class ClangTidyContext {
219220
/// If `AllowIO` is false, the function does not attempt to read source files
220221
/// from disk which are not already mapped into memory; such files are treated
221222
/// as not containing a suppression comment.
223+
/// \param EnableNolintBlocks controls whether to honor NOLINTBEGIN/NOLINTEND
224+
/// blocks; if false, only considers line-level disabling.
222225
/// If suppression is not possible due to improper use of "NOLINT" comments -
223226
/// for example, the use of a "NOLINTBEGIN" comment that is not followed by a
224227
/// "NOLINTEND" comment - a diagnostic regarding the improper use is returned
225228
/// via the output argument `SuppressionErrors`.
226229
bool shouldSuppressDiagnostic(
227230
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
228231
ClangTidyContext &Context,
229-
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO = true);
232+
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO = true,
233+
bool EnableNolintBlocks = true);
230234

231235
/// Gets the Fix attached to \p Diagnostic.
232236
/// If there isn't a Fix attached to the diagnostic and \p AnyFix is true, Check
@@ -237,6 +241,9 @@ getFixIt(const tooling::Diagnostic &Diagnostic, bool AnyFix);
237241

238242
/// A diagnostic consumer that turns each \c Diagnostic into a
239243
/// \c SourceManager-independent \c ClangTidyError.
244+
///
245+
/// \param EnableNolintBlocks Enables diagnostic-disabling inside blocks of
246+
/// code, delimited by NOLINTBEGIN and NOLINTEND.
240247
//
241248
// FIXME: If we move away from unit-tests, this can be moved to a private
242249
// implementation file.
@@ -245,7 +252,8 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
245252
ClangTidyDiagnosticConsumer(ClangTidyContext &Ctx,
246253
DiagnosticsEngine *ExternalDiagEngine = nullptr,
247254
bool RemoveIncompatibleErrors = true,
248-
bool GetFixesFromNotes = false);
255+
bool GetFixesFromNotes = false,
256+
bool EnableNolintBlocks = true);
249257

250258
// FIXME: The concept of converting between FixItHints and Replacements is
251259
// more generic and should be pulled out into a more useful Diagnostics
@@ -276,6 +284,7 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
276284
DiagnosticsEngine *ExternalDiagEngine;
277285
bool RemoveIncompatibleErrors;
278286
bool GetFixesFromNotes;
287+
bool EnableNolintBlocks;
279288
std::vector<ClangTidyError> Errors;
280289
std::unique_ptr<llvm::Regex> HeaderFilter;
281290
bool LastErrorRelatesToUserCode;

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

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
#include "GlobList.h"
1010
#include "llvm/ADT/SmallString.h"
1111

12-
using namespace clang;
13-
using namespace tidy;
12+
namespace clang {
13+
namespace tidy {
1414

1515
// Returns true if GlobList starts with the negative indicator ('-'), removes it
1616
// from the GlobList.
@@ -62,3 +62,19 @@ bool GlobList::contains(StringRef S) const {
6262
}
6363
return false;
6464
}
65+
66+
bool CachedGlobList::contains(StringRef S) const {
67+
switch (auto &Result = Cache[S]) {
68+
case Yes:
69+
return true;
70+
case No:
71+
return false;
72+
case None:
73+
Result = GlobList::contains(S) ? Yes : No;
74+
return Result == Yes;
75+
}
76+
llvm_unreachable("invalid enum");
77+
}
78+
79+
} // namespace tidy
80+
} // namespace clang

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

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
#include "clang/Basic/LLVM.h"
1313
#include "llvm/ADT/SmallVector.h"
14+
#include "llvm/ADT/StringMap.h"
1415
#include "llvm/ADT/StringRef.h"
1516
#include "llvm/Support/Regex.h"
1617

@@ -24,6 +25,8 @@ namespace tidy {
2425
/// them in the order of appearance in the list.
2526
class GlobList {
2627
public:
28+
virtual ~GlobList() = default;
29+
2730
/// \p Globs is a comma-separated list of globs (only the '*' metacharacter is
2831
/// supported) with an optional '-' prefix to denote exclusion.
2932
///
@@ -36,18 +39,31 @@ class GlobList {
3639

3740
/// Returns \c true if the pattern matches \p S. The result is the last
3841
/// matching glob's Positive flag.
39-
bool contains(StringRef S) const;
42+
virtual bool contains(StringRef S) const;
4043

4144
private:
42-
4345
struct GlobListItem {
4446
bool IsPositive;
4547
llvm::Regex Regex;
4648
};
4749
SmallVector<GlobListItem, 0> Items;
4850
};
4951

50-
} // end namespace tidy
51-
} // end namespace clang
52+
/// A \p GlobList that caches search results, so that search is performed only
53+
/// once for the same query.
54+
class CachedGlobList final : public GlobList {
55+
public:
56+
using GlobList::GlobList;
57+
58+
/// \see GlobList::contains
59+
bool contains(StringRef S) const override;
60+
61+
private:
62+
enum Tristate { None, Yes, No };
63+
mutable llvm::StringMap<Tristate> Cache;
64+
};
65+
66+
} // namespace tidy
67+
} // namespace clang
5268

5369
#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H

clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,10 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
5151
if (Struct->isTemplated())
5252
return;
5353

54+
// Packing and alignment requirements for invalid decls are meaningless.
55+
if (Struct->isInvalidDecl())
56+
return;
57+
5458
// Get sizing info for the struct.
5559
llvm::SmallVector<std::pair<unsigned int, unsigned int>, 10> FieldSizes;
5660
unsigned int TotalBitSize = 0;

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@
5050
#include "StringConstructorCheck.h"
5151
#include "StringIntegerAssignmentCheck.h"
5252
#include "StringLiteralWithEmbeddedNulCheck.h"
53+
#include "StringviewNullptrCheck.h"
5354
#include "SuspiciousEnumUsageCheck.h"
5455
#include "SuspiciousIncludeCheck.h"
5556
#include "SuspiciousMemoryComparisonCheck.h"
@@ -157,6 +158,8 @@ class BugproneModule : public ClangTidyModule {
157158
"bugprone-string-integer-assignment");
158159
CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
159160
"bugprone-string-literal-with-embedded-nul");
161+
CheckFactories.registerCheck<StringviewNullptrCheck>(
162+
"bugprone-stringview-nullptr");
160163
CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
161164
"bugprone-suspicious-enum-usage");
162165
CheckFactories.registerCheck<SuspiciousIncludeCheck>(

clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ add_clang_library(clangTidyBugproneModule
4545
StringConstructorCheck.cpp
4646
StringIntegerAssignmentCheck.cpp
4747
StringLiteralWithEmbeddedNulCheck.cpp
48+
StringviewNullptrCheck.cpp
4849
SuspiciousEnumUsageCheck.cpp
4950
SuspiciousIncludeCheck.cpp
5051
SuspiciousMemoryComparisonCheck.cpp
@@ -82,4 +83,5 @@ clang_target_link_libraries(clangTidyBugproneModule
8283
clangBasic
8384
clangLex
8485
clangTooling
86+
clangTransformer
8587
)

0 commit comments

Comments
 (0)