Skip to content

Commit 4dee192

Browse files
authored
LLVM and SPIRV-LLVM-Translator pulldown
LLVM: 67121d7 LLVM-SPIRV-Translator: KhronosGroup/SPIRV-LLVM-Translator@f8b112a
2 parents 49b6223 + 3a2ec88 commit 4dee192

File tree

2,654 files changed

+98143
-46473
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,654 files changed

+98143
-46473
lines changed

clang-tools-extra/clang-apply-replacements/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@ set(LLVM_LINK_COMPONENTS
44

55
add_clang_library(clangApplyReplacements
66
lib/Tooling/ApplyReplacements.cpp
7+
)
78

8-
LINK_LIBS
9+
clang_target_link_libraries(clangApplyReplacements
10+
PRIVATE
911
clangAST
1012
clangBasic
1113
clangRewrite

clang-tools-extra/clang-change-namespace/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
55

66
add_clang_library(clangChangeNamespace
77
ChangeNamespace.cpp
8+
)
89

9-
LINK_LIBS
10+
clang_target_link_libraries(clangChangeNamespace
11+
PRIVATE
1012
clangAST
1113
clangASTMatchers
1214
clangBasic

clang-tools-extra/clang-change-namespace/ChangeNamespace.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ bool isTemplateParameter(TypeLoc Type) {
347347

348348
ChangeNamespaceTool::ChangeNamespaceTool(
349349
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
350-
llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
350+
llvm::ArrayRef<std::string> AllowedSymbolPatterns,
351351
std::map<std::string, tooling::Replacements> *FileToReplacements,
352352
llvm::StringRef FallbackStyle)
353353
: FallbackStyle(FallbackStyle), FileToReplacements(*FileToReplacements),
@@ -365,8 +365,8 @@ ChangeNamespaceTool::ChangeNamespaceTool(
365365
DiffOldNamespace = joinNamespaces(OldNsSplitted);
366366
DiffNewNamespace = joinNamespaces(NewNsSplitted);
367367

368-
for (const auto &Pattern : WhiteListedSymbolPatterns)
369-
WhiteListedSymbolRegexes.emplace_back(Pattern);
368+
for (const auto &Pattern : AllowedSymbolPatterns)
369+
AllowedSymbolRegexes.emplace_back(Pattern);
370370
}
371371

372372
void ChangeNamespaceTool::registerMatchers(ast_matchers::MatchFinder *Finder) {
@@ -800,7 +800,7 @@ void ChangeNamespaceTool::replaceQualifiedSymbolInDeclContext(
800800
Result.SourceManager->getSpellingLoc(End)),
801801
*Result.SourceManager, Result.Context->getLangOpts());
802802
std::string FromDeclName = FromDecl->getQualifiedNameAsString();
803-
for (llvm::Regex &RE : WhiteListedSymbolRegexes)
803+
for (llvm::Regex &RE : AllowedSymbolRegexes)
804804
if (RE.match(FromDeclName))
805805
return;
806806
std::string ReplaceName =

clang-tools-extra/clang-change-namespace/ChangeNamespace.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class ChangeNamespaceTool : public ast_matchers::MatchFinder::MatchCallback {
4949
// files matching `FilePattern`.
5050
ChangeNamespaceTool(
5151
llvm::StringRef OldNs, llvm::StringRef NewNs, llvm::StringRef FilePattern,
52-
llvm::ArrayRef<std::string> WhiteListedSymbolPatterns,
52+
llvm::ArrayRef<std::string> AllowedSymbolPatterns,
5353
std::map<std::string, tooling::Replacements> *FileToReplacements,
5454
llvm::StringRef FallbackStyle = "LLVM");
5555

@@ -166,7 +166,7 @@ class ChangeNamespaceTool : public ast_matchers::MatchFinder::MatchCallback {
166166
llvm::SmallPtrSet<const clang::DeclRefExpr*, 16> ProcessedFuncRefs;
167167
// Patterns of symbol names whose references are not expected to be updated
168168
// when changing namespaces around them.
169-
std::vector<llvm::Regex> WhiteListedSymbolRegexes;
169+
std::vector<llvm::Regex> AllowedSymbolRegexes;
170170
};
171171

172172
} // namespace change_namespace

clang-tools-extra/clang-change-namespace/tool/ClangChangeNamespace.cpp

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -72,20 +72,20 @@ cl::opt<std::string> Style("style",
7272
cl::desc("The style name used for reformatting."),
7373
cl::init("LLVM"), cl::cat(ChangeNamespaceCategory));
7474

75-
cl::opt<std::string> WhiteListFile(
76-
"whitelist_file",
75+
cl::opt<std::string> AllowedFile(
76+
"allowed_file",
7777
cl::desc("A file containing regexes of symbol names that are not expected "
7878
"to be updated when changing namespaces around them."),
7979
cl::init(""), cl::cat(ChangeNamespaceCategory));
8080

81-
llvm::ErrorOr<std::vector<std::string>> GetWhiteListedSymbolPatterns() {
81+
llvm::ErrorOr<std::vector<std::string>> GetAllowedSymbolPatterns() {
8282
std::vector<std::string> Patterns;
83-
if (WhiteListFile.empty())
83+
if (AllowedFile.empty())
8484
return Patterns;
8585

8686
llvm::SmallVector<StringRef, 8> Lines;
8787
llvm::ErrorOr<std::unique_ptr<llvm::MemoryBuffer>> File =
88-
llvm::MemoryBuffer::getFile(WhiteListFile);
88+
llvm::MemoryBuffer::getFile(AllowedFile);
8989
if (!File)
9090
return File.getError();
9191
llvm::StringRef Content = File.get()->getBuffer();
@@ -103,15 +103,15 @@ int main(int argc, const char **argv) {
103103
ChangeNamespaceCategory);
104104
const auto &Files = OptionsParser.getSourcePathList();
105105
tooling::RefactoringTool Tool(OptionsParser.getCompilations(), Files);
106-
llvm::ErrorOr<std::vector<std::string>> WhiteListPatterns =
107-
GetWhiteListedSymbolPatterns();
108-
if (!WhiteListPatterns) {
109-
llvm::errs() << "Failed to open whitelist file " << WhiteListFile << ". "
110-
<< WhiteListPatterns.getError().message() << "\n";
106+
llvm::ErrorOr<std::vector<std::string>> AllowedPatterns =
107+
GetAllowedSymbolPatterns();
108+
if (!AllowedPatterns) {
109+
llvm::errs() << "Failed to open allow file " << AllowedFile << ". "
110+
<< AllowedPatterns.getError().message() << "\n";
111111
return 1;
112112
}
113113
change_namespace::ChangeNamespaceTool NamespaceTool(
114-
OldNamespace, NewNamespace, FilePattern, *WhiteListPatterns,
114+
OldNamespace, NewNamespace, FilePattern, *AllowedPatterns,
115115
&Tool.getReplacements(), Style);
116116
ast_matchers::MatchFinder Finder;
117117
NamespaceTool.registerMatchers(&Finder);

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ add_clang_library(clangDoc
1515
Representation.cpp
1616
Serialize.cpp
1717
YAMLGenerator.cpp
18+
)
1819

19-
LINK_LIBS
20+
clang_target_link_libraries(clangDoc
21+
PRIVATE
2022
clangAnalysis
2123
clangAST
2224
clangASTMatchers

clang-tools-extra/clang-doc/Generators.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ namespace doc {
1515

1616
llvm::Expected<std::unique_ptr<Generator>>
1717
findGeneratorByName(llvm::StringRef Format) {
18-
for (auto I = GeneratorRegistry::begin(), E = GeneratorRegistry::end();
19-
I != E; ++I) {
20-
if (I->getName() != Format)
18+
for (const auto &Generator : GeneratorRegistry::entries()) {
19+
if (Generator.getName() != Format)
2120
continue;
22-
return I->instantiate();
21+
return Generator.instantiate();
2322
}
2423
return createStringError(llvm::inconvertibleErrorCode(),
2524
"can't find generator: " + Format);

clang-tools-extra/clang-include-fixer/CMakeLists.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ add_clang_library(clangIncludeFixer
1111
YamlSymbolIndex.cpp
1212

1313
LINK_LIBS
14+
findAllSymbols
15+
)
16+
17+
clang_target_link_libraries(clangIncludeFixer
18+
PRIVATE
1419
clangAST
1520
clangBasic
1621
clangFormat
@@ -21,7 +26,6 @@ add_clang_library(clangIncludeFixer
2126
clangSerialization
2227
clangTooling
2328
clangToolingCore
24-
findAllSymbols
2529
)
2630

2731
add_subdirectory(plugin)

clang-tools-extra/clang-include-fixer/find-all-symbols/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,10 @@ add_clang_library(findAllSymbols
1212
PragmaCommentHandler.cpp
1313
STLPostfixHeaderMap.cpp
1414
SymbolInfo.cpp
15+
)
1516

16-
LINK_LIBS
17+
clang_target_link_libraries(findAllSymbols
18+
PRIVATE
1719
clangAST
1820
clangASTMatchers
1921
clangBasic

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,10 @@ set(LLVM_LINK_COMPONENTS
66
add_clang_library(clangMove
77
Move.cpp
88
HelperDeclRefGraph.cpp
9+
)
910

10-
LINK_LIBS
11+
clang_target_link_libraries(clangMove
12+
PRIVATE
1113
clangAnalysis
1214
clangAST
1315
clangASTMatchers

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,10 @@ set(LLVM_LINK_COMPONENTS
77
add_clang_library(clangQuery
88
Query.cpp
99
QueryParser.cpp
10+
)
1011

11-
LINK_LIBS
12+
clang_target_link_libraries(clangQuery
13+
PRIVATE
1214
clangAST
1315
clangASTMatchers
1416
clangBasic

clang-tools-extra/clang-reorder-fields/CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,10 @@ set(LLVM_LINK_COMPONENTS
55

66
add_clang_library(clangReorderFields
77
ReorderFieldsAction.cpp
8+
)
89

9-
LINK_LIBS
10+
clang_target_link_libraries(clangReorderFields
11+
PRIVATE
1012
clangAST
1113
clangASTMatchers
1214
clangBasic

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,10 @@ add_clang_library(clangTidy
1515

1616
DEPENDS
1717
ClangSACheckers
18+
)
1819

19-
LINK_LIBS
20+
clang_target_link_libraries(clangTidy
21+
PRIVATE
2022
clangAnalysis
2123
clangAST
2224
clangASTMatchers
@@ -32,7 +34,8 @@ add_clang_library(clangTidy
3234
)
3335

3436
if(CLANG_ENABLE_STATIC_ANALYZER)
35-
target_link_libraries(clangTidy PRIVATE
37+
clang_target_link_libraries(clangTidy
38+
PRIVATE
3639
clangStaticAnalyzerCore
3740
clangStaticAnalyzerFrontend
3841
)

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class ErrorReporter {
106106
DiagPrinter),
107107
SourceMgr(Diags, Files), Context(Context), ApplyFixes(ApplyFixes),
108108
TotalFixes(0), AppliedFixes(0), WarningsAsErrors(0) {
109-
DiagOpts->ShowColors = llvm::sys::Process::StandardOutHasColors();
109+
DiagOpts->ShowColors = Context.getOptions().UseColor.getValueOr(
110+
llvm::sys::Process::StandardOutHasColors());
110111
DiagPrinter->BeginSourceFile(LangOpts);
111112
}
112113

@@ -121,6 +122,8 @@ class ErrorReporter {
121122
{
122123
auto Level = static_cast<DiagnosticsEngine::Level>(Error.DiagLevel);
123124
std::string Name = Error.DiagnosticName;
125+
if (!Error.EnabledDiagnosticAliases.empty())
126+
Name += "," + llvm::join(Error.EnabledDiagnosticAliases, ",");
124127
if (Error.IsWarningAsError) {
125128
Name += ",-warnings-as-errors";
126129
Level = DiagnosticsEngine::Error;

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

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
#include "llvm/ADT/STLExtras.h"
2828
#include "llvm/ADT/SmallString.h"
2929
#include "llvm/Support/Regex.h"
30+
#include "llvm/Support/FormatVariadic.h"
3031
#include <tuple>
3132
#include <vector>
3233
using namespace clang;
@@ -634,6 +635,8 @@ void ClangTidyDiagnosticConsumer::removeIncompatibleErrors() {
634635
std::tuple<unsigned, EventType, int, int, unsigned> Priority;
635636
};
636637

638+
removeDuplicatedDiagnosticsOfAliasCheckers();
639+
637640
// Compute error sizes.
638641
std::vector<int> Sizes;
639642
std::vector<
@@ -728,3 +731,59 @@ std::vector<ClangTidyError> ClangTidyDiagnosticConsumer::take() {
728731
removeIncompatibleErrors();
729732
return std::move(Errors);
730733
}
734+
735+
namespace {
736+
struct LessClangTidyErrorWithoutDiagnosticName {
737+
bool operator()(const ClangTidyError *LHS, const ClangTidyError *RHS) const {
738+
const tooling::DiagnosticMessage &M1 = LHS->Message;
739+
const tooling::DiagnosticMessage &M2 = RHS->Message;
740+
741+
return std::tie(M1.FilePath, M1.FileOffset, M1.Message) <
742+
std::tie(M2.FilePath, M2.FileOffset, M2.Message);
743+
}
744+
};
745+
} // end anonymous namespace
746+
747+
void ClangTidyDiagnosticConsumer::removeDuplicatedDiagnosticsOfAliasCheckers() {
748+
using UniqueErrorSet =
749+
std::set<ClangTidyError *, LessClangTidyErrorWithoutDiagnosticName>;
750+
UniqueErrorSet UniqueErrors;
751+
752+
auto IT = Errors.begin();
753+
while (IT != Errors.end()) {
754+
ClangTidyError &Error = *IT;
755+
std::pair<UniqueErrorSet::iterator, bool> Inserted =
756+
UniqueErrors.insert(&Error);
757+
758+
// Unique error, we keep it and move along.
759+
if (Inserted.second) {
760+
++IT;
761+
} else {
762+
ClangTidyError &ExistingError = **Inserted.first;
763+
const llvm::StringMap<tooling::Replacements> &CandidateFix =
764+
Error.Message.Fix;
765+
const llvm::StringMap<tooling::Replacements> &ExistingFix =
766+
(*Inserted.first)->Message.Fix;
767+
768+
if (CandidateFix != ExistingFix) {
769+
770+
// In case of a conflict, don't suggest any fix-it.
771+
ExistingError.Message.Fix.clear();
772+
ExistingError.Notes.emplace_back(
773+
llvm::formatv("cannot apply fix-it because an alias checker has "
774+
"suggested a different fix-it; please remove one of "
775+
"the checkers ('{0}', '{1}') or "
776+
"ensure they are both configured the same",
777+
ExistingError.DiagnosticName, Error.DiagnosticName)
778+
.str());
779+
}
780+
781+
if (Error.IsWarningAsError)
782+
ExistingError.IsWarningAsError = true;
783+
784+
// Since it is the same error, we should take it as alias and remove it.
785+
ExistingError.EnabledDiagnosticAliases.emplace_back(Error.DiagnosticName);
786+
IT = Errors.erase(IT);
787+
}
788+
}
789+
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct ClangTidyError : tooling::Diagnostic {
4848
bool IsWarningAsError);
4949

5050
bool IsWarningAsError;
51+
std::vector<std::string> EnabledDiagnosticAliases;
5152
};
5253

5354
/// Contains displayed and ignored diagnostic counters for a ClangTidy
@@ -246,6 +247,7 @@ class ClangTidyDiagnosticConsumer : public DiagnosticConsumer {
246247
private:
247248
void finalizeLastError();
248249
void removeIncompatibleErrors();
250+
void removeDuplicatedDiagnosticsOfAliasCheckers();
249251

250252
/// Returns the \c HeaderFilter constructed for the options set in the
251253
/// context.

0 commit comments

Comments
 (0)