Skip to content

Commit f3e0f8a

Browse files
committed
Xilinx 2021.1 release
1 parent c150215 commit f3e0f8a

File tree

36,953 files changed

+57370
-4652579
lines changed

Some content is hidden

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

36,953 files changed

+57370
-4652579
lines changed

clang-tools-extra/.arcconfig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
{
2-
"repository.callsign" : "CTE",
3-
"conduit_uri" : "https://reviews.llvm.org/"
2+
"repository.callsign" : "E",
3+
"conduit_uri" : "http://hlsweb.xilinx.com/"
44
}

clang-tools-extra/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ add_subdirectory(include-fixer)
1414
add_subdirectory(pp-trace)
1515
add_subdirectory(tool-template)
1616

17+
add_subdirectory(xilinx-legacy-rewriter)
18+
add_subdirectory(xilinx-dataflow-lawyer)
19+
1720
# Add the common testsuite after all the tools.
1821
if(CLANG_INCLUDE_TESTS)
1922
add_subdirectory(test)

clang-tools-extra/LICENSE.TXT

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,6 @@ Program Directory
6161
------- ---------
6262
clang-tidy clang-tidy/cert
6363
clang-tidy clang-tidy/hicpp
64+
clang-tidy clang-tidy/xilinx
65+
xilinx-dataflow-lawyer xilinx-dataflow-lawyer
66+
xilinx-legacy-rewriter xilinx-legacy-rewriter

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ add_subdirectory(performance)
4343
add_subdirectory(plugin)
4444
add_subdirectory(readability)
4545
add_subdirectory(tool)
46+
add_subdirectory(xilinx)
4647
add_subdirectory(utils)

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -582,6 +582,11 @@ void exportReplacements(const llvm::StringRef MainFilePath,
582582
TUD.MainSourceFile = MainFilePath;
583583
for (const auto &Error : Errors) {
584584
tooling::Diagnostic Diag = Error;
585+
if (Error.RealLoc.isValid()) {
586+
Diag.Message.FilePath = Error.RealFilePath.c_str();
587+
// FIXME: Can not display column info
588+
Diag.Message.FileOffset = Error.RealLoc.getLine();
589+
}
585590
TUD.Diagnostics.insert(TUD.Diagnostics.end(), Diag);
586591
}
587592

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

Lines changed: 52 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
// This file is distributed under the University of Illinois Open Source
66
// License. See LICENSE.TXT for details.
77
//
8+
// And has the following additional copyright:
9+
//
10+
// (C) Copyright 2016-2020 Xilinx, Inc.
11+
// All Rights Reserved.
12+
//
813
//===----------------------------------------------------------------------===//
914
///
1015
/// \file This file implements ClangTidyDiagnosticConsumer, ClangTidyContext
@@ -23,6 +28,7 @@
2328
#include "clang/Frontend/DiagnosticRenderer.h"
2429
#include "llvm/ADT/STLExtras.h"
2530
#include "llvm/ADT/SmallString.h"
31+
#include "llvm/Support/Path.h"
2632
#include <tuple>
2733
#include <vector>
2834
using namespace clang;
@@ -79,12 +85,12 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
7985
tooling::Replacement Replacement(Loc.getManager(), Range,
8086
FixIt.CodeToInsert);
8187
llvm::Error Err = Error.Fix[Replacement.getFilePath()].add(Replacement);
82-
// FIXME: better error handling (at least, don't let other replacements be
83-
// applied).
8488
if (Err) {
89+
// FIXME: better error handling. Now if there are conflicted fixes,
90+
// neither one will be applied.
8591
llvm::errs() << "Fix conflicts with existing fix! "
8692
<< llvm::toString(std::move(Err)) << "\n";
87-
assert(false && "Fix conflicts with existing fix!");
93+
Error.HasConflictedFixes = true;
8894
}
8995
}
9096
}
@@ -109,9 +115,15 @@ class ClangTidyDiagnosticRenderer : public DiagnosticRenderer {
109115

110116
ClangTidyError::ClangTidyError(StringRef CheckName,
111117
ClangTidyError::Level DiagLevel,
112-
StringRef BuildDirectory, bool IsWarningAsError)
118+
StringRef BuildDirectory, bool IsWarningAsError,
119+
bool HasConflictedFixes = false,
120+
PresumedLoc Loc = PresumedLoc(),
121+
std::string FilePath = std::string())
113122
: tooling::Diagnostic(CheckName, DiagLevel, BuildDirectory),
114-
IsWarningAsError(IsWarningAsError) {}
123+
IsWarningAsError(IsWarningAsError),
124+
HasConflictedFixes(HasConflictedFixes), RealLoc(Loc),
125+
RealFilePath(FilePath) {
126+
}
115127

