Skip to content

Commit

Permalink
LLVM and SPIRV-LLVM-Translator pulldown (WW50)
Browse files Browse the repository at this point in the history
  • Loading branch information
bb-sycl committed Dec 7, 2021
2 parents 3fdc06c + cab1525 commit 7c3a9f1
Show file tree
Hide file tree
Showing 2,808 changed files with 232,015 additions and 109,720 deletions.
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: DO NOT FILE AN ISSUE
about: DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION
title: "DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION"
labels: ''
assignees: ''

---

# DO NOT FILE AN ISSUE

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.

# DO NOT FILE AN ISSUE
2 changes: 2 additions & 0 deletions .github/ISSUE_TEMPLATE/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,5 @@ contact_links:
- name: Ask community a question
url: https://github.com/intel/llvm/discussions/categories/q-a
about: Please use Q&A Discussions category instead of Issues to ask questions

blank_issues_enabled: false
14 changes: 14 additions & 0 deletions .github/ISSUE_TEMPLATE/do-not-file-an-issue.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
name: DO NOT FILE AN ISSUE
about: DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION
title: "DO NOT FILE AN ISSUE DUE TO ONGOING MIGRATION"
labels: ''
assignees: ''

---

# DO NOT FILE AN ISSUE

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.

# DO NOT FILE AN ISSUE
3 changes: 3 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# **DO NOT FILE A PULL REQUEST**

We are in the process of a github migration. Please do not create a pull request as this could interfere with the process.
2 changes: 1 addition & 1 deletion clang-tools-extra/clang-doc/ClangDoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
//
//===----------------------------------------------------------------------===//
//
// This file exposes a method to craete the FrontendActionFactory for the
// This file exposes a method to create the FrontendActionFactory for the
// clang-doc tool. The factory runs the clang-doc mapper on a given set of
// source code files, storing the results key-value pairs in its
// ExecutionContext.
Expand Down
58 changes: 24 additions & 34 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,22 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
return CharSourceRange::getCharRange(SourceRange.getBegin(), End);
};

// We are only interested in valid ranges.
auto ValidRanges =
llvm::make_filter_range(Ranges, [](const CharSourceRange &R) {
return R.getAsRange().isValid();
});

if (Level == DiagnosticsEngine::Note) {
Error.Notes.push_back(TidyMessage);
for (const CharSourceRange &SourceRange : Ranges)
for (const CharSourceRange &SourceRange : ValidRanges)
Error.Notes.back().Ranges.emplace_back(Loc.getManager(),
ToCharRange(SourceRange));
return;
}
assert(Error.Message.Message.empty() && "Overwriting a diagnostic message");
Error.Message = TidyMessage;
for (const CharSourceRange &SourceRange : Ranges)
for (const CharSourceRange &SourceRange : ValidRanges)
Error.Message.Ranges.emplace_back(Loc.getManager(),
ToCharRange(SourceRange));
}
Expand Down Expand Up @@ -149,29 +155,6 @@ ClangTidyError::ClangTidyError(StringRef CheckName,
: tooling::Diagnostic(CheckName, DiagLevel, BuildDirectory),
IsWarningAsError(IsWarningAsError) {}

class ClangTidyContext::CachedGlobList {
public:
CachedGlobList(StringRef Globs) : Globs(Globs) {}

bool contains(StringRef S) {
switch (auto &Result = Cache[S]) {
case Yes:
return true;
case No:
return false;
case None:
Result = Globs.contains(S) ? Yes : No;
return Result == Yes;
}
llvm_unreachable("invalid enum");
}

private:
GlobList Globs;
enum Tristate { None, Yes, No };
llvm::StringMap<Tristate> Cache;
};

ClangTidyContext::ClangTidyContext(
std::unique_ptr<ClangTidyOptionsProvider> OptionsProvider,
bool AllowEnablingAnalyzerAlphaCheckers)
Expand Down Expand Up @@ -291,10 +274,12 @@ std::string ClangTidyContext::getCheckName(unsigned DiagnosticID) const {

ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
ClangTidyContext &Ctx, DiagnosticsEngine *ExternalDiagEngine,
bool RemoveIncompatibleErrors, bool GetFixesFromNotes)
bool RemoveIncompatibleErrors, bool GetFixesFromNotes,
bool EnableNolintBlocks)
: Context(Ctx), ExternalDiagEngine(ExternalDiagEngine),
RemoveIncompatibleErrors(RemoveIncompatibleErrors),
GetFixesFromNotes(GetFixesFromNotes), LastErrorRelatesToUserCode(false),
GetFixesFromNotes(GetFixesFromNotes),
EnableNolintBlocks(EnableNolintBlocks), LastErrorRelatesToUserCode(false),
LastErrorPassesLineFilter(false), LastErrorWasIgnored(false) {}

