Skip to content

Commit 10d7e2d

Browse files
author
Frank Laub
committed
Merge branch 'master' into plaidml/plaidml-v1
2 parents 7e56550 + cca3f3d commit 10d7e2d

File tree

5,084 files changed

+249664
-85362
lines changed

Some content is hidden

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

5,084 files changed

+249664
-85362
lines changed

.arclint

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,9 @@
66
"script-and-regex.regex": "/^(?P<severity>[[:alpha:]]+)\n(?P<message>[^\n]+)\n(====|(?P<line>\\d),(?P<char>\\d)\n(?P<original>.*)>>>>\n(?P<replacement>.*)<<<<\n)$/s",
77
"include": [
88
"(\\.(cc|cpp|h)$)"
9+
],
10+
"exclude": [
11+
"(^clang/test/)"
912
]
1013
}
1114
}

clang-tools-extra/clang-include-fixer/find-all-symbols/FindAllSymbols.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ CreateSymbolInfo(const NamedDecl *ND, const SourceManager &SM,
9999

100100
SourceLocation Loc = SM.getExpansionLoc(ND->getLocation());
101101
if (!Loc.isValid()) {
102-
llvm::errs() << "Declaration " << ND->getNameAsString() << "("
102+
llvm::errs() << "Declaration " << ND->getDeclName() << "("
103103
<< ND->getDeclKindName()
104104
<< ") has invalid declaration location.";
105105
return llvm::None;

clang-tools-extra/clang-move/HelperDeclRefGraph.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ void HelperDeclRGBuilder::run(
116116
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
117117
assert(DC);
118118
LLVM_DEBUG(llvm::dbgs() << "Find helper function usage: "
119-
<< FuncRef->getDecl()->getNameAsString() << " ("
119+
<< FuncRef->getDecl()->getDeclName() << " ("
120120
<< FuncRef->getDecl() << ")\n");
121121
RG->addEdge(
122122
getOutmostClassOrFunDecl(DC->getCanonicalDecl()),
@@ -126,7 +126,7 @@ void HelperDeclRGBuilder::run(
126126
const auto *DC = Result.Nodes.getNodeAs<Decl>("dc");
127127
assert(DC);
128128
LLVM_DEBUG(llvm::dbgs()
129-
<< "Find helper class usage: " << UsedClass->getNameAsString()
129+
<< "Find helper class usage: " << UsedClass->getDeclName()
130130
<< " (" << UsedClass << ")\n");
131131
RG->addEdge(getOutmostClassOrFunDecl(DC->getCanonicalDecl()), UsedClass);
132132
}

clang-tools-extra/clang-move/Move.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -675,8 +675,8 @@ void ClangMoveTool::run(const ast_matchers::MatchFinder::MatchResult &Result) {
675675
Result.Nodes.getNodeAs<NamedDecl>("helper_decls")) {
676676
MovedDecls.push_back(ND);
677677
HelperDeclarations.push_back(ND);
678-
LLVM_DEBUG(llvm::dbgs() << "Add helper : " << ND->getNameAsString() << " ("
679-
<< ND << ")\n");
678+
LLVM_DEBUG(llvm::dbgs()
679+
<< "Add helper : " << ND->getDeclName() << " (" << ND << ")\n");
680680
} else if (const auto *UD = Result.Nodes.getNodeAs<NamedDecl>("using_decl")) {
681681
MovedDecls.push_back(UD);
682682
}
@@ -735,12 +735,12 @@ void ClangMoveTool::removeDeclsInOldFiles() {
735735
// We remove the helper declarations which are not used in the old.cc after
736736
// moving the given declarations.
737737
for (const auto *D : HelperDeclarations) {
738-
LLVM_DEBUG(llvm::dbgs() << "Check helper is used: "
739-
<< D->getNameAsString() << " (" << D << ")\n");
738+
LLVM_DEBUG(llvm::dbgs() << "Check helper is used: " << D->getDeclName()
739+
<< " (" << D << ")\n");
740740
if (!UsedDecls.count(HelperDeclRGBuilder::getOutmostClassOrFunDecl(
741741
D->getCanonicalDecl()))) {
742742
LLVM_DEBUG(llvm::dbgs() << "Helper removed in old.cc: "
743-
<< D->getNameAsString() << " (" << D << ")\n");
743+
<< D->getDeclName() << " (" << D << ")\n");
744744
RemovedDecls.push_back(D);
745745
}
746746
}
@@ -820,7 +820,7 @@ void ClangMoveTool::moveDeclsToNewFiles() {
820820
D->getCanonicalDecl())))
821821
continue;
822822

823-
LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getNameAsString()
823+
LLVM_DEBUG(llvm::dbgs() << "Helper used in new.cc: " << D->getDeclName()
824824
<< " " << D << "\n");
825825
ActualNewCCDecls.push_back(D);
826826
}

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

Lines changed: 30 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "llvm/ADT/SmallString.h"
1111
#include "llvm/ADT/StringRef.h"
1212
#include "llvm/Support/Error.h"
13+
#include "llvm/Support/WithColor.h"
1314
#include "llvm/Support/raw_ostream.h"
1415

1516
namespace clang {
@@ -126,7 +127,7 @@ bool ClangTidyCheck::OptionsView::get<bool>(StringRef LocalName,
126127
llvm::Expected<bool> ValueOr = get<bool>(LocalName);
127128
if (ValueOr)
128129
return *ValueOr;
129-
logErrToStdErr(ValueOr.takeError());
130+
logIfOptionParsingError(ValueOr.takeError());
130131
return Default;
131132
}
132133

@@ -145,7 +146,7 @@ bool ClangTidyCheck::OptionsView::getLocalOrGlobal<bool>(StringRef LocalName,
145146
llvm::Expected<bool> ValueOr = getLocalOrGlobal<bool>(LocalName);
146147
if (ValueOr)
147148
return *ValueOr;
148-
logErrToStdErr(ValueOr.takeError());
149+
logIfOptionParsingError(ValueOr.takeError());
149150
return Default;
150151
}
151152

@@ -204,13 +205,33 @@ llvm::Expected<int64_t> ClangTidyCheck::OptionsView::getEnumInt(
204205
Iter->getValue().Value);
205206
}
206207

207-
void ClangTidyCheck::OptionsView::logErrToStdErr(llvm::Error &&Err) {
208-
llvm::logAllUnhandledErrors(
209-
llvm::handleErrors(std::move(Err),
210-
[](const MissingOptionError &) -> llvm::Error {
211-
return llvm::Error::success();
212-
}),
213-
llvm::errs(), "warning: ");
208+
void ClangTidyCheck::OptionsView::logIfOptionParsingError(llvm::Error &&Err) {
209+
if (auto RemainingErrors =
210+
llvm::handleErrors(std::move(Err), [](const MissingOptionError &) {}))
211+
llvm::logAllUnhandledErrors(std::move(RemainingErrors),
212+
llvm::WithColor::warning());
214213
}
214+
215+
template <>
216+
Optional<std::string> ClangTidyCheck::OptionsView::getOptional<std::string>(
217+
StringRef LocalName) const {
218+
if (auto ValueOr = get(LocalName))
219+
return *ValueOr;
220+
else
221+
consumeError(ValueOr.takeError());
222+
return llvm::None;
223+
}
224+
225+
template <>
226+
Optional<std::string>
227+
ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal<std::string>(
228+
StringRef LocalName) const {
229+
if (auto ValueOr = getLocalOrGlobal(LocalName))
230+
return *ValueOr;
231+
else
232+
consumeError(ValueOr.takeError());
233+
return llvm::None;
234+
}
235+
215236
} // namespace tidy
216237
} // namespace clang

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