116128
// Returns true if GlobList starts with the negative indicator ('-'), removes it
117129
// from the GlobList.
@@ -267,6 +279,7 @@ ClangTidyDiagnosticConsumer::ClangTidyDiagnosticConsumer(
267279
Diags = llvm::make_unique<DiagnosticsEngine>(
268280
IntrusiveRefCntPtr<DiagnosticIDs>(new DiagnosticIDs), &*DiagOpts, this,
269281
/*ShouldOwnClient=*/false);
282+
DiagOpts->ShowPresumedLoc = 1;
270283
Context.setDiagnosticsEngine(Diags.get());
271284
}
272285

@@ -379,6 +392,24 @@ static bool LineIsMarkedWithNOLINTinMacro(SourceManager &SM, SourceLocation Loc,
379392
return false;
380393
}
381394

395+
static std::string GetAbsoluteFilename(const Diagnostic &Info,
396+
PresumedLoc PLoc) {
397+
if (PLoc.isInvalid() || !Info.hasSourceManager())
398+
return std::string();
399+
const auto &SM = Info.getSourceManager();
400+
StringRef Filename = PLoc.getFilename();
401+
SmallVector<char, 128> AbsoluteFilename;
402+
const DirectoryEntry *Dir =
403+
SM.getFileManager().getDirectory(llvm::sys::path::parent_path(Filename));
404+
if (Dir) {
405+
StringRef DirName = SM.getFileManager().getCanonicalName(Dir);
406+
llvm::sys::path::append(AbsoluteFilename, DirName,
407+
llvm::sys::path::filename(Filename));
408+
Filename = StringRef(AbsoluteFilename.data(), AbsoluteFilename.size());
409+
}
410+
return Filename.str();
411+
}
412+
382413
void ClangTidyDiagnosticConsumer::HandleDiagnostic(
383414
DiagnosticsEngine::Level DiagLevel, const Diagnostic &Info) {
384415
if (LastErrorWasIgnored && DiagLevel == DiagnosticsEngine::Note)
@@ -398,6 +429,12 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
398429
LastErrorWasIgnored = false;
399430
// Count warnings/errors.
400431
DiagnosticConsumer::HandleDiagnostic(DiagLevel, Info);
432+
FullSourceLoc Loc =
433+
(Info.getLocation().isInvalid())
434+
? FullSourceLoc()
435+
: FullSourceLoc(Info.getLocation(), Info.getSourceManager());
436+
PresumedLoc PLoc = Loc.getPresumedLoc();
437+
auto FilePath = GetAbsoluteFilename(Info, PLoc);
401438

402439
if (DiagLevel == DiagnosticsEngine::Note) {
403440
assert(!Errors.empty() &&
@@ -440,18 +477,16 @@ void ClangTidyDiagnosticConsumer::HandleDiagnostic(
440477
bool IsWarningAsError = DiagLevel == DiagnosticsEngine::Warning &&
441478
Context.treatAsError(CheckName);
442479
Errors.emplace_back(CheckName, Level, Context.getCurrentBuildDirectory(),
443-
IsWarningAsError);
480+
IsWarningAsError, false /* HasConflictedFixes */, PLoc,
481+
FilePath);
444482
}
445483

446484
ClangTidyDiagnosticRenderer Converter(
447485
Context.getLangOpts(), &Context.DiagEngine->getDiagnosticOptions(),
448486
Errors.back());
449487
SmallString<100> Message;
450488
Info.FormatDiagnostic(Message);
451-
FullSourceLoc Loc =
452-
(Info.getLocation().isInvalid())
453-
? FullSourceLoc()
454-
: FullSourceLoc(Info.getLocation(), Info.getSourceManager());
489+
455490
Converter.emitDiagnostic(Loc, DiagLevel, Message, Info.getRanges(),
456491
Info.getFixItHints());
457492

@@ -633,6 +668,13 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors(
633668
}
634669

635670
for (unsigned I = 0; I < Errors.size(); ++I) {
671+
if (Errors[I].HasConflictedFixes) {
672+
Errors[I].Fix.clear();
673+
Errors[I].Notes.emplace_back(
674+
"Found multiple fixes which conflict to each other and can not be "
675+
"resolved. Fixes will not be applied.");
676+
}
677+
636678
if (!Apply[I]) {
637679
Errors[I].Fix.clear();
638680
Errors[I].Notes.emplace_back(

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@
55
// This file is distributed under the University of Illinois Open Source
66
// License. See LICENSE.TXT for details.
77
//
8+
// And has the following additional copyright:
9+
//
10+
// (C) Copyright 2016-2020 Xilinx, Inc.
11+
// All Rights Reserved.
12+
//
813
//===----------------------------------------------------------------------===//
914

1015
#ifndef LLVM_CLANG_TOOLS_EXTRA_CLANG_TIDY_CLANGTIDYDIAGNOSTICCONSUMER_H
@@ -42,9 +47,13 @@ namespace tidy {
4247
/// FIXME: Make Diagnostics flexible enough to support this directly.
4348
struct ClangTidyError : tooling::Diagnostic {
4449
ClangTidyError(StringRef CheckName, Level DiagLevel, StringRef BuildDirectory,
45-
bool IsWarningAsError);
50+
bool IsWarningAsError, bool HasConflictedFixes,
51+
PresumedLoc Loc, std::string FilePath);
4652

4753
bool IsWarningAsError;
54+
bool HasConflictedFixes;
55+
PresumedLoc RealLoc;
56+
std::string RealFilePath;
4857
};
4958

5059
/// \brief Read-only set of strings represented as a list of positive and

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

100644100755
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ ClangTidyOptions::mergeWith(const ClangTidyOptions &Other) const {
152152
overrideValue(Result.User, Other.User);
153153
mergeVectors(Result.ExtraArgs, Other.ExtraArgs);
154154
mergeVectors(Result.ExtraArgsBefore, Other.ExtraArgsBefore);
155+
overrideValue(Result.ImportDirective, Other.ImportDirective);
155156

156157
for (const auto &KeyValue : Other.CheckOptions)
157158
Result.CheckOptions[KeyValue.first] = KeyValue.second;

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

100644100755
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ struct ClangTidyOptions {
108108

109109
/// \brief Add extra compilation arguments to the start of the list.
110110
llvm::Optional<ArgList> ExtraArgsBefore;
111+
112+
/// \brief file path for json format directive.
113+
llvm::Optional<std::string> ImportDirective;
111114
};
112115

113116
/// \brief Abstract interface for retrieving various ClangTidy options.

clang-tools-extra/clang-tidy/add_new_check.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,14 @@ def write_header(module_path, module, check_name, check_name_camel):
6464
// This file is distributed under the University of Illinois Open Source
6565
// License. See LICENSE.TXT for details.
6666
//
67+
""")
68+
if module=='xilinx':
69+
f.write("""// And has the following additional copyright:
70+
//
71+
// (C) Copyright 2016-2020 Xilinx, Inc.
72+
// All Rights Reserved.
73+
//""")
74+
f.write("""
6775
//===----------------------------------------------------------------------===//
6876
6977
#ifndef %(header_guard)s
@@ -115,6 +123,14 @@ def write_implementation(module_path, module, check_name_camel):
115123
// This file is distributed under the University of Illinois Open Source
116124
// License. See LICENSE.TXT for details.
117125
//
126+
""")
127+
if module=='xilinx':
128+
f.write("""// And has the following additional copyright:
129+
//
130+
// (C) Copyright 2016-2020 Xilinx, Inc.
131+
// All Rights Reserved.
132+
//""")
133+
f.write("""
118134
//===----------------------------------------------------------------------===//
119135
120136
#include "%(check_name)s.h"

0 commit comments

Comments
 (0)