void ClangTidyDiagnosticConsumer::finalizeLastError() {
Expand Down Expand Up @@ -463,7 +448,8 @@ static bool
lineIsMarkedWithNOLINT(const ClangTidyContext &Context,
SmallVectorImpl<ClangTidyError> &SuppressionErrors,
bool AllowIO, const SourceManager &SM,
SourceLocation Loc, StringRef CheckName) {
SourceLocation Loc, StringRef CheckName,
bool EnableNolintBlocks) {
// Get source code for this location.
FileID File;
unsigned Offset;
Expand Down Expand Up @@ -493,19 +479,21 @@ lineIsMarkedWithNOLINT(const ClangTidyContext &Context,
return true;

// Check if this line is within a NOLINT(BEGIN...END) block.
return lineIsWithinNolintBegin(Context, SuppressionErrors, SM, Loc, CheckName,
return EnableNolintBlocks &&
lineIsWithinNolintBegin(Context, SuppressionErrors, SM, Loc, CheckName,
TextBeforeDiag, TextAfterDiag);
}

static bool lineIsMarkedWithNOLINTinMacro(
const Diagnostic &Info, const ClangTidyContext &Context,
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO) {
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO,
bool EnableNolintBlocks) {
const SourceManager &SM = Info.getSourceManager();
SourceLocation Loc = Info.getLocation();
std::string CheckName = Context.getCheckName(Info.getID());
while (true) {
if (lineIsMarkedWithNOLINT(Context, SuppressionErrors, AllowIO, SM, Loc,
CheckName))
CheckName, EnableNolintBlocks))
return true;
if (!Loc.isMacroID())
return false;
Expand All @@ -520,12 +508,13 @@ namespace tidy {
bool shouldSuppressDiagnostic(
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info,
ClangTidyContext &Context,
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO) {
SmallVectorImpl<ClangTidyError> &SuppressionErrors, bool AllowIO,
bool EnableNolintBlocks) {
return Info.getLocation().isValid() &&
DiagLevel != DiagnosticsEngine::Error &&
DiagLevel != DiagnosticsEngine::Fatal &&
lineIsMarkedWithNOLINTinMacro(Info, Context, SuppressionErrors,
AllowIO);
AllowIO, EnableNolintBlocks);
}

const llvm::StringMap<tooling::Replacements> *
Expand Down Expand Up @@ -555,7 +544,8 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
return;

SmallVector<ClangTidyError, 1> SuppressionErrors;
if (shouldSuppressDiagnostic(DiagLevel, Info, Context, SuppressionErrors)) {
if (shouldSuppressDiagnostic(DiagLevel, Info, Context, SuppressionErrors,
EnableNolintBlocks)) {
++Context.Stats.ErrorsIgnoredNOLINT;
// Ignored a warning, should ignore related notes as well
LastErrorWasIgnored = true;
Expand Down
15 changes: 12 additions & 3 deletions clang-tools-extra/clang-tidy/ClangTidyDiagnosticConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ class CompilationDatabase;
} // namespace tooling

namespace tidy {
class CachedGlobList;

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

std::string CurrentFile;
ClangTidyOptions CurrentOptions;
class CachedGlobList;

std::unique_ptr<CachedGlobList> CheckFilter;
std::unique_ptr<CachedGlobList> WarningAsErrorFilter;

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

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

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

// FIXME: The concept of converting between FixItHints and Replacements is
// more generic and should be pulled out into a more useful Diagnostics
Expand Down Expand Up @@ -276,6 +284,7 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
DiagnosticsEngine *ExternalDiagEngine;
bool RemoveIncompatibleErrors;
bool GetFixesFromNotes;
bool EnableNolintBlocks;
std::vector<ClangTidyError> Errors;
std::unique_ptr<llvm::Regex> HeaderFilter;
bool LastErrorRelatesToUserCode;
Expand Down
20 changes: 18 additions & 2 deletions clang-tools-extra/clang-tidy/GlobList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#include "GlobList.h"
#include "llvm/ADT/SmallString.h"

using namespace clang;
using namespace tidy;
namespace clang {
namespace tidy {

// Returns true if GlobList starts with the negative indicator ('-'), removes it
// from the GlobList.
Expand Down Expand Up @@ -62,3 +62,19 @@ bool GlobList::contains(StringRef S) const {
}
return false;
}

bool CachedGlobList::contains(StringRef S) const {
switch (auto &Result = Cache[S]) {
case Yes:
return true;
case No:
return false;
case None:
Result = GlobList::contains(S) ? Yes : No;
return Result == Yes;
}
llvm_unreachable("invalid enum");
}

} // namespace tidy
} // namespace clang
24 changes: 20 additions & 4 deletions clang-tools-extra/clang-tidy/GlobList.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#include "clang/Basic/LLVM.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringMap.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/Support/Regex.h"

Expand All @@ -24,6 +25,8 @@ namespace tidy {
/// them in the order of appearance in the list.
class GlobList {
public:
virtual ~GlobList() = default;

/// \p Globs is a comma-separated list of globs (only the '*' metacharacter is
/// supported) with an optional '-' prefix to denote exclusion.
///
Expand All @@ -36,18 +39,31 @@ class GlobList {

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

private:

struct GlobListItem {
bool IsPositive;
llvm::Regex Regex;
};
SmallVector<GlobListItem, 0> Items;
};

} // end namespace tidy
} // end namespace clang
/// A \p GlobList that caches search results, so that search is performed only
/// once for the same query.
class CachedGlobList final : public GlobList {
public:
using GlobList::GlobList;

/// \see GlobList::contains
bool contains(StringRef S) const override;

private:
enum Tristate { None, Yes, No };
mutable llvm::StringMap<Tristate> Cache;
};

} // namespace tidy
} // namespace clang

#endif // LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_GLOBLIST_H
4 changes: 4 additions & 0 deletions clang-tools-extra/clang-tidy/altera/StructPackAlignCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,10 @@ void StructPackAlignCheck::check(const MatchFinder::MatchResult &Result) {
if (Struct->isTemplated())
return;

// Packing and alignment requirements for invalid decls are meaningless.
if (Struct->isInvalidDecl())
return;

// Get sizing info for the struct.
llvm::SmallVector<std::pair<unsigned int, unsigned int>, 10> FieldSizes;
unsigned int TotalBitSize = 0;
Expand Down
3 changes: 3 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/BugproneTidyModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
#include "StringConstructorCheck.h"
#include "StringIntegerAssignmentCheck.h"
#include "StringLiteralWithEmbeddedNulCheck.h"
#include "StringviewNullptrCheck.h"
#include "SuspiciousEnumUsageCheck.h"
#include "SuspiciousIncludeCheck.h"
#include "SuspiciousMemoryComparisonCheck.h"
Expand Down Expand Up @@ -157,6 +158,8 @@ class BugproneModule : public ClangTidyModule {
"bugprone-string-integer-assignment");
CheckFactories.registerCheck<StringLiteralWithEmbeddedNulCheck>(
"bugprone-string-literal-with-embedded-nul");
CheckFactories.registerCheck<StringviewNullptrCheck>(
"bugprone-stringview-nullptr");
CheckFactories.registerCheck<SuspiciousEnumUsageCheck>(
"bugprone-suspicious-enum-usage");
CheckFactories.registerCheck<SuspiciousIncludeCheck>(
Expand Down
2 changes: 2 additions & 0 deletions clang-tools-extra/clang-tidy/bugprone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ add_clang_library(clangTidyBugproneModule
StringConstructorCheck.cpp
StringIntegerAssignmentCheck.cpp
StringLiteralWithEmbeddedNulCheck.cpp
StringviewNullptrCheck.cpp
SuspiciousEnumUsageCheck.cpp
SuspiciousIncludeCheck.cpp
SuspiciousMemoryComparisonCheck.cpp
Expand Down Expand Up @@ -82,4 +83,5 @@ clang_target_link_libraries(clangTidyBugproneModule
clangBasic
clangLex
clangTooling
clangTransformer
)
Loading

0 comments on commit 7c3a9f1

Please sign in to comment.