Lines changed: 44 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
268268
if (llvm::Expected<T> ValueOr = get<T>(LocalName))
269269
return *ValueOr;
270270
else
271-
logErrToStdErr(ValueOr.takeError());
271+
logIfOptionParsingError(ValueOr.takeError());
272272
return Default;
273273
}
274274

@@ -314,7 +314,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
314314
if (llvm::Expected<T> ValueOr = getLocalOrGlobal<T>(LocalName))
315315
return *ValueOr;
316316
else
317-
logErrToStdErr(ValueOr.takeError());
317+
logIfOptionParsingError(ValueOr.takeError());
318318
return Default;
319319
}
320320

@@ -353,7 +353,7 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
353353
if (auto ValueOr = get<T>(LocalName, IgnoreCase))
354354
return *ValueOr;
355355
else
356-
logErrToStdErr(ValueOr.takeError());
356+
logIfOptionParsingError(ValueOr.takeError());
357357
return Default;
358358
}
359359

@@ -395,10 +395,35 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
395395
if (auto ValueOr = getLocalOrGlobal<T>(LocalName, IgnoreCase))
396396
return *ValueOr;
397397
else
398-
logErrToStdErr(ValueOr.takeError());
398+
logIfOptionParsingError(ValueOr.takeError());
399399
return Default;
400400
}
401401

402+
/// Returns the value for the option \p LocalName represented as a ``T``.
403+
/// If the option is missing returns None, if the option can't be parsed
404+
/// as a ``T``, log that to stderr and return None.
405+
template <typename T = std::string>
406+
llvm::Optional<T> getOptional(StringRef LocalName) const {
407+
if (auto ValueOr = get<T>(LocalName))
408+
return *ValueOr;
409+
else
410+
logIfOptionParsingError(ValueOr.takeError());
411+
return llvm::None;
412+
}
413+
414+
/// Returns the value for the local or global option \p LocalName
415+
/// represented as a ``T``.
416+
/// If the option is missing returns None, if the
417+
/// option can't be parsed as a ``T``, log that to stderr and return None.
418+
template <typename T = std::string>
419+
llvm::Optional<T> getOptionalLocalOrGlobal(StringRef LocalName) const {
420+
if (auto ValueOr = getLocalOrGlobal<T>(LocalName))
421+
return *ValueOr;
422+
else
423+
logIfOptionParsingError(ValueOr.takeError());
424+
return llvm::None;
425+
}
426+
402427
/// Stores an option with the check-local name \p LocalName with
403428
/// string value \p Value to \p Options.
404429
void store(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
@@ -456,7 +481,8 @@ class ClangTidyCheck : public ast_matchers::MatchFinder::MatchCallback {
456481
void storeInt(ClangTidyOptions::OptionMap &Options, StringRef LocalName,
457482
int64_t Value) const;
458483

459-
static void logErrToStdErr(llvm::Error &&Err);
484+
/// Logs an Error to stderr if a \p Err is not a MissingOptionError.
485+
static void logIfOptionParsingError(llvm::Error &&Err);
460486

461487
std::string NamePrefix;
462488
const ClangTidyOptions::OptionMap &CheckOptions;
@@ -524,6 +550,19 @@ void ClangTidyCheck::OptionsView::store<bool>(
524550
ClangTidyOptions::OptionMap &Options, StringRef LocalName,
525551
bool Value) const;
526552

553+
/// Returns the value for the option \p LocalName.
554+
/// If the option is missing returns None.
555+
template <>
556+
Optional<std::string> ClangTidyCheck::OptionsView::getOptional<std::string>(
557+
StringRef LocalName) const;
558+
559+
/// Returns the value for the local or global option \p LocalName.
560+
/// If the option is missing returns None.
561+
template <>
562+
Optional<std::string>
563+
ClangTidyCheck::OptionsView::getOptionalLocalOrGlobal<std::string>(
564+
StringRef LocalName) const;
565+
527566
} // namespace tidy
528567
} // namespace clang
529568

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ struct EqualClangTidyError {
744744
std::vector<ClangTidyError> ClangTidyDiagnosticConsumer::take() {
745745
finalizeLastError();
746746

747-
llvm::sort(Errors, LessClangTidyError());
747+
llvm::stable_sort(Errors, LessClangTidyError());
748748
Errors.erase(std::unique(Errors.begin(), Errors.end(), EqualClangTidyError()),
749749
Errors.end());
750750
if (RemoveIncompatibleErrors)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ struct NOptionMap {
7070
NOptionMap(IO &, const ClangTidyOptions::OptionMap &OptionMap) {
7171
Options.reserve(OptionMap.size());
7272
for (const auto &KeyValue : OptionMap)
73-
Options.emplace_back(KeyValue.getKey(), KeyValue.getValue().Value);
73+
Options.emplace_back(std::string(KeyValue.getKey()), KeyValue.getValue().Value);
7474
}
7575
ClangTidyOptions::OptionMap denormalize(IO &) {
7676
ClangTidyOptions::OptionMap Map;

clang-tools-extra/clang-tidy/abseil/AbseilMatcher.h

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,18 @@ AST_POLYMORPHIC_MATCHER(
4747
if (PrefixPosition == StringRef::npos)
4848
return false;
4949
Path = Path.drop_front(PrefixPosition + AbslPrefix.size());
50-
static const char *AbseilLibraries[] = {
51-
"algorithm", "base", "container", "debugging", "flags",
52-
"hash", "iterator", "memory", "meta", "numeric",
53-
"random", "strings", "synchronization", "time", "types",
54-
"utility"};
55-
return std::any_of(
56-
std::begin(AbseilLibraries), std::end(AbseilLibraries),
57-
[&](const char *Library) { return Path.startswith(Library); });
50+
static const char *AbseilLibraries[] = {"algorithm", "base",
51+
"container", "debugging",
52+
"flags", "hash",
53+
"iterator", "memory",
54+
"meta", "numeric",
55+
"random", "status",
56+
"strings", "synchronization",
57+
"time", "types",
58+
"utility"};
59+
return llvm::any_of(AbseilLibraries, [&](const char *Library) {
60+
return Path.startswith(Library);
61+
});
5862
}
5963

6064
} // namespace ast_matchers

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ def write_implementation(module_path, module, namespace, check_name_camel):
136136
void %(check_name)s::check(const MatchFinder::MatchResult &Result) {
137137
// FIXME: Add callback implementation.
138138
const auto *MatchedDecl = Result.Nodes.getNodeAs<FunctionDecl>("x");
139-
if (MatchedDecl->getName().startswith("awesome_"))
139+
if (!MatchedDecl->getIdentifier() || MatchedDecl->getName().startswith("awesome_"))
140140
return;
141141
diag(MatchedDecl->getLocation(), "function %%0 is insufficiently awesome")
142142
<< MatchedDecl;

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,14 +30,17 @@ static Preprocessor *PP;
3030

3131
void BadSignalToKillThreadCheck::check(const MatchFinder::MatchResult &Result) {
3232
const auto IsSigterm = [](const auto &KeyValue) -> bool {
33-
return KeyValue.first->getName() == "SIGTERM";
33+
return KeyValue.first->getName() == "SIGTERM" &&
34+
KeyValue.first->hasMacroDefinition();
3435
};
3536
const auto TryExpandAsInteger =
3637
[](Preprocessor::macro_iterator It) -> Optional<unsigned> {
3738
if (It == PP->macro_end())
3839
return llvm::None;
3940
const MacroInfo *MI = PP->getMacroInfo(It->first);
4041
const Token &T = MI->tokens().back();
42+
if (!T.isLiteral() || !T.getLiteralData())
43+
return llvm::None;
4144
StringRef ValueStr = StringRef(T.getLiteralData(), T.getLength());
4245

4346
llvm::APInt IntValue;

0 commit comments

Comments
 (0)